I guess I was not clear. Count is working fine, and the accuracy is right on,
I am using a 4 MHz xtal, and have a meter from work that reads 0.001 Hz,
just need to track it from 50 Hz to about 62Hz. Generators shut off anyway
on overspeed at about 65Hz.
I am using count over 4 seconds to get more resolution, since the meters read .1Hz, should be using 10 sec, but that is too long a wait for update.
A count of 240 is 60.0 Hz. But when I feed my program more than 62 Hz,
it overranges, and the display "rolls over" to zero. All I wanted to do is limit
the readout to 62 Hz, that is, "jam" a value of 62 in, if the real world tries to give it a higher value. Like this, seems to work. Next part is to get it to read 60.0 Hz even
when there is jitter causing it to jump around a little. It is pretty stable, I put
a 1 uF film cap across the meter input, but these guys are fanatical, they want it to read 60.0 Hz most the time, the computer panel this goes with does that
(and I happen to know they use bracketing tricks like this).
Maybe there is a more elegant way to introduce the 62Hz limiting, this
is cumbersome.
Code:
main: i2cslave %00011000,i2cslow_16,i2cbyte 'config i2c
setfreq em16
main2: Count C.7, 16000, w2
if w2 > 248 then main4 'if HZ > 62 then
main3: w2 = w2 << 4
WriteI2c 0, ( %00011000, b5, b4 )
debug
goto main2
main4: w2 = 248 'limit to 62
goto main3