Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What am I missing (LM393 as comparator)

Status
Not open for further replies.

lilimike

Member
Hi,
I am trying to figure out what I am doing wrong. I built an Ultrasonic distance meter based on the circuit from page 3 on THIS LINK, I got the Tx part to generate a 40KHz burst and with the Rx listening I get what I think should be the propper readings on the scope (CH1 is on U2 pin 2 and CH2 is on U2 pin 3) I get as expected
CH1_P2-CH2_P3..jpg
The part I start not understanding is when I read PIN1 of U2 which should give me a reading of 5 or 0 volts but I get this reading which is average -180 mV
U2_PIN1..jpg
Now this is without any capacitor, if I add a 1nF cap as suggested I simply get an average of -16mv.
Any help would be appreciated.

Mike
 
Last edited:
Hi,
I am trying to figure out what I am doing wrong. I built an Ultrasonic distance meter based on the circuit from page 3 on THIS LINK, I got the Tx part to generate a 40KHz burst and with the Rx listening I get what I think should be the propper readings on the scope (CH1 is on U2 pin 2 and CH2 is on U2 pin 3) I get as expected
View attachment 40189
The part I start not understanding is when I read PIN1 of U2 which should give me a reading of 5 or 0 volts but I get this reading which is average -180 mV
View attachment 40188
Now this is without any capacitor, if I add a 1nF cap as suggested I simply get an average of -16mv.
Any help would be appreciated.

Mike

hi Mike,
The LM393 requires a pull up resistor on its output, say a 4k7

The LM393 is an open collector output.
 
Thank you Eric,

Now I am getting better results on pin U2 pin 1.

I am using this circuit to learn how to read distance using ultrasonic. Do you think it is possible to improve this circuit to gain a better range?
I can raise the voltage to 9 Volts (in which case I would probably have to reduce the output to 5V, would adding one or two more amplification stages help?

Thanks for your help,

Mike
 
Thank you Eric,

Now I am getting better results on pin U2 pin 1.

I am using this circuit to learn how to read distance using ultrasonic. Do you think it is possible to improve this circuit to gain a better range?
I can raise the voltage to 9 Volts (in which case I would probably have to reduce the output to 5V, would adding one or two more amplification stages help?

Thanks for your help,

Mike

hi Mike,
The gain is already 1000, increasing the 5V to 9V will not help the receiver.

You could try driving the txr transducer harder, by using an external amplifier driven by RB4/5
 
I am not sure about how to go on amplifying the TX from the 5V output coming out of the PIC, does this mean in this case I would have to raise the voltage to 9V or more?
I am trying to reach a max of 10 meters. Is this a solution?
TX_4069..jpg

Mike
 
I am not sure about how to go on amplifying the TX from the 5V output coming out of the PIC, does this mean in this case I would have to raise the voltage to 9V or more?
I am trying to reach a max of 10 meters. Is this a solution?
View attachment 40197

Mike

hi,
That circuit should increase the TX drive.
I think 10 mtrs would not be possible for reliable operation with this set up.

Which type of TX and RX transducer do you have, some types have a narrow beam angle in order to increase the range.
 
I am not sure about how to go on amplifying the TX from the 5V output coming out of the PIC, does this mean in this case I would have to raise the voltage to 9V or more?
I am trying to reach a max of 10 meters. Is this a solution?
View attachment 40197

Mike
Why use the CD4069? The PIC outputs will have a lower output impedance.
 
I am far from beeing an expert, I just figured it would raise the voltage if raising the voltage will increase the range. Also it would save an I/O pin on the PIC, not that I ran out of I/O though.
 
hi Mike,
The gain is already 1000.
No, Eric.
The old fashioned poor high frequency response of the lousy LM358 dual opamp limits the max gain to only About 11 at 40kHz when the supply voltage is low.
Also, the first opamp is inverting so the impedance of the transducer is in series with the input and makes the gain less than 10.
The gain of the second opamp is about 11. The total gain is only 80 if you are lucky.

If better opamps are used and the first opamp is non-inverting then the gain will be 1000.
 

Attachments

  • LM358 at 40kHz..PNG
    LM358 at 40kHz..PNG
    20.2 KB · Views: 332
Should I use LM833 instead of LM358 with 2 non-inverting stages?
Any other suggestion for the op-amp I should use?
 
Should I use LM833 instead of LM358 with 2 non-inverting stages?
Any other suggestion for the op-amp I should use?
The LM833 needs a minimum supply of 10V, not the 5V for the micro-controller.
An OPA2134 has low noise, a wide bandwidth and a minimum supply of 5V.
 
No, Eric.
The old fashioned poor high frequency response of the lousy LM358 dual opamp limits the max gain to only About 11 at 40kHz when the supply voltage is low.
Also, the first opamp is inverting so the impedance of the transducer is in series with the input and makes the gain less than 10.
The gain of the second opamp is about 11. The total gain is only 80 if you are lucky.

If better opamps are used and the first opamp is non-inverting then the gain will be 1000.

hi agu,
Thanks, Ididn't check it, I just read the text from the OP's link.
 
The LM833 needs a minimum supply of 10V, not the 5V for the micro-controller.
An OPA2134 has low noise, a wide bandwidth and a minimum supply of 5V.
As a second choice would you say TL072 is still way better than LM833 or LM358?
I am just comparing the price in CAD: OPA2124 = $2.76 / TL072 = $0.26

It's a biiiig difference!

Mike
 
The LM358 is old garbage with very poor spec's.
The TL072 and LM833 are very good and are almost the same. The minimum supply for the TL072 is 7V.
The OPA2134 has extremely good spec's.
 
OK so I think I will work my way up and I will start with TL072. I am not really conserned about the voltage beeing higher than what the MCU can take since I just want to amplify the signal picked up from the transducer and I am only looking at 40KHz +/- a few Hz and the end result will trigger a comparator where I can then control the voltage to top 5V.

This beeing said, part of this thread kind of got lost in the conversation (not complaining here I find every response interesting), now I think I can go quite a long way with the receiving part but how to I improve the transmitter when it is already sending 40KHz bursts of 5 Volts? I had sugested to use a 4069 (post #5)

Eric responded with:
That circuit should increase the TX drive.
Herro999 responded with:
Why use the CD4069? The PIC outputs will have a lower output impedance.

So if I could get maybe either a third opinion or even a "Why" "by how much" or "why not" to the previous responses I think I would be good to go and start ordering more parts and spend a few nights up and testing.

Again I am trying to reach a range of .10 to 10 meters although .15 to 9 m will be aceptable.

Mike
 
how to I improve the transmitter when it is already sending 40KHz bursts of 5 Volts? I had sugested to use a 4069 (post #5)
I can't remember what is driving the Tx transducer now. A CD4069 even paralleled has a very low output voltage and current. I used complementary emitter-follower transistors to drive a piezo beeper in a bridge and it was very loud. The transistors can be driven from a CD4069.

Using half-decent opamps in the receiver will increase the range a lot.
 
Right now the TX is connected directly to 2 pins of the MCU which is producing the 40KHz with each pin inverted from the other (push-pull)
I guess I will take it step by step so I will start with the receiver and then I will try complementary emitter-follower transistors and see the difference.

Mike
 
The MCU has outputs of up to 25mA with a low voltage drop. Complementary transistors will cause a voltage drop of about 2.8V p-p when bridged.
Using a modern opamp in the receiver will make a huge difference in range.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top