Ultrasonic Range Finder Using SDM-IO


Ultrasonic module is shaped generally small size of the electronic board with multiple electronic circuits and 2 transducer. 2 pieces of this transducer, one serves as a transmitter and another as a receiver. There are also modules that only have 1 piece transducer, transmitter and receiver function as well. Available pin VCC, Trig, ECHO and GND. There are also modules TRIG pin and ECHO was merged into one and use the other.


Ultrasonic module works by generating sound waves at high frequencies, which are then emitted by the transmitter. The reflection of sound waves in front of the object will be captured by the receiver. By knowing the length of time between the sound waves radiated until arrested again, we can calculate the distance of objects in front of the module. We know the speed of sound is 340m/detik. The length of the sound wave travel time multiplied by the speed of sound, then divided by 2 will yield the distance between the ultrasonic module with objects in front of him.



SDM-IO



SDM-IO is the ultrasonic module the same as HC-SR04. Unlike in the distance range distance measurement, in which SDM-IO has a shorter distance range. How to use about the same as HC-SR04, but the signal level is inverted. If HC-SR04 HIGH signals with a duration of 10 microseconds, the SDM-IO uses a LOW signal with a duration of 10 microseconds.


SDM-IO has a 4 pin, as are like HC-SR04, VCC, Trig, ECHO and GND. Connect the pin-pin is the same as in the HC-SR04. VCC is connected to the 5V from the Arduino and the Arduino GND to GND. Trig is connected to digital pin 12 and ECHO 13 is connected to digital pin.


SDM-IO connected with Arduino UNO
SDM-IO connected with Arduino UNO
Connect your Arduino board to the computer using a USB cable and upload the program below.



#define SDM_IO_TIMEOUT 1000 int TrigPin = 12; int EchoPin = 13; unsigned long ultrasoundDuration; int timeout; unsigned long tStartPing = 0; int sensorValue = 0; void setup() {   Serial.begin(9600);   pinMode(TrigPin, OUTPUT); //pin is output   pinMode(EchoPin, INPUT); // pin is now input } void loop() {   sensorValue = read_sdm_io_range();   Serial.print(sensorValue);   Serial.println(" cm");   delay(100); } //SDM-IO Ultrasonic Range Sensor distance function float read_sdm_io_range() {   unsigned char pin = 0;   unsigned int time_flag = 0;   digitalWrite(TrigPin, HIGH);   delayMicroseconds(2);   digitalWrite(TrigPin, LOW);   delayMicroseconds(10);   digitalWrite(TrigPin, HIGH);   tStartPing = micros();   timeout = 0;   pin = digitalRead(EchoPin);   while(pin)   {     pin = digitalRead(EchoPin);     time_flag++;     if(time_flag > SDM_IO_TIMEOUT)       {         timeout = 1;         break;       }   }   ultrasoundDuration = micros() - tStartPing;   Serial.print(ultrasoundDuration);   Serial.print(" us, ");   Serial.print(ultrasoundDuration*0.017, DEC); // result in cm   Serial.print(" cm");   Serial.println();   if (timeout)     return 999;   else     return ultrasoundDuration * 0.017; // result in cm }
If there are no error messages then the ultrasonic module will work directly measure the object distance in front of him. Use the Serial Monitor ( Ctrl + Shift + M ) on the Arduino software to see the measurement results.


How, pretty easy right? Please experiment with Ultrasonis Range Sensor Module on your Arduino projects.