Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Product Manual Ultrasonic Sensor Version1.0 Phi Robotics Research Pvt. Ltd. www.phi-robotics.com Table of Contents 1 Introduction ................................................................................................................................................... 2 2 Board Features ............................................................................................................................................... 2 3 Specifications ................................................................................................................................................. 2 4 Hardware Connections ................................................................................................................................... 3 5 Pseudo Code ................................................................................................................................................... 4 5.1 Getting Distance Value.......................................................................................................................... 4 1 Introduction Ultrasonic sensor module is used for measuring the distance between the sensor and an obstacle. The sensor works on the principle similar to radar or sonar. The sensor produces the high frequency sound and evaluates the echo received by the sensor. Sensor then calculates the time interval between sending the signal and receiving the echo to determine the distance between the objects. The Ultrasonic sensor provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm. The sensor includes ultrasonic transmitter, receiver and a control circuit. The working principle of the module is as follows- set the trigger pin high for at least 10 µs, then module automatically sends eight pulses of 40 KHz and detects whether the pulses are echoed or not. The echo pin goes high and remains high till the echo is received (38ms Max). Calculations are as follow: Test Distance = (High level time X Velocity of the sound (340M/S))/2. High level Time = Timer count * Time period 2 3 Board Features Small and compact size Standard operating frequency and good sensitivity Ideal for use in range measurements, robot applications Specifications Input operating voltage: 5V Working current: 15mA Range: 2cm to 400cm Resolution: 0.3 cm Measuring angle: 30 degree Trigger Input pulse width: 10 µs 4 Hardware Connections Figure 1 - Ultrasonic sensor pin layout The module has 4 pin header for interfacing. Figure 1 above shows the pin layout. Apart from 2 power supply pins, Ultrasonic Sensor has a trigger and an echo pin for distance measurement. When a pulse of 10 µs is provided to trigger pin, sensor transmits ultrasonic wave. Default state for echo pin is logic 1. Echo pin goes low after 550-570 µs after trigger pulse is issued, and again goes high when the sensor receives reflected ultrasonic wave. The distance between the sensor and the obstacle can be calculated by measuring the time period for which the echo pin stays low. Following is the equation to calculate distance in cm from measured pulse low time. 𝐷𝑖𝑠𝑡𝑎𝑛𝑐𝑒 (𝑐𝑚) = 𝑝𝑢𝑙𝑠𝑒 𝑙𝑜𝑤 𝑡𝑖𝑚𝑒 (µ𝑠) 58 5 Pseudo Code 5.1 Getting Distance Value int32_t ultrasonicGetDistance(void) { int32_t distance, timerCount, time_us; // issue trigger pulse gpioSet(TRIGGER); delay_us(10); // trigger pulse width should be min 10 us gpioCLear(TRIGGER); // wait till echo pin goes high while(!(gpioReadPin(ECHO))); // start timer timerStart(); // wait till echo pin goes low while(gpioReadPin(ECHO)); // stop timer timerStop(); // read timer count timerCount = timerGetCount(); // convert timer count to time in micro seconds, // according to timer settings time_us = timerCount * TIMER_SCALING_FACTOR; // calculate distance in centimetres distance_cm = time_us / 58; return distance_cm; } Phi Robotics Research Pvt. Ltd. www.phi-robotics.com