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.

Sine to square wave conversion

Status
Not open for further replies.

bob4bvm

Member
I know this must've been covered before but not finding it
Need to convert ~ 4Vp-p sine to 3-5Vpk square wave , low freq, maybe 5kHz max, usually under 1kHz.

This is for a two encoders application, each with Ch A & B, so four channels

Was thinking of a schmidt trigger IC or maybe comparator IC. Trying for a min. parts count ckt ... so maybe a 4093 where i can squeeze all 4 channels thru one IC pkg ?

Thanks
Bob
 
Here is a simulation how leading and trail edge shift with CMOS threshold voltage using a slide on the side.

There are differences between the reliable slow CD4xxx inverter gates with unbuffered gains of >10 and triple stage or Buffered gains of >> 1000 and the much faster 74HCxx series and 74ALCxx series for gain and bandwidth.

Ceramic supply caps are essential near the part to prevent amplifying transition noise.


But I fear we are presuming too much already.
1680624351243.png
 
Thx again guys
More info is due i guess...
My encoders are 5V optical quadrature with A, B, Z outputs. Not using Z for cycle cnt, only A&B for posn and dir. of travel.
As stated i am not using the input cap. Deleting it produced the sq wave shown on scope.
I am using an ESP32 to do the counting and output position
Not sure if the inputs are settable to 'schmitt'. I know way less than enough to be dangerous with uC's; got alot of help with this one. Being an old analog/discreet guy with a ton of that kind of chips on the bench, i tend to hardware solutions so i guess that's why i went this route.
For the Schmitt ckt above, i had some 74HC132s here so used that. seems to work fine for my appln as noted above
Also tried my old go-to LM339 CMP which worked equally well for this. would have just used the 339, but had more of the 132's to play with
Bob
 
Last edited:
Thx again guys
More info is due i guess...
My encoders are 5V optical quadrature with A, B, Z outputs. Not using Z for cycle cnt, only A&B for posn and dir. of travel.
As stated i am not using the input cap. Deleting it produced the sq wave shown on scope.
I am using an ESP32 to do the counting and output position
Not sure if the inputs are settable to 'schmitt'. I know way less than enough to be dangerous with uC's; got alot of help with this one. Being an old analog/discreet guy with a ton of that kind of chips on the bench, i tend to hardware solutions so i guess that's why i went this route.
For the Schmitt ckt above, i had some 74HC132s here so used that. seems to work fine for my appln as noted above
Also tried my old go-to LM339 CMP which worked equally well for this. would have just used the 339, but had more of the 132's to play with
Bob

No Schmitt on an ESP32 I'm afraid :(
 
The nice feature about quadrature or sin/cos decoders if done right is that even if there is a bunch of edge noise is as long as the other sensor is stable (0 or 1) no further counting is done after the 1st leading edge change. So denoising is not required as long as only 1 channel is noisy during low levels near the transition threshold. That means even two sinusoids within the acceptable input logic voltage range exceed the drift due to temp. or Vdd will still work.

Of course, increasing the amplitude increases SNR which statistically reduces the error rate.

Trivia question: If analog SNR of 10:1 gives some low error rate say 10^-8, what is the logic error rate of 5V logic with a slew rate of < 1% of the period?
 
Thx again guys
More info is due i guess...
My encoders are 5V optical quadrature with A, B, Z outputs. Not using Z for cycle cnt, only A&B for posn and dir. of travel.
As stated i am not using the input cap. Deleting it produced the sq wave shown on scope.
I am using an ESP32 to do the counting and output position
Not sure if the inputs are settable to 'schmitt'. I know way less than enough to be dangerous with uC's; got alot of help with this one. Being an old analog/discreet guy with a ton of that kind of chips on the bench, i tend to hardware solutions so i guess that's why i went this route.
For the Schmitt ckt above, i had some 74HC132s here so used that. seems to work fine for my appln as noted above
Also tried my old go-to LM339 CMP which worked equally well for this. would have just used the 339, but had more of the 132's to play with
Bob

You could effect a Schmidt on an ESP32 if you have the available pins. Basically config
one for open drain, the other as the input. Put a R divider on input, configured for very small
divide ratio, and add a high valued R from pin to open drain pin. Then using an ISR change the
open drain output from on to off, or vice versa, to alter the trip level of the input. A bit toady
but possible. Will that handle speed needed, not sure.

A sim :

1681058200724.png



Switch is the open drain MOSFET pin. Inversion is ISR code generated inversion
from input pin.

Never tried it, would be easy to check suitability.


Regards, Dana.
 
I know this must've been covered before but not finding it
Need to convert ~ 4Vp-p sine to 3-5Vpk square wave , low freq, maybe 5kHz max, usually under 1kHz.

This is for a two encoders application, each with Ch A & B, so four channels

Was thinking of a schmidt trigger IC or maybe comparator IC. Trying for a min. parts count ckt ... so maybe a 4093 where i can squeeze all 4 channels thru one IC pkg ?

Thanks
Bob
You forgot to quote Vmin, DC offset, fmin (0?), SNR ( if in noisy env.) and Z(ohms), single-ended or differential.
Or use some link to define sensor specs.
 
You forgot to quote Vmin, DC offset, fmin (0?), SNR ( if in noisy env.) and Z(ohms), single-ended or differential.
Or use some link to define sensor specs.
This is up and running. I used the Schmitt ckt above, i had some 74HC132s here so used that. seems to work fine for my appln as noted above.
Later i discovered that my particular encoders read fine into the ESP32 if i simply used a pull-down resistor on each encoder channel. So that is the simplest solution for me.
Thanks to all for the good suggestions !
Bob
 
Those two schematics shown above (posts #4 and #6) are not reliable.

The first (#4) is a high-gain amplifier, that will amplify any noise on the input if used with non-schmitt-trigger inverter, and will oscillate if used with schmitt-trigger inverter (when the input signal frequency becomes low). The second (#6) will oscillate when input frequency is low.

If this is for displaying the encoder count, as mentioned in the link in #10, then the best solution would be to use a microcontroller. The shifted quadrature signal could be read directly by four ADC channels.
You are wrong about post #4. That is not a high gain amplifier. It is an inverter with properties that may be specified but not shown on the schematic. It is one of the special devices in LTspice. You would know this if you were familiar with that piece of software. There was never a claim for this circuit that it was realizable in practice.

As for the operation at low frequency, a lower limit was never mentioned as a requirement in the original post by the TS. The TS might want to amend his query if there is such a requirement.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top