[time-nuts] Building a mains frequency monitor
Charles Steinmetz
csteinmetz at yandex.com
Tue Apr 12 02:00:36 EDT 2016
Nick wrote:
>The instructable I wrote about it is at [link]
>
>There's code for the Arduino and the
>Linux side as well as schematics.
Several things to note about that front end circuit, from a time-nut
perspective (the circuit was apparently created as a science project,
and it may be fine for that):
1) The LM358 makes a very poor comparator, even for a 60Hz ZCD, with
rise and fall times of tens of microseconds. Also, its output
doesn't pull closer than about 1.5v to the positive supply.
2) With the non-inverting input biased to +2.5v, the switching
threshold is over 3 volts positive from the zero cross of the AC
mains voltage, which guarantees that mains voltage variations will
create timing offsets. Ideally, the non-inverting input would be
biased one diode drop below ground so the actual switching threshold
would be near 0v. However, that is not within the input voltage
range of the 358 running on a single supply, so ground would be the
closest workable choice (the 358 is a "single supply" op-amp, so its
input common-mode range includes the negative supply -- ground, in
this case). Just remove R2 to implement this change.
3) The unused section of the LM358 has its noninverting and
inverting inputs grounded, with the output left floating. This is
not a good way to connect an unused op-amp. Generally, one should
connect the noninverting input to a potential that is within both the
input common-mode range and the output voltage range (here, from
ground to about 3.5v), and connect the output to the inverting input
(making it a unity-gain follower).
A much better solution is to use a real comparator with the threshold
at 0v. Instead of a series diode on the input, use a series resistor
and clamp diodes as necessary to keep the comparator's noninverting
input within its allowable voltage range.
I didn't review the code, but anyone building the circuit should
check it carefully to see if there are any similar issues on the software end.
Best regards,
Charles
More information about the time-nuts
mailing list