[ELECTRON] Arduino project help.

Andrew Back andy at smokebelch.org
Tue Jan 25 22:10:35 UTC 2011


Hello,

So, I'm hoping that a seasoned Arduino expert might be able to offer advice
in connection with a project that I'm working on and where I'm encountering
a frustrating bug. Furthermore, where I'm not certain whether it's hardware
or software related, although I suspect the latter.

It's essentially a mains frequency meter, mostly copied cargo cult fashion
from:

http://jeelabs.org/2009/05/28/measuring-the-ac-line-frequency/#comments

The circuit I've built simply takes the mains and outputs half-wave
rectified AC (top half of the sine wave) at 5v peak. For what the Arduino
does with this see the above link. The schematic is at:

https://github.com/9600/timefortea/raw/master/Time_for_Tea_1_0.png

And my code, which is the pretty much the Jeelabs code with the addition of
a PWM output to drive a moving coil meter:

https://github.com/9600/timefortea/blob/master/Time_for_Tea/Time_for_Tea.pde

Now, what I don't understand is why periodically I get a totally erroneous
reading. The meter needle bounces across and then back at the subsequent
reading. Sometimes these events are some time apart and sometimes the thing
seems to get caught in a brief frenzy of them. I *think* there is always at
least one correct reading after every bad one, so I could maybe say if delta
greater than N then use last reading, or something. But this would be a bit
of a fudge. 

I've pasted two sequences of measurements each containing an erroneous reading
as examples below.

Any thoughts much appreciated!

Cheers,

Andrew

-- Example 1.

50.068 Hz +0.14 %

50.070 Hz +0.14 %

50.071 Hz +0.14 %

50.073 Hz +0.15 %

50.072 Hz +0.14 %

50.070 Hz +0.14 %

50.067 Hz +0.13 %

50.063 Hz +0.13 %

50.061 Hz +0.12 %

50.057 Hz +0.11 %

50.053 Hz +0.11 %

50.049 Hz +0.10 %

50.640 Hz +1.28 %

50.039 Hz +0.08 %

50.034 Hz +0.07 %

50.029 Hz +0.06 %

50.024 Hz +0.05 %

50.021 Hz +0.04 %

50.018 Hz +0.04 %

50.017 Hz +0.03 %

50.016 Hz +0.03 %

-- Example 2

50.136 Hz +0.27 %

50.135 Hz +0.27 %

50.134 Hz +0.27 %

50.132 Hz +0.26 %

50.131 Hz +0.26 %

50.129 Hz +0.26 %

50.128 Hz +0.26 %

50.127 Hz +0.25 %

50.127 Hz +0.25 %

50.724 Hz +1.45 %

50.129 Hz +0.26 %

50.127 Hz +0.25 %

50.125 Hz +0.25 %


-- 
Andrew Back
a at smokebelch.org



More information about the members mailing list