Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/06/03 09:24
Read: times


 
#56152 - RE: RPM
Responding to: ???'s previous message
Since you know the possible range of values beforehand, you can use integer calculations but premultiply the numbers by a factor -say 100 if you want two decimal places.
eg: 2.32 = 232. You can add/remove the implied decimal place in your input/output routines if you need a human to interpret them. You will probably have to use long variables in 'C' to cope with the larger numbers. Remeber with integers do all your multiplies first then divide! Otherwise you'll lose precision.
Another method od counting RPM especially if you need an accurate value (for fuel injection etc) is to measure the period (the time between the trigger pulses) therefore you get a value for each input pulse. To convert the value (use a timer) back to rpm you divide the timer value by a constant which you have precalculated. If you want output in 10's of RPM, just change the constant. Easy to do in asm or 'C'. Low rpm's can be a bit tricky as the timer can overflow between pulses, in this case the timer overflow interrupt increments an extra variable thus increasing the timer length. The input pulse comes via an interrupt whereby you calculate the difference between the previous timer value you had and the current timer value thus getting the time difference between the two. Since you get a result every pulse, it is sometimes worthwhile to low-pass filter the value to stop it jittering around - engines have quite a variation in instantaneous rpm. With the analog tachometers this was done with fluid in the meter pivots.

Silicon Chip magazine in Australia (www.siliconchip.com.au) had an article for a digital tacho using a PIC processor that you can download the code for (in asm) and get the idea of how to do it.


List of 11 messages in thread
TopicAuthorDate
RPM            01/01/70 00:00      
   RE: RPM            01/01/70 00:00      
   RE: RPM            01/01/70 00:00      
   RE: RPM            01/01/70 00:00      
      RE: RPM            01/01/70 00:00      
         RE: RPM            01/01/70 00:00      
            RE: RPM            01/01/70 00:00      
               RE: RPM            01/01/70 00:00      
         Fixed Point Arithmetic            01/01/70 00:00      
         RE: RPM            01/01/70 00:00      
   oops wrong thread            01/01/70 00:00      

Back to Subject List