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:
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?
Will the 9 V supplied to the receiver circuit cause any harm to the arduino?
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?
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.
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.
I connected the output of receiving circuit to arduino pin A0.
I am giving 5 V to the receiving circuit through arduino pin 6.
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);
}
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?
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.