??? 02/24/09 04:26 Read: times |
#162726 - Tip for Speed sensor via External Interrupt |
I'm having issues with a counting function for calculating speed pulse transitions.
I'm using a 74ls02 to fire an external edge trigger interrupt and a port pin to monitor the level of the switching transistor to count the pulses. I'm using a timer0 with a 500ms window to count how many transitions occur and then will be translated to speed/rpm data. The problem now that I think of it, is that in the lower numbers, the time durations are sub seconds within that 500ms window and will just be recorded as zero since there is no such thing as a 1/2 a pulse. I need to update the display every 1 or less (1/2 second is optimal. Here is my data tables: Pulse Count (Hz)-MPH-KPH-Pulse Count/60 Seconds 2.20 1 1.61 0.0366666667 4.40 2 3.22 0.0733333333 6.60 3 4.83 0.1100000000 8.80 4 6.44 0.1466666667 11.00 5 8.05 0.1833333333 13.20 6 9.66 0.2200000000 15.40 7 11.27 0.2566666667 17.60 8 12.87 0.2933333333 19.80 9 14.48 0.3300000000 22.00 10 16.09 0.3666666667 24.20 11 17.70 0.4033333333 26.40 12 19.31 0.4400000000 28.60 13 20.92 0.4766666667 30.80 14 22.53 0.5133333333 33.00 15 24.14 0.5500000000 35.20 16 25.75 0.5866666667 I tried to pick up some info from the heart beat and speedometer thread, I don't think I found anything that I can use to solve my issue. Any suggestions on how to properly parse the pulses with my timers? Would a counter be effective here instead of a timer? I'm stuck and could use a fresh thought. |