I really think somethings wrong with the math. I just can't figure it out :/
Now an example:
Code:
MAIN:
W1 = W1 * 2 ' To get whole period
W1 = W1 * 4 ' now the count is in mS
W1 = (60000/W1) ' Revs per 60 mS
W1 = W1 * 1000 ' Revs per minute
GOSUB display ' Go to display sobroutine
GoTo LOOP ' Do forever
The input has a period of 12 mS (5000 RPM) - Which is 1500 increments @ 4µS.
As I only measure the low part of the 50% duty-cycle, I multiply with 2. Full period.
Then I multiply with 4. Now it's in mS. 12,000.
60,000 / 12,000 = 5.
5 * 1000 = 5000 RPM. NICE! - But i doesn't work.
I have seriously no idea of why this shouldn't work.
EDIT:
And then i thought. Figure out when i goes wrong:
So i tried to make the calculations. With a number, that wouldn't go straight up into 60,000. Example: 2000.
2,000*2=4,000
4,000*4=16,000
60,000/16,000=3.75 <- I guess this is were the PIC can't follow my lead.
3.75*1,000= 3750.
Bookmarks