{"id":4600,"date":"2024-03-28T12:00:21","date_gmt":"2024-03-28T19:00:21","guid":{"rendered":"https:\/\/www.cloudacm.com\/?p=4600"},"modified":"2024-03-26T07:17:16","modified_gmt":"2024-03-26T14:17:16","slug":"a-scope-in-a-pinch","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=4600","title":{"rendered":"A Scope In A Pinch"},"content":{"rendered":"<p>When working with device electronics, it&#8217;s important to work within voltage and signal limits. Designing circuits that interact with those devices need to have expected results. There can be several stages in a circuit design where voltages or signals are changed. It can be extremely challenging to design without some kind of measurement at each stage. Having a tool that can measure multiple stages at the same time in realtime is key. Fortunately, this can be done for little cost using a micro-controller with a serial connection to the Arduino IDE.<\/p>\n<p>This post will cover the use and customization of the Serial Plotter available in the Arduino IDE Tools menu. This post is based off of the following link that introduces its use, <a href=\"https:\/\/www.makerguides.com\/how-to-visualise-data-on-the-arduino-serial-plotter\/\">https:\/\/www.makerguides.com\/how-to-visualise-data-on-the-arduino-serial-plotter\/<\/a>. The plotter was added to the Arduino IDE in version 1.6.6 (2015.11.03), based on the release notes <a href=\"https:\/\/www.arduino.cc\/en\/software\/ReleaseNotes\">https:\/\/www.arduino.cc\/en\/software\/ReleaseNotes<\/a>. However, several updates have been made since and more are likely to be introduced.<\/p>\n<p>The Serial Plotter configuration file is theme.txt, which is located under the lib\\theme directories. The &#8220;GUI &#8211; PLOTTING&#8221; section in that file contains the following lines in the examples used below.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\"># GUI - PLOTTING\r\n# Comments - multiple color output of signals\r\n\r\n# Black Background\r\nplotting.bgcolor = #000000\r\n\r\nplotting.color = #c0c0c0\r\nplotting.gridcolor = #808080\r\nplotting.boundscolor = #c0c0c0\r\n\r\n# Limit to 7 signals to be plotted\r\nplotting.graphcolor.size = 7\r\n\r\n# Colors for each signal line to be plotted\r\n# - uses #rrggbb hex values\r\nplotting.graphcolor.00 = #bb44bb\r\nplotting.graphcolor.01 = #ff4444\r\nplotting.graphcolor.02 = #ff8800\r\nplotting.graphcolor.03 = #bbbb00\r\nplotting.graphcolor.04 = #00bb00\r\nplotting.graphcolor.05 = #00bbbb\r\nplotting.graphcolor.06 = #0044ff<\/pre>\n<p>The following plot shows an example of various signals with these theme settings.<\/p>\n<p><a href=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4603\" src=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example1.png\" alt=\"\" width=\"854\" height=\"363\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example1.png 854w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example1-300x128.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example1-768x326.png 768w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example1-604x257.png 604w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/a><\/p>\n<p>Any changes made to the theme.txt file require that the IDE be restarted to take effect. In the next example, the colors have been changed so that attention is focused on the signal of interest.<\/p>\n<p><a href=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4605\" src=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example2.png\" alt=\"\" width=\"854\" height=\"362\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example2.png 854w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example2-300x127.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example2-768x326.png 768w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2024\/03\/SerialPlotter-Example2-604x256.png 604w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/a><\/p>\n<p>This is the code used for these examples, which runs on an Arduino UNO.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">float Sawtooth = -4.05;\r\nfloat SWFactor = .18;\r\nfloat Sinewave;\r\nfloat Squarewave = 0;\r\nfloat SquarewaveValue = 4;\r\nfloat RCTime = .1;\r\nfloat RCTimeFactor = .6;\r\nfloat RCTimeMultiplier = .85;\r\nfloat UpperFixed = 1.85;\r\nfloat LowerFixed = .85;\r\nlong DelayTime = 50;\r\n\r\nvoid setup(void) \r\n{\r\n  Serial.begin(115200);\r\n  while (!Serial) {\r\n      delay(1);\r\n  }\r\n  \r\n  Serial.print(\"Sine,\");\r\n  Serial.print(\"Cosine,\");\r\n  Serial.print(\"Sawtooth,\");\r\n  Serial.print(\"Square,\");\r\n  Serial.print(\"RCTime,\");\r\n  Serial.print(\"UpperFixed,\");\r\n  Serial.print(\"LowerFixed\");\r\n  Serial.println(\"\");\r\n    \r\n  \r\n\r\n}\r\n\r\nvoid loop(void) \r\n{\r\n\r\nfor (Sinewave = 0; Sinewave &lt; 180; Sinewave=Sinewave + 4) {\r\n  \r\nSerial.print(3.6*sin(Sinewave * (PI \/ 180)));\r\nSerial.print(\",\");\r\nSerial.print(3.6*cos(Sinewave * (PI \/ 180)));\r\nSerial.print(\",\");\r\nSawtooth = Sawtooth + SWFactor;\r\nSerial.print(Sawtooth);\r\nSerial.print(\",\");\r\nSquarewave = SquarewaveValue;\r\nSerial.print(Squarewave);\r\nSerial.print(\",\");\r\nRCTime = (RCTime + RCTimeFactor)* RCTimeMultiplier;\r\nSerial.print(RCTime);\r\nSerial.print(\",\");\r\nSerial.print(UpperFixed);\r\nSerial.print(\",\");\r\nSerial.println(LowerFixed);\r\ndelay (DelayTime);\r\n}\r\n\r\nfor (Sinewave = 180; Sinewave &lt; 360; Sinewave=Sinewave + 4) {\r\n  \r\nSerial.print(3.6*sin(Sinewave * (PI \/ 180)));\r\nSerial.print(\",\");\r\nSerial.print(3.6*cos(Sinewave * (PI \/ 180)));\r\nSerial.print(\",\");\r\nSawtooth = Sawtooth - SWFactor;\r\nSerial.print(Sawtooth);\r\nSerial.print(\",\");\r\nSquarewave = -(SquarewaveValue);\r\nSerial.print(Squarewave);\r\nSerial.print(\",\");\r\nRCTime = (RCTime - RCTimeFactor)* RCTimeMultiplier;\r\nSerial.print(RCTime);\r\nSerial.print(\",\");\r\nSerial.print(UpperFixed);\r\nSerial.print(\",\");\r\nSerial.println(LowerFixed);\r\ndelay (DelayTime);\r\n}\r\n\r\n\r\n\r\n\r\n}<\/pre>\n<p>Using the Serial Plotter tool is a simple and quick way to visualize circuit signals and levels. This is another example which uses Processing to provide more sophisticated plots, <a href=\"https:\/\/github.com\/devinaconley\/arduino-plotter\">https:\/\/github.com\/devinaconley\/arduino-plotter<\/a>. The features in the Arduino IDE are likely to change, so check the release notes if this interest you.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with device electronics, it&#8217;s important to work within voltage and signal limits. Designing circuits that interact with those devices need to have expected results. There can be several stages in a circuit design where voltages or signals are changed. It can be extremely challenging to design without some kind of measurement at each stage. Having a tool that can measure multiple stages at the same time in realtime is key. Fortunately, this can be done for little cost&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=4600\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4600","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/4600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4600"}],"version-history":[{"count":6,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/4600\/revisions"}],"predecessor-version":[{"id":4604,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/4600\/revisions\/4604"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}