{"id":910,"date":"2022-06-05T05:41:00","date_gmt":"2022-06-05T05:41:00","guid":{"rendered":"https:\/\/vegaprocessors.in\/blog\/?p=910"},"modified":"2022-06-09T04:18:48","modified_gmt":"2022-06-09T04:18:48","slug":"ultrasonic-sensor-with-thejas-soc","status":"publish","type":"post","link":"https:\/\/vegaprocessors.in\/blog\/ultrasonic-sensor-with-thejas-soc\/","title":{"rendered":"Ultrasonic Sensor with  ARIES v2 Board"},"content":{"rendered":"\n<p>In this tutorial, we are going to interface the HC-SR04  Ultrasonic Sensor with the ARIES v2 Board. An&nbsp;ultrasonic sensor&nbsp;is an electronic device that measures the distance of a target object by emitting&nbsp;ultrasonic&nbsp;sound waves and converts the reflected sound into an electrical signal.&nbsp;<strong>Ultrasonic<\/strong>&nbsp;waves travel faster than the speed of audible sound (i.e. the sound that humans can hear). The Ultrasonic sensors have two main components: the transmitter (which emits the sound using piezoelectric crystals) and the receiver (which encounters the sound after it has traveled to and from the target).<\/p>\n\n\n\n<p>Ultrasonic sensing is one of the best ways to sense proximity and detect levels with high reliability.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">HC-SR04<\/h1>\n\n\n\n<p>This is the HC-SR04 ultrasonic distance sensor. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver, and a control circuit.<\/p>\n\n\n\n<p>The transmitters emit a high-frequency ultrasonic sound, which bounces off any nearby solid objects, and the receiver listens for any return echo. That echo is then processed by the control circuit to calculate the time difference between the signal being transmitted and received. This time can subsequently be used, along with some clever math, to calculate the distance between the sensor and the reflecting object!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/06\/front_main-1024x683.jpeg\" alt=\"\" class=\"wp-image-915\" width=\"590\" height=\"394\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/06\/front_main-1024x683.jpeg 1024w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/06\/front_main-300x200.jpeg 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/06\/front_main-768x512.jpeg 768w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/06\/front_main.jpeg 1500w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-41665783-295e-4655-8277-d85b700b7227\">Circuit Diagram<\/h2>\n\n\n\n<p id=\"block-f309353c-9913-4a11-b66b-e7f73d336b88\">The<strong> ultrasonic<\/strong> <strong>sensor<\/strong> is composed of 4 pins. Connect VCC and GND to +5V and GND respectively. Then connect <strong>Trig<\/strong> to<strong> GPIO0<\/strong> and <strong>Echo <\/strong>to a voltage divider as shown in the  figure below and take output from the voltage divider to <strong>GPIO1<\/strong> of ARIES v2 Board. The voltage divider is used , in order to reduce the input voltage from echo pin to a range of 3.3V.<\/p>\n\n\n\n<p>Now, for powering up and programming the code into the ARIES v2 Board, we have to connect a <strong>micro USB type B<\/strong> (common data cable, used for mobile charging and data transfer) in the <strong>UART0<\/strong> port of the ARIES v2 Board, to a Laptop\/Desktop\/PC with preinstalled VEGA SDK and Toolchain.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/05\/pinmap_Ar_ULTRASONIC.jpg\" alt=\"\" class=\"wp-image-1183\" width=\"837\" height=\"662\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/05\/pinmap_Ar_ULTRASONIC.jpg 671w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/05\/pinmap_Ar_ULTRASONIC-300x237.jpg 300w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong><strong>Ultrasonic Sensor<\/strong><\/strong><\/td><td><strong>ARIES v2 Board<\/strong><\/td><\/tr><tr><td>VCC<\/td><td>5V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>Trigger<\/td><td>GPIO0<\/td><\/tr><tr><td>Echo<\/td><td>R1 ***<\/td><\/tr><\/tbody><\/table><figcaption>*** connect GND to R2 and then take output from the junction of R1 and R2 ,connect it with GPIO1<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-32cb08e5-87b9-4300-9e46-a29be4436adc\"><strong>Procedure<\/strong><\/h2>\n\n\n\n<p id=\"block-fe352b07-a674-4754-b285-bafd33106df7\">After setting up the toolchain and SDK path environments are ready, build the example program for the ultrasonic sensor module by:<\/p>\n\n\n\n<pre id=\"block-98c3408c-130d-4e1c-9247-614ed2ea2608\" class=\"wp-block-code\"><code><strong>cd vega-sdk\/examples\/gpio\/ultrasound_sensor_pgm<\/strong><\/code><\/pre>\n\n\n\n<p><strong>make clean<\/strong> command to clean the executable :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make clean<\/code><\/pre>\n\n\n\n<p>then use <strong>make<\/strong> command to build it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make<\/code><\/pre>\n\n\n\n<p>Now, we can transfer the built program to the board, before transfer please ensure that you have connected UART0 connector of the board to the PC.<\/p>\n\n\n\n<p id=\"block-09fbc4ed-2d51-4916-86e3-5e9d9fc312e3\">Open a new terminal and execute the following command.<\/p>\n\n\n\n<pre id=\"block-42a9557f-d0e9-4acf-badc-ec94ff360de9\" class=\"wp-block-code\"><code><strong>minicom aries<\/strong><\/code><\/pre>\n\n\n\n<p id=\"block-1ce27174-d8f5-4c2b-b17d-683db89940be\">Now you can see the minicom terminal opened and the board uart terminal is ready.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\" id=\"block-1353a31a-4d2d-4bd7-ac98-7d65cae80fc3\"><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"689\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-6.png\" alt=\"\" class=\"wp-image-602\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-6.png 820w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-6-300x252.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-6-768x645.png 768w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/figure>\n\n\n\n<p id=\"block-cd6a17a4-c39e-456a-bd13-46a767c681b1\">Use CTRL+A S to enter file sending menu and select xmodem by pressing <strong>Enter<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"block-09ca85fc-b896-45b0-b7c3-7325f27c48e7\"><img decoding=\"async\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/Screenshot-from-2021-04-30-16-14-03.png\" alt=\"This image has an empty alt attribute; its file name is Screenshot-from-2021-04-30-16-14-03.png\"\/><\/figure>\n\n\n\n<p id=\"block-0493bb63-b7da-4838-b324-03dc3e63853a\">In the next window, with the <strong>space bar<\/strong> select the <strong>ultrasound_sensor_pgm.bin<\/strong> file to be transferred, by pressing <strong>Enter<\/strong>, the transfer process starts.<\/p>\n\n\n\n<p id=\"block-c0f4d3e2-615d-46dc-b456-17b196e9c263\">Wait until the process is completed. The screen should display how much data has been transferred.<\/p>\n\n\n\n<p id=\"block-cf92dbc8-fa97-4bed-aa6d-e08e48e7877e\">After completing transfer the Program will start to execute.<\/p>\n\n\n\n<p id=\"block-c0d91f20-0043-4ee4-9abc-95d51109316b\">The output is displayed in minicom UART terminal:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1178\" height=\"583\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/image-3-edited.png\" alt=\"\" class=\"wp-image-1402\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/image-3-edited.png 1178w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/image-3-edited-300x148.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/image-3-edited-1024x507.png 1024w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/image-3-edited-768x380.png 768w\" sizes=\"auto, (max-width: 1178px) 100vw, 1178px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"VEGA Processor: HC-SR04 Ultrasonic Sensor Demo\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/ih7usyOD-0o?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>for additional information:<\/p>\n\n\n\n<p><a href=\"https:\/\/cdn.sparkfun.com\/datasheets\/Sensors\/Proximity\/HCSR04.pdf\">https:\/\/cdn.sparkfun.com\/datasheets\/Sensors\/Proximity\/HCSR04.pdf<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to interface the HC-SR04 Ultrasonic Sensor with the ARIES v2 Board. An&nbsp;ultrasonic sensor&nbsp;is an electronic device that measures the distance of a target object by emitting&nbsp;ultrasonic&nbsp;sound waves and converts the reflected sound into an electrical signal.&nbsp;Ultrasonic&nbsp;waves travel faster than the speed of audible sound (i.e. the sound that humans [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,14,1],"tags":[75,76,68,72,77,24],"class_list":["post-910","post","type-post","status-publish","format-standard","hentry","category-general","category-tutorials","category-uncategorized","tag-aries-v2-board","tag-c-dac","tag-gpio","tag-hc-sr04","tag-thejas-32","tag-vegaprocessor"],"_links":{"self":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/comments?post=910"}],"version-history":[{"count":24,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/910\/revisions"}],"predecessor-version":[{"id":1403,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/910\/revisions\/1403"}],"wp:attachment":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/media?parent=910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/categories?post=910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/tags?post=910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}