I have a variable AC voltage coming from the motor of a scooter, appropriately rectified with a bridge rectifier and large capacity capacitor.

The circuit I want to create will be powered by 12v DC, with which I created a threshold voltage of 7v with a divider.

With the LM393 I want to compare these two voltages: output high when the AC voltage exceeds the threshold voltage. I use the output of the LM393 to drive a relay. Being open collector, I can make the relay switch by placing it directly between output and +Vcc (with a protection diode).

The problem is that the comparator doesn't work with the rectified voltage coming from the motor. It would probably need a more careful adjustment... Without It, the ripple being too high. How could I solve it?

I tried with an LM358 but it doesn't work anyway. How can I compare this very unstable voltage? Schematics

  • \$\begingroup\$ Clarification: The voltage will be more stable as the engine rpm increases. But I want it to work at all speeds, especially at idle (around 1500rpm) \$\endgroup\$
    – Anasten
    Mar 1 at 1:01
  • 1
    \$\begingroup\$ The task is pretty straightforward. However, without a schematic of your circuit there is no way to diagnose it. And - what is the peak value of the voltage waveform being sensed? \$\endgroup\$
    – AnalogKid
    Mar 1 at 1:01
  • \$\begingroup\$ the comparator doesn't work with the rectified voltage How does it not work? I can almost assure you that the comparator works just fine but your expectation of what it should do (vs. what it is actually doing) is off for some reason. Schematics please! \$\endgroup\$ Mar 1 at 1:13
  • \$\begingroup\$ I want to compare these two voltages You want to compare the instantaneous rectified value of AC, or the average value, and if the average then what is the averaging period you need? \$\endgroup\$ Mar 1 at 1:15
  • \$\begingroup\$ Are you sure you can operate a relay coil with the LM393 output? The datasheet says that maximum output collector current is 20mA, which is insufficient for all but the most "special" relays. \$\endgroup\$ Mar 1 at 3:15

2 Answers 2


You're also going to have a problem that when the relay pulls in the voltage will drop a little due to the loading effect. Unless you add some hysteresis to the comparator the circuit will turn into a relay oscillator.

I would be inclined to make a separate rectifier for the comparator circuit - maybe a single diode, capacitor and discharge resistor - so that you can optimise the C value for the comparator and optimise a different C value for the load.

Having said all that, you might be better monitoring the frequency of the rectified, unsmoothed voltage, convert that to a voltage and then feed that to a comparator. The LM2907 might be suitable.


simulate this circuit – Schematic created using CircuitLab

Figure 1. A sketchy layout to get you started.

What does what:

  • V1 and BR1 behave as before.
  • U2 provides a regulated 5 V supply for the F-to-V converter and the comparator setpoint (R2). I've shown a 7805 but they need about 7 V in to get 5 V out. This may result in incorrect switching at low voltage (at low RPM). You'll need to experiment.
  • D2 / R4 provide a half-wave pulse signal to the LM2907 for its frequency input.
  • I didn't read the datasheet but there will be a voltage limit on the input so D3 shunts any excess voltage off to the 5 V rail and R5 limits the current.
  • The LM2907 is just shown as a block. I haven't used one for about 30 years and didn't re-read the datasheet. C3 represents the timing capacitor. There are probably a few additional components required.
  • R2 determines the switching point on the comparator. It will be adjustable between 0 and 5 V.
  • Most comparators have open-collector outputs. That means they can only pull the output low.
  • Q1 is turned on by base current via R1. The comparator pulling low will turn Q1 off.
  • D4 is a snubbing relay to protect Q1 from high inductive kickback voltages when RLY1 is switched off.
  • I have not shown decoupling capacitors which are required on U1, U2 and CMP1. Follow the datasheet recommendations but usually 100 nF is right. Don't be tempted to omit them.

Have fun.

  • \$\begingroup\$ I can use a small transistor to drive the relay if it starts doing strange things. Thank you for the tip! As for the LM2907, it's great! I wasn't aware of these ICs and it's probably just what I need! Thank you very very much! I agree about separating the two rectification circuits. So, if I understand correctly, using an LM2907, would I be able to solve all the problems listed above? \$\endgroup\$
    – Anasten
    Mar 1 at 15:11
  • \$\begingroup\$ Have a look at the update. \$\endgroup\$
    – Transistor
    Mar 1 at 16:19
  • \$\begingroup\$ Ok, that's perfect! Thank you! I forgot to mention that the famous 12v on the power supply comes from a lithium battery (UPS circuit) which I will always have present. In fact, I will need the DC-DC to charge it with the motor voltage, but only at High rpm. The peak voltage Is about 20v at max rpm of the motor. Therefore LM7805 Is useless. \$\endgroup\$
    – Anasten
    Mar 1 at 18:13

You'd want a peak-value circuit designed to deal with variable frequency AC, i.e. a circuit that doesn't have fixed time constants but adapts to the frequency of AC.

The way to do it is to use two peak detectors. At any given time, either peak detector is active, while the other is reset at the zero transition, and then accumulates a new AC peak value.


simulate this circuit – Schematic created using CircuitLab

The elements inside of the blocks above are not actual implementations but functional approximations. The actual circuit will have the same functionals block, but implemented quite differently - often simpler or leveraging functions available in cheap analog and digital ICs. Stay tuned :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.