TR switching and receiving echo signals

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi eric , its over :D
I made experiments and my measurements are very close.
But somehow , I had to go for some weird changes in the number of my delay counter.
It changes if I take the variable from long to float or like I delay it for 10us but It does not work when I count as 10us but It works if I count as 16us and wait for 10us at every loop.
I share my code.
I also wonder that , for example JSN-SR04T says it can measure from 25cms to 6.5 meters. Mine start from like 55cms. May using dampening path would work but also I guess the piezo piece has affects on it. Im happy since I accomplished the project but I also wonder these.
 

Attachments

Last edited:

ericgibbs

Joined Jan 29, 2010
21,445
Hi demir,
Using your Sketch in a Uno, being driven with a simulated Echo, at 250uSec, generated by a Nano Sketch, this is the distance result shown in the IDE.
A very close comparison between your distance.
E
EG57_ 2063.png
 

ericgibbs

Joined Jan 29, 2010
21,445
is 0.085 mtr not 8.5 cm?
Hi,
I will recheck my calculations, thanks for the heads up. @bertus

Update:
I have found my mistake, I misread the wrong delay in my RX Nano test sketch, when using my calculator.
:rolleyes:
void loop() {
if (digitalRead(2) == HIGH){ // detect TX pulse from main Uno
delay(5); echo time delay
digitalWrite(3,1);
delayMicroseconds(250); RX pulse Out to main Uno
digitalWrite(3,0);
}

I should have used the delay(5) // which when divided by 2 for the return distance gives 2.5mSec
So 340*0.0025sec =85cm



E
 
Last edited:

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi everyone , I hope you doing good and everything is ok for you.
Tomorrow I go back to the school so I wanted to record a video about this project.
That includes brief info and some measurement.
Out the video , I could have measured distance using small objectile - laptop - at 1.8meters precise. From piezo to wall I could measured 2.4meters. I could not try larger distances in both situations due to experiment environment.
I be happy If you feel free to comment and more.
Have a good day !
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi,
I will recheck my calculations, thanks for the heads up. @bertus

Update:
I have found my mistake, I misread the wrong delay in my RX Nano test sketch, when using my calculator.
:rolleyes:
void loop() {
if (digitalRead(2) == HIGH){ // detect TX pulse from main Uno
delay(5); echo time delay
digitalWrite(3,1);
delayMicroseconds(250); RX pulse Out to main Uno
digitalWrite(3,0);
}

I should have used the delay(5) // which when divided by 2 for the return distance gives 2.5mSec
So 340*0.0025sec =85cm



E
Hi eric , I hope you doing good. Things are going very well for me.
I am keeping developing the project.
I have a important question for you , I think you may help me since you are very experienced over this topic.
1726698069819.pngThis V pointed in the picture is varying. It was working fine , but It not does not work well at all.
Could you give me some hints and the important points about catching echoes.
I also get smaller output than I expected from sim. In sim , I set the echo V around 5mV which a realistic value , but in real circuit my output is smaller.
Is that maybe because of amplifiers limit ?
 

Attachments

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi eric , I hope you doing good. Things are going very well for me.
I am keeping developing the project.
I have a important question for you , I think you may help me since you are very experienced over this topic.
View attachment 331975This V pointed in the picture is varying. It was working fine , but It not does not work well at all.
Could you give me some hints and the important points about catching echoes.
I also get smaller output than I expected from sim. In sim , I set the echo V around 5mV which a realistic value , but in real circuit my output is smaller.
Is that maybe because of amplifiers limit ?
https://www.alldatasheet.com/datasheet-pdf/view/175241/ONSEMI/NE5532.html
I guess the gain I try to have is upper than It can produce as the graphics say
 

ericgibbs

Joined Jan 29, 2010
21,445
hi demir,
At which point on the circuit did you measure that signal shown in the image in post #230?
The RX pulse input to the MCU pin should be clamped at 5Vmax and ideally 0V

The normal practice is to use a Comparator in order to give a 0V/+5V pulse output for the MCU.
Remember, an MCU I/O pin input requires a voltage level well below or above MCU pin threshold voltage, in order to register as a logic High or Low.

Also, please check the TXPulse width, it appears to be much longer than 250uSc.

If the angle between the piezo and the reflecting surface [ the wall ] is changed, the RX signal strength will change.
As the pulse is ultrasonic sound, it can also be slightly affected by air movement currents.

E
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
hi demir,
At which point on the circuit did you measure that signal shown in the image in post #230?
The RX pulse input to the MCU pin should be clamped at 5Vmax and ideally 0V

The normal practice is to use a Comparator in order to give a 0V/+5V pulse output for the MCU.
Remember, an MCU I/O pin input requires a voltage level well below or above MCU pin threshold voltage, in order to register as a logic High or Low.

Also, please check the TXPulse width, it appears to be much longer than 250uSc.

If the angle between the piezo and the reflecting surface [ the wall ] is changed, the RX signal strength will change.
As the pulse is ultrasonic sound, it can also be slightly affected by air movement currents.

E
Hi eric , tx is only 250us. The inertia moment causes this unfortunutely. The point I get you the picture is the output of amplifier before the comparator.
I names that node as output
 

Attachments

Thread Starter

demir-ali

Joined Jul 13, 2024
321
hi demir,
At which point on the circuit did you measure that signal shown in the image in post #230?
The RX pulse input to the MCU pin should be clamped at 5Vmax and ideally 0V

The normal practice is to use a Comparator in order to give a 0V/+5V pulse output for the MCU.
Remember, an MCU I/O pin input requires a voltage level well below or above MCU pin threshold voltage, in order to register as a logic High or Low.

Also, please check the TXPulse width, it appears to be much longer than 250uSc.

If the angle between the piezo and the reflecting surface [ the wall ] is changed, the RX signal strength will change.
As the pulse is ultrasonic sound, it can also be slightly affected by air movement currents.

E
I do not have any problem to convert that peak to digital btw. What would you suggest me for the issue of varying echo magnitude ? I already have the varying Vref you know.
May I use another opamp or bjt to increase the gain ?
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi d,
Which type of OPA's do you have available?
E
Please post your comparator circuit.
I use rail to rail ne5532 , drive it by setting a 6v node as gnd to bias the signal.
At comparator side , I have no problems.
I tested that with and without comparator connected , it is seperated
1726736077818.png
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi,
I will recheck my calculations, thanks for the heads up. @bertus

Update:
I have found my mistake, I misread the wrong delay in my RX Nano test sketch, when using my calculator.
:rolleyes:
void loop() {
if (digitalRead(2) == HIGH){ // detect TX pulse from main Uno
delay(5); echo time delay
digitalWrite(3,1);
delayMicroseconds(250); RX pulse Out to main Uno
digitalWrite(3,0);
}

I should have used the delay(5) // which when divided by 2 for the return distance gives 2.5mSec
So 340*0.0025sec =85cm



E
Hi Eric , I hope you doing all good. I've got alot of way up to here. Now I have some current problems about piezo.
When the surface has some tilt , or the material differs , you know the echo magnitute changes. It does not detect people.
I also could measured distances down to 25cm and up to 2meters using 2 gain stages plus TSC.
If I decrease the piece of pulse count at transmit , then I can go even lower down to 20cms but then I pay the tradeoff with loss of longer distances.
What would you suggest me ?
Can I have some tips and tricks ?
I also have a interesting problem with the opamp I use LF347. I will share it when I go back to lab.
 

ericgibbs

Joined Jan 29, 2010
21,445
Hi demir,
Do you have a datasheet for the Piezo that you are using on the project, you could post?
Check the allowed maximum drive voltage.
E
What is the problem with the LF347?
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi demir,
Do you have a datasheet for the Piezo that you are using on the project, you could post?
Check the allowed maximum drive voltage.
E
What is the problem with the LF347?
The maximum drive voltage was 20Vpp as I remember , I drive at 10Vpp. I need to picture the problem from oscilloscope , because the same circuit works fine at ltspice.
The other problem I have is I know very normal. The surface affects the echo magnitude. But when that echo is smaller than expected , It does not reach the Vref of TSC.
 

ericgibbs

Joined Jan 29, 2010
21,445
Hi demir,
I would suggest you try to measure echo signal strengths of the returned Echo at different angles to the plane of the Piezo.
As you may know, the ultrasonic beam is Cone shaped, so the echo strength falls as you move the 'target' away from the beam centre.
Being off the centre of the beam also slightly changes the measured distance.

The other problem is the shape/ and angle of the echo surface material effects the echo strength.

Do you know how to construct a simple test surface to check the echo distance/strength?

E.
 
Top