Hi am building a frequency counter have a code that I am working from all goes well.
I have turned it into a tachometer code. the problem I have is I want to eliminate the decimal point and last 2 digits for example at my operating speed the display reads 62000.00 witch is correct I want to eliminate the decimal point and last 2 numbers so it will read just 62000
attached is a copy of the code I am using any Ideas on removing the last digits
you're using floats. that's fine. your application may require them. but, your final division is into a float and it's that's what you print. not fine.
Thanks that does work but then the reading will only go to 32000 then it displays a minus and then counts backwards to zero at 0HZ input the display reads 0 at 1000HZ reads 32000 after 1000hz it goes-30000 at 2000hz its back to zero.Had the same problem with a lot of the tach programs I found they will not read correctly at higher frequencys allways go into minus numbers
the 32000 number you reference is a dead give-away, since it's so close to 32767. i checked the language ref. an int, is defined as a 2-byte int. max positive value of 32767. any add to that value will wrap to negative. use unsigned long. it's 4 byte int with a max value of a crap load. check the ref.
with this sketch I get 0 rpm reading at 0 HZ just like it should be but then from about 5HZ to 45 HZ I get the multi numbers on the display after about 45 to 50HZ again reads perfect.
pulseTotal = pulseHigh + pulseLow; // Time period of the pulse in microseconds
unsigned long frequency = 30000000/(float )pulseTotal;