Timing Problems? with pasm tachometer.
I am having accuracy problems displaying rpm using the PST object. The
problems might be in my main spin method, and how it communicates
with the pasm (jm_freqin) to spin, and out through the PST.
At first the program had what I thought was small accuracy problems,
while it was measuring time from an electric motor test stand with a
hall sensor. The inaccuracies became huge when I reduced the baud
rate from 115,200 to 9600. At 115,200, the pst was displaying ~1850 rpm,
but when I reduced the buad to 9600 it displayed less than half of the
normal output ~800.
One of my goals was to display the changing rpm every 1/2 to 1 second.
Any faster would not be easy to read, and every 2 seconds or more can
be like waiting an eternity for good data. Another goal is to use a software
filter, possibly measure 4 to 8 revolutions and find the average. So I tried
adding a waitcnt in spin, but that didn't seem to work, so I added a 1/10th
second delay (waitcnt ) at the bottom of the pasm program.
Next, I added a frequency generator, so that I always knew what the frequency
was, and so I could confirm what the rpm was supposed to be. But my problems
got worse, and constantly displayed 1/2 the frequency.
I thought the freqIn routine was only recording 1/2 of the revolution, but then
I realized if that was happening my rpm would have increase. So perhaps it
is recording 2 loops? But that is crazy because freqin zero's phsa and phsb
every time it loops.
The program was put together in small pieces. Each piece was tested before
I combined it with the existing code, and then I retested. The program is
built around a math routine, jm_freqin, a 32x32 multiplication by Lonesock,
Kenyan 32 bit division, PST, and Frequency Synthesizer demo v1.1
jmFreqIn with Multiply_Division_v02.spin, Is well documented and does a
better job of documenting my problems.