Component: Ultrasonic Ranger (101020010) (Grove)
Author | Matrix Ltd |
Version | 1.0 (Release) |
Category | Grove |
Contents
Ultrasonic Ranger (101020010) component
The ultrasonic sensor is a non-contact distance measurement module. It's designed for easy modular project usage with industrial performance. Detecting range: 3cm to 4m, best in 30 degree angle.
The ultrasonic ranger works at 40kHz. It issues 8 cycles of the 40kHz level and detects the echo, the pulse width of which is proportional to the measured distance. The distance can be measured in mm, cm or inches using the ‘MeasureDistance’ macro in flowcode 8, after you have used the ‘SampleSensor’ macro to send out a signal and receive it. You can then use a screen display such as the LCD (BL0169) to output the recording you get for the measured distance.
Examples
This example performs an ultrasonic range sample and then converts the sample from a timing into a measurement in millimetres.
Downloadable macro reference
WaitForEcho
Waits until the echo has been received from the Ping macro allowing you to perform your own timing.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
MeasureDistance
Converts a micro second time from the ultrasonic range sensor and returns the range in mm, cm or inches.
Parameters
- UINT TimeDelay
- Microsecond reading from Ultrasound module
- BYTE Scale
- 0=MM / 1=CM / 2=Inch
Return value
Ping
Performs a transmit ping allowing you to monitor the incoming signal and perform your own timings maybe using a rising edge interrupt and a timer.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
SampleSensor
Sends out an ultrasonic ping and times how long it takes to receive the echo.
Returns the time in microseconds.
Performs the timing using software so depending on the speed of the micro will be an approximation. For better results use the Ping macro.
Parameters
- This macro has no parameters
Return value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Control Pin
This property is of type Single digital pin and can be referenced with the variable name ControlPin.
Pin connected to the emitter of the sensor.
Discrete Distance
This property is of type Floating point and can be referenced with the variable name DiscreteDistance.
Simulation range used to determine if the sense pin is active or not.