{"id":23130,"date":"2017-12-06T08:34:09","date_gmt":"2017-12-06T16:34:09","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=23130"},"modified":"2021-06-10T16:11:06","modified_gmt":"2021-06-10T23:11:06","slug":"reading-arduino-and-servo-data","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/reading-arduino-and-servo-data\/","title":{"rendered":"Reading Arduino Servo Data"},"content":{"rendered":"<section id=\"about-project\" class=\"section-container collapsed\">\n<div class=\"section-content hljs-active hljs-monokai\">\n<div class=\"medium-editor\">\n<p>This blog post will show you how to use your Analog Discovery 2 to verify what the signal looks like from an Arduino PWM pin in LabVIEW. To do this we will use a\u00a0LabVIEW VI, called LabForms, which allows you to\u00a0connect an\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply\/\">Analog Discovery 2\u00a0<\/a>USB Oscilloscope to LabVIEW. The LabVIEW code uses the\u00a0<a href=\"https:\/\/decibel.ni.com\/content\/docs\/DOC-44838\">LabVIEW driver for the Analog Discovery 2<\/a>,\u00a0which lets you access the analog scope and Waveform Generator\u00a0(WaveGen)\u00a0functionalities of the Analog Discovery with LabVIEW.<\/p>\n<h3>Materials Needed<\/h3>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/380903\/picture_yqkLO1IT2z.jpg?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>Everything from Setup (OpenScope, micro USB, wires)<\/li>\n<\/ul>\n<ul>\n<li>Breadboard (from Parts Kit)<\/li>\n<\/ul>\n<ul>\n<li>Servo (from Parts Kit)<\/li>\n<\/ul>\n<ul>\n<li>Arduino<\/li>\n<\/ul>\n<ul>\n<li>USB-B Cable<\/li>\n<\/ul>\n<ul>\n<li>Mini Grabbers<\/li>\n<\/ul>\n<ul>\n<li><a href=\"https:\/\/digilent.com\/shop\/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply\/\" rel=\"nofollow\">Analog Discovery 2<\/a><\/li>\n<\/ul>\n<ul>\n<li><a href=\"https:\/\/digilent.com\/shop\/labview-home-bundle\/\" rel=\"nofollow\">LabVIEW<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Verifying the Servo Signal<\/strong><\/p>\n<p>Connect your Servo to your Arduino using breadboard wires.<\/p>\n<ul>\n<li>Orange servo wire \u2013 Pin 9<\/li>\n<\/ul>\n<ul>\n<li>Red servo wire \u2013 Power 5V<\/li>\n<\/ul>\n<ul>\n<li>Black\/Brown servo wire \u2013 GND<\/li>\n<\/ul>\n<ul>\n<li>The servo should be in SWEEP mode<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379518\/picture1_Pr8UJj9pSi.jpg?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<div><strong>PWN<\/strong><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>The Arduino implements a PWM signal, that is a square wave with a duty cycle that can range from 0% to 100%.<\/li>\n<\/ul>\n<ul>\n<li>We will use LabForms and the\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply\/\" rel=\"nofollow\">Analog Discovery 2<\/a>, to see exactly how long the duty cycle is on, what voltage, and duration.<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379519\/picture3__aSHizDZLrB.png?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>Connect the Analog Discovery 2 to Arduino<\/strong><\/p>\n<ul>\n<li>Disconnect the Servo<\/li>\n<\/ul>\n<ul>\n<li>Remember, the PWM Signal for the Servo is on Pin 9 of the Arduino.<\/li>\n<\/ul>\n<ul>\n<li>Use a breadboard wire, connect OSC1 (Orange Wire) to Pin 9.<\/li>\n<\/ul>\n<ul>\n<li>Close out LabForms, open up a new window (so the settings reset to default).<\/li>\n<\/ul>\n<ul>\n<li>Hit Run.<\/li>\n<\/ul>\n<p><strong>Grounding the Oscilloscope Channel<\/strong><\/p>\n<ul>\n<li>Anytime you use your Oscilloscope channel, you need to have a Ground connected. In the previous exercise when we tied AWG1 to OSC1, the signal and the scope have the same ground (the\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply\/\" rel=\"nofollow\">Analog Discovery 2<\/a>\u00a0ground). Since the Arduino is on a different circuit, the\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply\/\" rel=\"nofollow\">Analog Discovery 2<\/a>\u00a0needs to know its ground in order to correctly measure the signal. Let\u2019s demonstrate this.<\/li>\n<\/ul>\n<ul>\n<li>Plug a breadboard wire into the\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply\/\" rel=\"nofollow\">Analog Discovery 2<\/a>\u00a0analog ground (orange or blue with white stripe) and plug it into one of the Arduino Ground Pins.<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379570\/picture3_KA5f81xDWF.jpg?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>Adjust the Signal on the Screen<\/strong><\/p>\n<ul>\n<li>The Arduino puts out 5V signals. We suggest \u201czooming out\u201d so you have the signal cleanly on your screen.<\/li>\n<\/ul>\n<ul>\n<li>\u201cVolts\/\u201d will allow you to change the Y Scale of the graph. Offset will allow you to move where 0 is.<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379571\/1_bR4LQsYhLk.PNG?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>Best Fit<\/strong><\/p>\n<ul>\n<li>It\u2019s important to make sure that the screen is \u201cfocused\u201d on the part of the waveform with the information we need.<\/li>\n<\/ul>\n<ul>\n<li>For this exercise we are interested in what happens when the signal goes high, so the top of the waveform needs to be seen.<\/li>\n<\/ul>\n<ul>\n<li>Change your Volts\/ Division to 1.00 V and Offset to 1.5 V (you can scroll or type it in). You can also type in mV instead of V.<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379597\/1_2_7yTokAAHuu.PNG?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 id=\"toc-cursor-7\"><strong style=\"font-size: 14px; color: #606569; line-height: 1.857;\">Cursor<\/strong><br \/>\n<i class=\"fa fa-link\"><\/i><\/h3>\n<ul>\n<li>Cursors are a way in which you can set points of interest on a screen, and display the exact value.<\/li>\n<\/ul>\n<ul>\n<li>LabForms allows you to put single cursors on Time or Voltage.<\/li>\n<\/ul>\n<ul>\n<li>Time \u2013 We\u2019ll use this to see if the PWM signal has a consistent duty cycle<\/li>\n<\/ul>\n<ul>\n<li>Voltage \u2013 We\u2019ll use this to see what Voltage the PWM signal peaks at.<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379599\/2_XKIrIOkG3P.PNG?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<div><strong>Testing Cursors<\/strong><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li>Hit SINGLE to capture a single acquisition of the waveform<\/li>\n<\/ul>\n<ul>\n<li>Turn on Cursors, select Time<\/li>\n<\/ul>\n<ul>\n<li>Line the cursors up with the edges of the signal by moving the dotted lines at the top of the graph<\/li>\n<\/ul>\n<ul>\n<li>Pay attention to the calculations to the right of the cursors button<\/li>\n<\/ul>\n<ul>\n<li>Follow the same procedure for Voltage<\/li>\n<\/ul>\n<div>\n<div>\n<div class=\"image_carousel__container___hMJxn\">\n<div class=\"image_carousel__wrapper___102VA\">\n<div class=\"image_carousel__scrollContainer___3mmPE \">\n<div class=\"image_carousel__imageContainer___22WPm\">\n<div class=\"image_carousel__imageWrapper___39AG2\"><img decoding=\"async\" class=\"image_carousel__image___2-CjO \" src=\"https:\/\/hackster.imgix.net\/uploads\/attachments\/379600\/3_mJLDP4uZtn.PNG?auto=compress%2Cformat&amp;w=680&amp;h=510&amp;fit=max\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n<section id=\"code\" class=\"section-container\">\n<p class=\"section-title\">Thank you for reading my blog post; if you want to learn more, please check out my Instructable &#8220;<a href=\"http:\/\/www.instructables.com\/id\/Analog-Discovery-2-USB-Oscilloscope-LabVIEW2016-Up\/\">Analog Discovery 2 USB Oscilloscope + LabVIEW(2016 update)<\/a>&#8220;. \u00a0If you are interested in making this project yourself but don&#8217;t have the right supplies, you can purchase\u00a0LabVIEW 2014 home bundle\u00a0<a href=\"https:\/\/digilent.com\/shop\/labview-home-bundle\/\">here<\/a>, and if you are a student the\u00a0<a href=\"https:\/\/digilent.com\/shop\/labview-home-bundle\/\">Analog Discovery 2<\/a>\u00a0has an academic discount available. Please comment below with any questions or comments you may have!<\/p>\n<p>&nbsp;<\/p>\n<\/section>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-23130 jlk' data-task='like' data-post_id='23130' data-nonce='822831b204' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-23130 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-23130 jlk' data-task='unlike' data-post_id='23130' data-nonce='822831b204' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-23130 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-23130 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>Learn how to measure an Arduino servo signal with Analog Discovery 2 In LabVIEW.<\/p>\n","protected":false},"author":42,"featured_media":23128,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4312],"tags":[111],"ppma_author":[4493],"class_list":["post-23130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-usb-scopes-analyzers-generators","tag-analog-discovery"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2017\/12\/p_Yq5dfPXKcV-1.jpg","authors":[{"term_id":4493,"user_id":42,"is_guest":0,"slug":"astanton","display_name":"Austin Stanton","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/0cc9db2caf6344c8f78ea46c21570f33a954c45596addf479125043e52431de0?s=96&d=mm&r=g","1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":"","9":"","10":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/23130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=23130"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/23130\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/23128"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=23130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=23130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=23130"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=23130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}