rexlan
Junior Member level 3
- Joined
- Aug 20, 2006
- Messages
- 31
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- USA -- Florida
- Activity points
- 1,547
picaxe rpm
Hi all:
What I want to do is use the PULSIN command on a PICAXE-8M chip to caculate the RPM of a motor. I have this idea and code so far but I am not sure how to do the math to actually get a RPM number like 2900, etc. I will use the standard 10us slice with the chip.
I am taking ten samples of the length of time between a pulse of the ignition system and averaging the sample. This is a four cylinder engine so there are (I think?) two pulses per revolution.
I thought about the count command but I don't think there is much resolution. Hippy has helped me with a variation I will use to change the value of RPM with some dil switches after I have this working.
symbol RPM= 0 ' set the name RPM to 0
low 0 ' preset I/O pin 0 to low
getpulse:
w1 = 0 ' preset word 1, the accumulator variable, to zero
for b0 = 1 to 10 'define loop for 10 times, variable b0 is the counter
pulsin 3,1,w2 ' record the length of a positive-going pulse on
I/O pin 2 into word 2
w1 = w1 + w2 ' add in the new pulse width to the total being
accumulated
next b0 ' jump back to the "for" instruction again until
loped ten times
w1 = w1 / 10 ' compute the average by dividing the accumulated
total by ten
RPM = w1 *(here is my problem)
Pause 100
if RPM > 3000 then overrpm ' jump to "overrpm" if word 2 is over
the RPM limit turn on the control
low 0 ' set I/O pin 0 to low (control off)
goto loop ' loop back to start
overrpm:
high 0 ' set I/O pin 0 to high and turn on the control
goto loop ‘ loop back to start
Hi all:
What I want to do is use the PULSIN command on a PICAXE-8M chip to caculate the RPM of a motor. I have this idea and code so far but I am not sure how to do the math to actually get a RPM number like 2900, etc. I will use the standard 10us slice with the chip.
I am taking ten samples of the length of time between a pulse of the ignition system and averaging the sample. This is a four cylinder engine so there are (I think?) two pulses per revolution.
I thought about the count command but I don't think there is much resolution. Hippy has helped me with a variation I will use to change the value of RPM with some dil switches after I have this working.
symbol RPM= 0 ' set the name RPM to 0
low 0 ' preset I/O pin 0 to low
getpulse:
w1 = 0 ' preset word 1, the accumulator variable, to zero
for b0 = 1 to 10 'define loop for 10 times, variable b0 is the counter
pulsin 3,1,w2 ' record the length of a positive-going pulse on
I/O pin 2 into word 2
w1 = w1 + w2 ' add in the new pulse width to the total being
accumulated
next b0 ' jump back to the "for" instruction again until
loped ten times
w1 = w1 / 10 ' compute the average by dividing the accumulated
total by ten
RPM = w1 *(here is my problem)
Pause 100
if RPM > 3000 then overrpm ' jump to "overrpm" if word 2 is over
the RPM limit turn on the control
low 0 ' set I/O pin 0 to low (control off)
goto loop ' loop back to start
overrpm:
high 0 ' set I/O pin 0 to high and turn on the control
goto loop ‘ loop back to start