{"id":4,"date":"2017-03-19T19:00:11","date_gmt":"2017-03-20T02:00:11","guid":{"rendered":"https:\/\/sysprogs.com\/tutorials\/?p=4"},"modified":"2018-04-25T13:55:31","modified_gmt":"2018-04-25T20:55:31","slug":"capturing-basic-signals","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/analyzer2go\/tutorials\/signals\/","title":{"rendered":"Capturing Basic Signals with Analyzer2Go"},"content":{"rendered":"<p>This tutorial shows how to use Analyzer2Go to capture and quickly analyze a basic digital signal. We will use an STM32F4Discovery board to produce 2 different periodic signals with a timer and use Analyzer2Go to capture and visualize them using another STM32F4Discovery board as a logic analyzer.<\/p>\n<p><strong>Warning! STM32 boards are not 5V-tolerant. If you want to sample 5V logic with them, use a voltage divider.<\/strong><\/p>\n<p>Before you begin, compile and upload a program with the following code to generate 3 signals on the channels 1-3 of timer #4<\/p>\n<pre class=\"\">static TIM_HandleTypeDef s_Timer = { \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.Instance = TIM4\r\n\u00a0\u00a0 \u00a0};\r\n\r\n\u00a0\u00a0 \u00a0int prescaler = 16;\r\n\u00a0\u00a0 \u00a0int period = 8;\r\n\u00a0\u00a0 \u00a0unsigned pulseLength = 1;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0__TIM4_CLK_ENABLE();\r\n\u00a0\u00a0 \u00a0s_Timer.Init.Prescaler = prescaler - 1;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.CounterMode = TIM_COUNTERMODE_UP;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.Period = period - 1;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.RepetitionCounter = 0;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0TIM_OC_InitTypeDef oc = { \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.OCMode = TIM_OCMODE_PWM1,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.Pulse = pulseLength,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.OCPolarity = TIM_OCPOLARITY_HIGH,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.OCNPolarity = TIM_OCPOLARITY_HIGH,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.OCFastMode = TIM_OCFAST_DISABLE,\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.OCIdleState = TIM_OCIDLESTATE_SET\r\n\u00a0\u00a0 \u00a0};\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_Init(&amp;s_Timer) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_ConfigChannel(&amp;s_Timer, &amp;oc, TIM_CHANNEL_1) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_Start(&amp;s_Timer, TIM_CHANNEL_1) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0oc.OCMode = TIM_OCMODE_PWM2;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_ConfigChannel(&amp;s_Timer, &amp;oc, TIM_CHANNEL_2) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_Start(&amp;s_Timer, TIM_CHANNEL_2) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\r\n\u00a0\u00a0 \u00a0oc.OCMode = TIM_OCMODE_TOGGLE;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_ConfigChannel(&amp;s_Timer, &amp;oc, TIM_CHANNEL_3) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_OC_Start(&amp;s_Timer, TIM_CHANNEL_3) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0__GPIOD_CLK_ENABLE();\r\n\u00a0\u00a0 \u00a0GPIO_InitTypeDef GPIO_InitStructure;\r\n\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14;\r\n\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Pull = GPIO_NOPULL;\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Alternate = GPIO_AF2_TIM4;\r\n\u00a0\u00a0 \u00a0HAL_GPIO_Init(GPIOD, &amp;GPIO_InitStructure);<\/pre>\n<ol>\n<li>Connect the board you want to use as a logic analyzer to your computer (only the ST-Link connection is required) and start <a href=\"http:\/\/analyzer2go.com\/download\/\">Analyzer2Go<\/a>. Then select your board type from the list:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-24\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-board.png\" alt=\"\" width=\"848\" height=\"534\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-board.png 848w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-board-300x189.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-board-768x484.png 768w\" sizes=\"(max-width: 848px) 100vw, 848px\" \/><br \/>\nIf Analyzer2Go detects several instances of the same board type, it will show the serial numbers so that you can select a specific one from the list.<\/li>\n<li>When you press OK, Analyzer2Go will automatically install the necessary drivers and load the logic analyzer firmware to the board: <img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25 aligncenter\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/02-conn.png\" alt=\"\" width=\"392\" height=\"790\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/02-conn.png 392w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/02-conn-149x300.png 149w\" sizes=\"(max-width: 392px) 100vw, 392px\" \/><\/li>\n<li>When the board is ready to be used as a logic analyzer, Analyzer2Go will display the picture of the board and the pins that can be used to capture signals:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-26\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-siglist.png\" alt=\"\" width=\"1026\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-siglist.png 1026w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-siglist-300x241.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-siglist-768x616.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-siglist-1024x821.png 1024w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/><\/li>\n<li>Connect the ground line on the 2 boards. Then connect the pins generating the output signals on the first board to the input pins on the second board:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-75\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/2boards-1.jpg\" alt=\"\" width=\"800\" height=\"456\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/2boards-1.jpg 800w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/2boards-1-300x171.jpg 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/2boards-1-768x438.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/li>\n<li>Click on the input pins to begin sampling the signal on them. Analyzer2Go will immediately begin showing the signal level there:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-27\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-sigs.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-sigs.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-sigs-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-sigs-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-sigs-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<li>If the signal switches too fast to be meaningfully displayed on the screen, Analyzer2Go can automatically zoom to a meaningful scale if you double-click on it:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/05-zoomed.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/05-zoomed.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/05-zoomed-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/05-zoomed-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/05-zoomed-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<li>You can add meaningful descriptions to the signals to simplify distinguishing them. They will be preserved next time you start Analyzer2Go with the same board:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-labels.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-labels.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-labels-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-labels-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-labels-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<li>Select one of the short pulses to measure its length. Then click on the &#8220;1&#8221; icon to set the selected time span as a reference clock period:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-30\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-period.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-period.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-period-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-period-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-period-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<li>If you now select the entire clock period, Analyzer2Go will automatically show how many reference clocks fit in the selection and will the values of all signals in each period:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-31\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-periodx8.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-periodx8.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-periodx8-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-periodx8-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-periodx8-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<li>If you are analyzing signals with short period, you can significantly increase the FPS by reducing the amount of data captured in a single frame. Click the &#8220;sampling frequency and triggers&#8221; button and reduce the sampling buffer size to ~1\/5 of the maximum value:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-32\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/09-freq.png\" alt=\"\" width=\"530\" height=\"484\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/09-freq.png 530w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/09-freq-300x274.png 300w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/li>\n<li>The amount of frames captured per second will now greatly increase. Check the status bar below to see the sampling parameters:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-33\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/10-fps.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/10-fps.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/10-fps-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/10-fps-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/10-fps-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<li>Next time you start Analyzer2Go with the same board, it will remember the selected signals, their names and the sampling parameters. You can also save them to workspace files and load them later using the &#8220;Save Workspace&#8221; button:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-34\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/11-workspace.png\" alt=\"\" width=\"1140\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/11-workspace.png 1140w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/11-workspace-300x217.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/11-workspace-768x554.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/11-workspace-1024x739.png 1024w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/li>\n<\/ol>\n<p>Starting from\u00a0version 2.0 Analyzer2Go is compatible with the Cypress\u00a0SuperSpeed Explorer Kit, supporting\u00a0continuous\u00a0capture at 200MHz\u00a0via the fast USB 3.0 interface. Check out\u00a0the <a href=\"https:\/\/sysprogs.com\/analyzer2go\/tutorials\/superspeed\/\">SuperSpeed tutorial<\/a> for details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use Analyzer2Go to capture and quickly analyze a basic digital signal. We will use an<\/p>\n","protected":false},"author":1,"featured_media":37,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12,11],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/4"}],"collection":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":10,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/4\/revisions\/300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media\/37"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}