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.
Thanks
Bill M.
Comments
How many pulses do you read per revolution and what is the speed range 0-1850 rpm etc. In another post I have a simple frequency counter that works very well. If you read one pulse per revolution, than the best you could read would be 60 rpm.
I started with one spark/rev to get the process ironed out, but eventually it will need 2 sparks
per revolution. The rpm range needs to be ~900 to 9,999 rpm so that it will fit in a 4 digit, 7
segment display. Eventually I will need ~8 revolution with 2 sparks each rev so I can display
the average, and calculate acceleration.
The tachometer is for a racing Kawasaki X2 (jet ski), and since it is difficult to watch a display
at high speed, it will need to work as a data logger, for other sensors too, and a warning
buzzer to warn the rider to slow down if the engine is experiencing detonation.
I also need a simple tach with a display to offer other watercraft users as an easy to build,
open source design that includes a capacitive pick-up for the spark plug wire.
Originally I planned on using the P2 for this project. Spin2 and pasm2 certainly make the
math easier, but I wanted to spend more time learning P1 pasm since there is a larger
pool of good information available for the P1, compared to the P2.
Bill M.
You need better sensor resolution. Instead of counting sparks it would be better to count pulses off a shaft sensor. Like a 60 tooth gear, then you could read it as straight up frequency, freaquency would = rpm. A sensor counting the teeth on the crank flex plate that engages the starter would be a good candidate.
I disagree, I found the problem with the program. It was my P1 frequency generator.
With the current program (P1 frequency generator removed), there is only 3 to 6 rpm
error. I tested the new freq generator with a logic analyzer to confirm it was generating
the same frequency it said it was.
I do want to average the rpm measurements though, some combination of 2^n (4, 8, 16,
32, 64, etc) to make the math calculation faster.
Capacitive pick-ups (for counting sparks) are easy, and accurate when you mask the
coil bounce. We have discussed Capacitive pick-ups on the P1 forums before, and
unfortunately it wasn't as simple as adding a schmitt trigger, but with a few components
you can mask a 3ms (or whatever duration) coil bounce with a little testing.
Bill M.
You don't need additional components for that. Just write your program to ignore any edges that occur within 3 ms. of the timed edge. (I'm mentoring a HS senior who's using the Prop in a digital tach for his car. All signal conditioning is done in software, and it works.)
-Phil
This may not help but I used it to count comparator transitions in my bldc project. I changed the "pin" to 16.
Ok, you said your counting sparks, I'm guessing that this is a two stroke and it fires once per shaft revolution. So at 10k rpm that's 166.6 hz , if you want that accurate acceleration, more resolution would be helpful, I do acceleration setups for actuators and machine motion all the time, what works best is small D.C. Generators wether they be linear or rotary. D.C. Volts out against time equal acceleration. In your case your going to measure ticks from one set point to another.
I have been aware of that method for a while. But for some reason I keep
gravitating towards the method used by many tachometer, hour/meters
using a similar circuit (from our old post) and a quad nand gate with 2
capacitors.
Recently I found another possibility using 2 inverted schmitt triggers and
1, maybe 2 rc circuits to mask the coil bounce.
Regarding acceleration, is there anything wrong with just using (rpm - rpm_initial) / time?
The old Dyno Jet inertia dynos used to use only one measurement/rev
to calculate torque and horsepower/ rpm or / time.
Personally I think Dyno Jets were a pos dyno, but I believe it failed for other
reasons.
I am looking for the point where acceleration flattens out, and maybe goes
negative so that I can approximate where the engine makes peak hp. Especially
on a watercraft that I have no dyno information on. On a watercraft, with a
jet pump, it is very likely that the engine will fail, if it does not rev to peak HP
rpm. Unfortunately impeller manufactures sell their impellers as a bolt on
increase in speed (like just changing sprockets on a motorcycle), instead of
estimating the increase in peak hp the engine requires to turn the new impeller
the same rpm as the old (stock) impeller.
Acceleration could be a good project for your student. So would a portable
weather station and/or temp sensors inside the engine compartment so the
student can learn about how air temp, barometric pressure, air density,
and density altitude can affect horsepower negatively.
The SAE dyno correction factor is an easy way to demonstrate the % of HP
lost, or gained by weather conditions.
Thanks
Bill M.
To measure Accel using pulse you have to set a trigger threshold, let say steady idle is 800 rpm, then trigger your timer so it starts at 825 or 850 rpm and then stop the timer at 9500 rpm, count how many pulses you had in the duration. How fast you you gate or count the pulses in your program effects your time. Another start trigger could be a switch on your throttle.