# Could you please validate this sine to square circuit?

I need to read the velocity of a universal motor with a microcontroller. The motor is a universal brush motor 230 V AC 50 Hz velocity controlled by a Triac. The motor has a mechanically connected an AC (generator) tachometer that produces a frequency (and voltage) proportional to the motor rotation velocity. I need to read 1 kHz max of sine wave with a variable voltage from 0 to 35V ac peak-to-peak and transform it in a square wave thanks to the BC547 as a switch.

After several experimentations between a comparator circuit with an LM393 and a more "simple" switch circuit, I chose the last because I noticed that in the field of motor & C it is the most used (maybe for better stability under noise?). I simulated the circuit that I found (the original one was with a PNP BJT I don't know why) and modified it a bit, and all seems ok on the PC. I added R7 in order to shift a bit the sine signal and overcome the 0.7 Vb threshold of the BJT, so that when the input signal is <0.7 V RMS I can still read it. The BJT produce a square wave 0-5V that I send to my micro to count the frequency.

I would put this circuit over a PCB with other stuff, so I would like to know some suggestions about it and if I can proceed!

I read about a third harmonic problem with the 230 AC motor that could be induced in the tachometer (motor and tachometer are very close), and a datasheet suggests for a low pass filter. My doubt is that with a low pass filter centred to 100-150 Hz I think I would take off my signal (up to 1 kHz)! A lot of noise I think will be produced by the 230 AC sine partially due to the TRIAC.

My questions: 1. How to deal with this (supposed) 3rd harmonic problem? 2. What could be the role of R8? 3. Without the C2, can I avoid the R6? 4. The capacitor values could be ok?

Thanks a lot

Update: analogKid, whitout the BJT the total shift with V2=1V seems not 2.08 V but 1.3V about. With V2=100mV the output is 0.66V about. I would capture motor rotation starting when V2>100 mV about. Maybe I need to raise a little bit more the R7 to 150-180 kOhm to avoid a too low trigger compared with noise. I'm in trouble to calculate the impedence of the generator (V2). The tacho resistence is 70 Ohm, but when the AC signal is generated the impedence appears and I don't know the XL (inductive reactance). The Z=R+jXL also change when the frequency change!

• You mention that the voltage is proportional to the rotation. Is it? You mention being able to detect at 0 VAC. That's impossible. Please properly spec the lower limit on signal amplitude. – scorpdaddy May 10 at 15:18
• BTW - Good question, solid presentation, and reference designators ! Gold star. – AnalogKid May 10 at 15:31
• Why do you want a square wave instead of a Tach DC voltage vs RPM? Design is ok, minor improvements might be possible with specs. – Sunnyskyguy EE75 May 10 at 21:01
• Scorpdaddy, sorry I intend with 0 volt to detect if the motor (and so the tachogenerator) is still. This is equivalent to count 0 square pulse whithin a certain period of time. – daigs May 11 at 21:25
• Sunnyskyguy, counting the frequency and not the voltage, have several advantages, the first is the precision in conversion due to the fact I don't know at 3.45V (for example) how many revs the motor is doing. I should previously map the couple V - #Revs value before, etc. Better doing in frequency! Another question is that if I change the device I have more chance to avoid to change the circuit because the frequency is directly correlated to the revs as a #Revs/sec=Const*Freq where Const is the number of pole of the tacho, and rarely change from a model to another. – daigs May 11 at 21:32

R6 and C2 form a 33.8 kHz lowpass filter that reduces high frequency noise and slows the rise and fall times of the output squarewave. Because R2 is the collector load, the actual filter corner frequencies are 33.8 kHz for the trailing edge, and 3.08 kHz for the leading edge. You can see this in your sim image, where the output square wave has three steps in the rising edges and only one or two steps in the falling edges. If the uC input can take the 5 V waveform directly, I don't see any need for R6-C2.

Without the transistor installed, the R5-R7 node sits at 2.08 V. If the purpose of R7 is to remove the 0.6 V threshold of a transistor, I think you overcompensated in the other direction. Consider increasing R7 to bring the threshold down to either 0.9 V or 0.4 V, but be aware that the closer the bias point is to 0.6 V, the more susceptible the circuit is to noise causing false output signals.

With a network of only V1, V2, R3, R5, and R7, you can calculate the instantaneous V2 voltage necessary to pull the node below 0.6 V and create an output transition. This assumes the V2 output impedance is significantly lower than R3. If not, add it to R3.

Whatever the transition level is, a drawback of this circuit is its relatively low gain. There will be a small range of low input voltages where the transistor is conducting but not saturated. With a single inverting stage and a grounded emitter, there is no way to add hysteresis to clean up low and slow input voltage changes. If this turns out to be a problem, your solutions are either a second transistor stage or changing to a comparator IC.

ak

• This increases the dynamic range. tinyurl.com/yydozjzk – Sunnyskyguy EE75 May 10 at 22:23
• Sunny thank you for your schema. Two questions. Can you please explain me the role of the new two diodes (should they put the positive half wave to 1.4V?) and the two 30 pF caps? How the BJT output cap filter work whitout series resistence? (coincidentally I realized the breadboard of my original circuit and the microcontroller frequency measure routine works reliable only if I put a 22nF cap between output and ground at the BJT output!) What mean "increases the dynamic range"? p.s. Note that I need to put 5 V to input the micro, not 12V. – daigs May 11 at 22:10
• Sunny, in your profile page there is a link to an electronic tutorial series of modules. I noticed that some links are disabled on ibiblio.org/kuphaldt/socratic/model/index.html Why? – daigs May 11 at 22:15
• AnalogKid thanks for your precious analysis. I noticed that some real realization use the R2 C6 filter. Consider that the circuit is immersed in section where a triac switching produces a lot of noise when partialize the AC main sinewave to regulate the motor velocity. And also the motor with his brushes returns a lot of noise. – daigs May 11 at 22:37
• AnalogKid I'm not an expert but I'm thinking to the EMI certification in the real commercial case, where I got the circuit. I realized by a breadboard my circuit and omitting R2 it still works, but omitting C6 the routine doesn't measure the frequency in a reliable way. I don't understand why, maybe the long connections wire in the breadboard are responsible here. – daigs May 11 at 22:37

you can add hysteresis like this

simulate this circuit – Schematic created using CircuitLab

• Hysteresis could be very bad. The question indicates detection down to 0 VAC. At small signal levels the hysteresis could squelch the signal. Further, this does not answer any of the 3 questions specifically asked. – scorpdaddy May 10 at 16:21
• The hysteresis can be made arbitrarily small. At 0vac, the output will become nothing but rail-rail squared-up noise. XYproblem. – analogsystemsrf May 11 at 2:10