Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2022:cstan:5 [2022/05/25 12:49]
carlos_javier.del [Hardware Design]
pm:prj2022:cstan:5 [2022/05/25 14:32] (current)
carlos_javier.del [Concluzii]
Line 54: Line 54:
  
 <note tip> <note tip>
-  ​__Arduino ultrasonic sensor (HC-SR04)__+  ​__Arduino ultrasonic sensor (HC-SR04)__
 To measure distances with Arduino we can do it in different ways. There is the infrared sensor, which uses the properties of light to calculate distance, and the Arduino ultrasonic sensor uses the propagation properties of sound to measure distances. More specifically it uses ultrasound. This type of sound waves are above the spectrum audible to humans. To measure distances with Arduino we can do it in different ways. There is the infrared sensor, which uses the properties of light to calculate distance, and the Arduino ultrasonic sensor uses the propagation properties of sound to measure distances. More specifically it uses ultrasound. This type of sound waves are above the spectrum audible to humans.
 The operation is very simple. The sensor sends an ultrasonic wave through the trigger, it bounces off the object and the receiver or echo detects the wave. By knowing how long the wave has taken to travel, we can find out the distance.{{:​pm:​prj2022:​cstan:​psr2.jpg?​200|}} The operation is very simple. The sensor sends an ultrasonic wave through the trigger, it bounces off the object and the receiver or echo detects the wave. By knowing how long the wave has taken to travel, we can find out the distance.{{:​pm:​prj2022:​cstan:​psr2.jpg?​200|}}
  
-  ​__Buzzer__+  ​__Buzzer__
 To correctly simulate the distance sensor we are going to use an Arduino buzzer. These components use piezoelectricity,​ a physical phenomenon that affects certain crystals (quartz is the most common). When a crystal of this type is subjected to piezoelectricity,​ it deforms and vibrates. If we get that vibration to have a frequency within the audible spectrum, we get a sound. {{:​pm:​prj2022:​cstan:​psr3.jpg?​200|}} To correctly simulate the distance sensor we are going to use an Arduino buzzer. These components use piezoelectricity,​ a physical phenomenon that affects certain crystals (quartz is the most common). When a crystal of this type is subjected to piezoelectricity,​ it deforms and vibrates. If we get that vibration to have a frequency within the audible spectrum, we get a sound. {{:​pm:​prj2022:​cstan:​psr3.jpg?​200|}}
  
-  ​__1 green LED, 1 yellow LED, 1 red LED__+  ​__1 green LED, 1 yellow LED, 1 red LED__
 Finally, we incorporate the visual alert system for the Arduino ultrasonic sensor. This allows us to visualise whether we are near or far from an obstacle. Finally, we incorporate the visual alert system for the Arduino ultrasonic sensor. This allows us to visualise whether we are near or far from an obstacle.
-With 3 LEDs (green, yellow and red) we can determine whether we are far, near or in the danger zone.+With 3 LEDs (green, yellow and red). 
  ​{{:​pm:​prj2022:​cstan:​psr4.jpg?​200|}}  ​{{:​pm:​prj2022:​cstan:​psr4.jpg?​200|}}
 +  * __Arduino UNO__
 +
 +  * __Protoboard__
 +Where we will connect the components.
 +  * __Cables__
 +To make the connections.
 +  * __3 Resistors__
 +Of 220 Ω
 </​note>​ </​note>​
 +
 +**ELECTRIC SCHEMATIC**
 +
 +{{:​pm:​prj2022:​cstan:​psr5.png?​200|}}
  
 ===== Software Design ===== ===== Software Design =====
Line 71: Line 83:
  
 <note tip> <note tip>
