Difference between revisions of "Component: Ultrasonic (HCSR04) (Audio)"

From Flowcode Help
Jump to navigationJump to search
 
(12 intermediate revisions by the same user not shown)
Line 12: Line 12:
  
  
==Ultrasonic component==
+
==Ultrasonic (HCSR04) component==
 
This  board  has  both  an  ultrasonic  transmitter  and receiver.  When the Trig pin is set high for 10uS, the transmitter sends eight 40KHz pulses.  The Echo pin goes high about 2ms later.  The duration of the Echo pin is measure when it goes high, and a distance is then calculated based on the high duration. The distance of objects in a range of around 3cm to 2.75m can be determined.  
 
This  board  has  both  an  ultrasonic  transmitter  and receiver.  When the Trig pin is set high for 10uS, the transmitter sends eight 40KHz pulses.  The Echo pin goes high about 2ms later.  The duration of the Echo pin is measure when it goes high, and a distance is then calculated based on the high duration. The distance of objects in a range of around 3cm to 2.75m can be determined.  
 +
 +
==Component Source Code==
 +
 +
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Ultrasonic_HC_SR04.fcfx FC_Comp_Source_Ultrasonic_HC_SR04.fcfx]
 +
 +
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Ultrasonic_HC_SR04.fcfx FC_Comp_Source_Ultrasonic_HC_SR04.fcfx]
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 26: Line 48:
  
 
==Examples==
 
==Examples==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 36: Line 74:
 
{{Fcfile|HC-SR04 Distance Sensor Demo.fcfx|HC-SR04 Distance Sensor Demo.fcfx}}
 
{{Fcfile|HC-SR04 Distance Sensor Demo.fcfx|HC-SR04 Distance Sensor Demo.fcfx}}
  
==Downloadable macro reference==
 
  
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
==Macro reference==
 +
 +
===GetDistance===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 49: Line 100:
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
  
  
Line 60: Line 109:
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
 
|-
 
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Type
 +
|-
 +
| colspan="2" | Select which sensor you have. HC-SR04 has a10us trig duration. AJ-SR04M has a 20us trig duration. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
Line 70: Line 124:
 
|-
 
|-
 
| colspan="2" | ADC channel used to monitor the echo 
 
| colspan="2" | ADC channel used to monitor the echo 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''
 
|-
 
 
|}
 
|}

Latest revision as of 10:26, 20 October 2023

Author Matrix TSL
Version 1.0
Category Audio


Ultrasonic (HCSR04) component

This board has both an ultrasonic transmitter and receiver. When the Trig pin is set high for 10uS, the transmitter sends eight 40KHz pulses. The Echo pin goes high about 2ms later. The duration of the Echo pin is measure when it goes high, and a distance is then calculated based on the high duration. The distance of objects in a range of around 3cm to 2.75m can be determined.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_Ultrasonic_HC_SR04.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_Ultrasonic_HC_SR04.fcfx

Detailed description

No detailed description exists yet for this component

Examples

FC6 Icon.png HC-SR04 Distance Sensor Demo.fcfx







Macro reference

GetDistance

Fc9-comp-macro.png GetDistance
Sends a pulse and processes the echo. Returns a object distance in cm 
Fc9-u16-icon.png - UINT Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Type
Select which sensor you have. HC-SR04 has a10us trig duration. AJ-SR04M has a 20us trig duration. 
Fc9-type-5-icon.png OutputTrig Pin
Pin used for controlling the output pulse 
Fc9-type-5-icon.png Input Echo Pin
ADC channel used to monitor the echo