I am using the C51 compiler and have code for the silabs C8051F120.
I have built a wind speed sensor with a rotary encoder but it seems to top out at 42mph. I know there have been gusts greater than that since I started using it.
I have considered calibrating the unit with an automobile and think i may be missing edges of the encoder signal because of processing overhead. I think the encoder counter routine should be interrupt driven.
My coworker Frisky suggested the circuitry is not able to handle fast counting signals coming from sensor and said that the 2nd problem circuitry should be analyzed.
Does anyone have an idea why that might happen?
A poor little 8-bit processor can handle many kHz if it is correctly programmed. In some situations, it may even be able to handle MHz signals.
Note that if using a hardware counter to count # of ticks in a fixed time interval, the max speed is limited by the counter hardware and not by the processor speed.
Issue one interrupt for each pulse. Check how many interrupts (pulses) you get in a second.
Or: connect signal to a timer and let it tick one step in hardware for each pulse.
If if you really do need to poll: Keep track of current and previous value. Only count when previous is zero and current is one. OR only count when previous is one and current is zero. That will give one count for every positive (or negative) flank of the tachometer signal.
And do make sure if your pulses has fixed or proportional pulse width. It does affect if the hardware has a limit on # of pulses that may be generated per second.
freyed,
You said earlier:
"I think the clock is going at 50MHZ and the pulses are going at about 18 to 22MS so i cannot see how the code can miss them."
You are right with that.
A basic 8051 running at 12MHz can easily do timing on 22ms pulses. But it assumes that the code is written in an appropriate fashion.
Just re-read the posts here, analyse your problem and fix your code.