Distance Measurement with Ultrasonic Transceiver

Hello, I am working on a project of finding distance using ultrasonic transceiver. I am going to use arduino UNO as a microcontroller. So for this project, I will be sending a burst of 8 square waves at 40 kHz and then ill be waiting for the receiver circuit to pick up the echo. I have designed the receiver circuit, whose link I have given below. So i have two specific doubts and i will be very thankful if you can spare some time and answer them:

  1. The transducer has two pins - one for I/O and the other as GND. So is it okay to give the burst by one arduino analog pin to the transducer's I/O pin and then receive the signal by other arduino pin from the receiver circuit? As in, one wire will be from one arduino pin to the transducer and then connected to this pin will be the the receiver circuit and then to another arduino pin. Is there any flaw in this method?

  2. Will the 9 V supplied to the receiver circuit cause any harm to the arduino?

  3. Is it necessary for the GND of the receiver circuit to be connected to a GND on arduino? As in, is it necessary for all the grounds present in the circuit to be common?

  4. Any other overall suggestions regarding the project?

I will be extremely thankful if someone spares some time and answers these. It will really be heplful.

Thank you.

Links:

  1. Receiver circuit : Ultrasonic receiver circuit using Opamp LM324 - Gadgetronicx
  2. Datasheet of sensor that I am using : (attatched)

MCUSD14A40S09Rs-30C datasheett.pdf (658 KB)

  1. You need a 220 Ohm current limiting resistor between the digital output and the transducer, or you may destroy the output pin.

  2. Yes, input voltage > 5.5V can damage or destroy the Arduino. Power the receiver with 5V instead.

  3. All grounds MUST be connected.

  4. The very inexpensive HC-SR04 ultrasonic distance modules are convenient and work well

okay so I did as follows:

  1. I connected the I/O pin of the sensor to the trigger pin (pin 3) of arduino from which i am giving a burst, also this pin is connected to the ground of receiving circuit.
  2. I connected the output of receiving circuit to arduino pin A0.
  3. I am giving 5 V to the receiving circuit through arduino pin 6.
  4. The ground is common.

The arduino code is as follows:

int trig_pin = 3;
int echo_pin = A0;
int power_pin = 6;

unsigned long duration;
unsigned long distance;
int i;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(trig_pin, OUTPUT);
pinMode(echo_pin, INPUT);
pinMode(power_pin, OUTPUT);
}

void loop() {
for(i=0; i<=7; i++){
digitalWrite(trig_pin, LOW);
delayMicroseconds(12.5);
digitalWrite(trig_pin, HIGH);
delayMicroseconds(12.5);
}

digitalWrite(trig_pin, LOW);
//Power ON the receiver circuit
digitalWrite(power_pin, HIGH);
//delayMicroseconds(5);

//Measures the response from the echo_pin
duration = pulseIn(echo_pin, HIGH);

//Calculating the distance
distance = duration*0.000343/2;

Serial.print(duration);
Serial.print(" Distance = ");
Serial.println(distance);

digitalWrite(power_pin, LOW);
delay(500);

}

Please can you go through it and see what is wrong as on the serial monitor i am getting just on value irrespective of the distance from the sensor. Is it because there is some problem with pulseIn received from analog pin? Or is it because i powered the receiving circuit with 5 V instead of 9 V?

Please help. Any help is appreciated.

Thanks

First you need to determine if the receiver works at all. You may need an oscilloscope to see the output signal.

You need a couple of milliseconds delay after transmitting the pulse, so the transmit transducer stops ringing, before activating the receiver.

Pratyay_16:
The transducer has two pins - one for I/O and the other as GND. So is it okay to give the burst by one arduino analog pin to the transducer's I/O pin and then receive the signal by other arduino pin from the receiver circuit? As in, one wire will be from one arduino pin to the transducer and then connected to this pin will be the the receiver circuit and then to another arduino pin. Is there any flaw in this method?

This is not clear. It sounds like one transducer pin is grounded and the other pin is connected to two wires: one wire goes to the arduino's output pin ("trig_pin"), and the other wire goes to the receive circuit input.

If that's really how it is, then it won't work, because the last digitalWrite(trig_pin, LOW) before turning on the receiver shorts the transducer pin to ground (at which point both transducer pins are grounded), so the receive input is also grounded and the receive circuit can't get a signal from the transducer.

You can get around that problem by pinMode(trig_pin, INPUT) prior to turning on the receiver (which puts the trig_pin in a high impedance state, in which it shouldn't affect the transducer output), and then pinMode(trig_pin, OUTPUT) prior to the next burst.

Post a complete wiring diagram. Are you trying to use the same sensor for transmit and receive?

delayMicroseconds(12.5);?