newelltech
Full Member level 4
picaxe rpm code
Here's what I think is going on. Sorry for cheesy table, lost patience with trying to get HTML turned off.
Line______PulseIn___Pulse_____Expected__My Code__32 Bit____Corrected
_________Polarity___Width_____Reading____________Bit Code__32 Bit Code
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Tach______0________14________RPM/2____RPM/2____RPM______RPM/2
Tach______1_________0.7______RPMx10___RPMx2____RPM______RPM/2
PIP_______0_________7________RPM______RPM______RPMx2____RPM
PIP_______1_________7________RPM______RPM______RPMx2____RPM
1. The Tach line has a narrow pulse. When the polarity is 1 we're measuring it and in the pics it is about 0.7 msec. This will give us a very low count and cause register overflow with unpredictable results. Mathematically it should read 20,000 RPM. Neither code version checks for this. I tried to add a branch but it never got called. So the first step is to check the count for too low a reading and peg the RPM at some number.
2. I don't have time to review the 32-bit code but believe there is a factor of 2 error. If we reduce the reading by 1/2 (see last col) it produces the correct results (except for tach 1 of course)
3. With the 32 bit code corrected, both code versions give the same results. The suspicious thing is that they both produce RPMx2 with Tach 1. So either they have the same overflow consequence or something else is going on. Regardless, the code should never allow the condition and I wouldn't worry about it.
Regards,
Dennis
Here's what I think is going on. Sorry for cheesy table, lost patience with trying to get HTML turned off.
Line______PulseIn___Pulse_____Expected__My Code__32 Bit____Corrected
_________Polarity___Width_____Reading____________Bit Code__32 Bit Code
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Tach______0________14________RPM/2____RPM/2____RPM______RPM/2
Tach______1_________0.7______RPMx10___RPMx2____RPM______RPM/2
PIP_______0_________7________RPM______RPM______RPMx2____RPM
PIP_______1_________7________RPM______RPM______RPMx2____RPM
1. The Tach line has a narrow pulse. When the polarity is 1 we're measuring it and in the pics it is about 0.7 msec. This will give us a very low count and cause register overflow with unpredictable results. Mathematically it should read 20,000 RPM. Neither code version checks for this. I tried to add a branch but it never got called. So the first step is to check the count for too low a reading and peg the RPM at some number.
2. I don't have time to review the 32-bit code but believe there is a factor of 2 error. If we reduce the reading by 1/2 (see last col) it produces the correct results (except for tach 1 of course)
3. With the 32 bit code corrected, both code versions give the same results. The suspicious thing is that they both produce RPMx2 with Tach 1. So either they have the same overflow consequence or something else is going on. Regardless, the code should never allow the condition and I wouldn't worry about it.
Regards,
Dennis