-Descrierea codului aplicaţiei ​(firmware): +  ***__VARIABLES AND CONSTANTS__** 
-  * mediu de dezvoltare ​(if any(e.gAVR StudioCodeVisionAVR) + 
-  * librării şi surse 3rd-party ​(e.gProcyon AVRlib) +Through the ultrasonic sensor we are going to detect the obstacle. We start programming by declaring the variables and constants. 
-  * algoritmi şi structuri pe care plănuiţi să le implementaţi + 
-  * (etapa 3surse şi funcţii implementate+{{:​pm:​prj2022:​cstan:​psr6.png?​200|}} 
 + 
 +We define the pins for the LEDs, for the ultrasonic sensor and for the Arduino buzzer. Then we declare 4 constants. The first one is the speed of sound converting from metres per second to centimetres per second. We do this by multiplying by 100. The next constants are the decision thresholds we marked earlier. 
 + 
 +  ***__SET UP FUNCTION__** 
 + 
 +In the setup function we start the serial monitor and set the pins to the corresponding mode. The LEDs, the Trigger of the ultrasonic sensor and the buzzer are in output mode (OUTPUT). The Echo pin of the ultrasonic sensor is in INPUT mode. 
 + 
 +{{:pm:​prj2022:​cstan:​psr7.png?​200|}} 
 +{{:​pm:​prj2022:​cstan:​psr8.png?​200|}} 
 + 
 +  ***__LOOP FUNCTION__** 
 + 
 +The loop() function contains the code that will be repeated over and over againThis is where we are going to put all our algorithmthe one we have detailed above. I have split this function into several functions to make the code more readable. 
 + 
 +{{:​pm:​prj2022:​cstan:​psr9.png?​200|}} 
 + 
 +  ***__START ULTRASONIC SENSOR__** 
 + 
 +The first thing we do is to prepare the ultrasonic sensor. We do this with the function initiateTrigger() which sends a pulseIt starts in the low state for 2 milliseconds,​ then 10 milliseconds in the high state and finally we put it in the low state. This indicates that the signal will then be sent to be picked up by echo. 
 + 
 +{{:​pm:​prj2022:​cstan:​psr10.png?​200|}} 
 + 
 +  ***__CALCULATE DISTANCE OF OBJECTS__** 
 + 
 +Once the sensor is ready, we can use it to calculate the distance. We do this with the function calculateDistance(). It is a particular function as it will return a value. This is done by putting at the end (or wherever you want) the reserved word return followed by the value you want to return. All code below the return is not executed, so be careful. In this case I return the calculated distance inside the function which is a float variable. 
 +The pulseIn function detects just that, and returns the elapsed time in microseconds. For this reason, it must be converted to seconds by multiplying by 0.000001, which is the same as dividing by 1,000,000. With this information we can now apply the formula to calculate the distance as a function of time and speed. 
 + 
 +{{:​pm:​prj2022:​cstan:​psr11.png?​200|}} 
 + 
 +  ***__TRIGGER ALERTS__** 
 + 
 +Once we have the distance calculated, we can decide whether we are in the situation to send an alert or not. Whenever the distance is below the first threshold ​(green LED threshold and the least restrictive), we will launch the corresponding visual and audible alert. 
 + 
 +{{:​pm:​prj2022:​cstan:​psr12.png?​200|}} 
 + 
 +  ***__FINAL CODE__** 
 + 
 +{{:​pm:​prj2022:​cstan:​psr13.png?​200|}} {{:​pm:​prj2022:​cstan:​psr14.png?​200|}} {{:​pm:​prj2022:​cstan:​psr15.png?​200|}} {{:​pm:​prj2022:​cstan:​psr16.png?​200|}}
 </​note>​ </​note>​
  
Line 84: Line 134:
 </​note>​ </​note>​
  
-===== Concluzii ​===== +===== Conclusions ​===== 
 +Testing the car sensor sensor car makes it easy for car drivers to park the car.
 ===== Download ===== ===== Download =====
  
Line 159: Line 209:
  
 <note warning> <note warning>
-O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului:​ surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-). 
  
-Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:​pm:​prj20??:​c?​** sau **:​pm:​prj20??:​c?:​nume_student** (dacă este cazul). **Exemplu:​** Dumitru Alin, 331CC -> **:​pm:​prj2009:​cc:​dumitru_alin**. 
-</​note>​ 
  
 ===== Jurnal ===== ===== Jurnal =====
Line 173: Line 220:
  
 <​note>​ <​note>​
-Listă cu documente, datasheet-uri,​ resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. 
-</​note>​ 
  
-<​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ 
  
pm/prj2022/cstan/5.1653472144.txt.gz · Last modified: 2022/05/25 12:49 by carlos_javier.del
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0