Set up the timer to count 10 seconds some how. On each rising pulse (change from low to high) increment the counter. When the timer counts 10 seconds, display the value and reset the counter.how do I measure the length of each pulse of the incoming signal using timer?
As I mentioned earlier when I connect the function generator ot one of the ports I should read the same freq on LCD
If you have an idea please let me know
Thanks
Then you will either have to trick the user by averaging the new value with the old one, or use the reciprocal method suggested by Mark.Set up the timer to count 10 seconds some how. On each rising pulse (change from low to high) increment the counter. When the timer counts 10 seconds, display the value and reset the counter.
@Tom66
I have to display frequency after every one second and reset counter too after 1 second
This is an issue with asynchronous counters but synchronous counters avoid this. Modern frequency counters avoid it. I'm not entirely sure how it works though, so don't take my word for it.If you are limited to a 1 second sample time, your accuracy will be +/- 1cps since you cannot control the timing of when the first count appears after starting the sample. Of course you could synchronize the sample start with the first rise seen on your unknown signal and accept that as your first count. Any fractional cycle left will be discarded.
I've explained it already. Your program needs to watch one of the port pins and check if it has gone high. Then it can start a timer. It needs to keep watching the pin. When that goes low, the timer needs to stop. The value in the timer is the period, times the scaling factor of the timer. Ideally, set up the timer so that it has a direct easy relationship to seconds; for example, one timer period = 1 millisecond.I am using Timer0
I would like to know how can I measure the time between the two consecutive rising egdes of the incoming signal at one of the ports
Thanks
No - that is for you to write.Do you have any code related to it?
Thanks
The period of a cycle is the time from two equal value points, not the time from when it goes high to the time it goes low! a 10% duty cycle rectangular wave would show 10 times the actual frequency using that logic. Start the timer on a rising edge and stop it on the next rising edge.I've explained it already. Your program needs to watch one of the port pins and check if it has gone high. Then it can start a timer. It needs to keep watching the pin. When that goes low, the timer needs to stop. The value in the timer is the period, times the scaling factor of the timer. Ideally, set up the timer so that it has a direct easy relationship to seconds; for example, one timer period = 1 millisecond.
Good point! I wasn't thinking!! To the OP, you want to reset the timer on each rising edge.The period of a cycle is the time from two equal value points, not the time from when it goes high to the time it goes low! a 10% duty cycle rectangular wave would show 10 times the actual frequency using that logic. Start the timer on a rising edge and stop it on the next rising edge.