Thanks for that Charles i probably should have added i am using a 16F88 pic running at 8mhz, TMR1 (16bit) is already in use for another interrupt driven routine. Darrell's SSPWM routine.
Thanks for that Charles i probably should have added i am using a 16F88 pic running at 8mhz, TMR1 (16bit) is already in use for another interrupt driven routine. Darrell's SSPWM routine.
It would still work with that part (I think). I normally run this on a TMR0 interrupt (in an 18F part). You could make the speed interrupt a low priority interrupt, and let the SSPWM be high priority. That way, the speed interrupt wouldn't screw up your PWM.
You could get by with 8 bit counters (ex fan1counter in my example) in your application. I used a 16 bit counter because I often need to measure the speed of
15,000 RPM fans.
Charles Linquist
I will try that later Charles.
I was hoping for some help using DIV32 and that sort of thing to reduce errors in my 16 bit maths![]()
Still hoping for some guidance on the div32 type maths to improve the accuracy of my current 16 bit maths![]()
Hi, Retep ...
first you have to declare a dummy var ... and a Div flag
then ...
Code:IF Local > 32767 then ' see PBP manual ... for the Why ??? Local = Local/2 Div = 1 Else Div = 0 ENDIF Dummy = 11 Dummy = Dummy*7908 ; operation needed by PBP ... ActualSpeed = DIV32 Local IF Div THEN ActualSpeed = Actualspeed / 2 ' Ooops ! not *2 ... ActualSpeed = ActualSpeed + 1
Last edited by Acetronics2; - 6th May 2011 at 08:19.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Thanks for the help so far, here is a different formula though.
How to convert that to use max resolution and div 32 command etc.
3600sph / (count * 0.000005 * 4550)
Count will be a maximum of 10,000
Does this code look correct to implement the formula?
'Formula Speed = 3600 / (Local * 0.000005 * 4550)
Dummy = Local * 5
Local = 10000
Dummy = Dummy * 4550
Dummy = DIV32 Local
Count1 = 36000
Local = Count1 * 10000
Speed = div32 Dummy
Speed = Speed / 1000
Bookmarks