
Originally Posted by
HankMcSpank
A 'Timer1 count' of 5000 equals 100Hz
A 'Timer1 count' of 500 = 1000Hz
Therefore the timer clock cycle = 2us (0.000002s)
What formula do I use to convert my Timer1 count into Hertz? (it's the floating point aspect that messing me up - else I'd just use this simple formula....
1 / ('timer1 count' * 0.000002)
If I add to the left side of the equation (to take the right hand side out of 'decimals' territory)...it cranks up into the millions - tilt!!!!
So how should I approach this Hertz conversion?
Hank, it looks like you are getting great results. Despite what it may look like, you really are not talking to yourself! A lot of people are interested in what you are doing, myself very much included.
I often have to take a step back to figure out math .. or try to. For your equation,
1/(counts * .000002) = hertz
you can change it by multiplying both top and bottom by 500000.
That gives you
500,000/counts = hertz
Then using one of your data points for counts:
500,000/5007 = 99.86 hertz
But since that doesn't fit in a pic well, and since I am sure you want the tenth and hundreds, we multiply the top by 100. Giving us:
50,000,000/5007 = 9986 hundredths hertz. (really 99.86 hertz)
To make it work inside a pic, check out the DIV32 function. It allows a number as big as 2,147,483,647 to be divided by a number as large as 32,767. Looks like you are good on both "counts"
Last edited by ScaleRobotics; - 28th August 2010 at 03:18.
Reason: Took out "code" tags, which seem to make people sick to their stomachs.
http://www.scalerobotics.com
Bookmarks