Frequency measurement

Thread Starter

RG23

Joined Dec 6, 2010
304
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
 

tom66

Joined May 9, 2009
2,595
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
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.
 

Thread Starter

RG23

Joined Dec 6, 2010
304
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
 

tom66

Joined May 9, 2009
2,595
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
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.
 

BillB3857

Joined Feb 28, 2009
2,570
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.
 

tom66

Joined May 9, 2009
2,595
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.
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.

To the OP: Given that you are dealing with a low frequency signal, measuring the period of the waveform is about all that you can do. If you do that, you can get (theoretically) infinite frequency resolution (in practice, it's dependent on the resolution of the counter and precision/resolution of your reciprocal function.)
 

Thread Starter

RG23

Joined Dec 6, 2010
304
To the OP: Given that you are dealing with a low frequency signal, measuring the period of the waveform is about all that you can do. If you do that, you can get (theoretically) infinite frequency resolution (in practice, it's dependent on the resolution of the counter and precision/resolution of your reciprocal function.)

@Tom66

I have two questions

How to measure the period of waveform? [I am using timer0]
How to take the reciprocal?
 

Thread Starter

RG23

Joined Dec 6, 2010
304
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
 

tom66

Joined May 9, 2009
2,595
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
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.
 

BillB3857

Joined Feb 28, 2009
2,570
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.
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.
 

tom66

Joined May 9, 2009
2,595
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.
Good point! I wasn't thinking!! To the OP, you want to reset the timer on each rising edge.
 

Thread Starter

RG23

Joined Dec 6, 2010
304
No - that is for you to write.
@Tom66

I still couldn't figure it out

I know how to define the timer but never started the timer on rising edge of pulse and reset on another rising edge and determine the time period

Thats the reason for asking the code

Anyways

Still no success
 

atferrari

Joined Jan 6, 2004
4,764
The Op seems to be listening only what he wants.

Instead of trying to understand the basics he keeps repeating the initial questions in various combinations.

OK, I know that to take advantage of information you need previous knowledge of some kind but he did not stop and kept asking and asking questions.

Why not to stop posting for one week and coming back with what you did not understand after reading what was shown to you.

Google is your friend for basics like "frequency", "period", "timer" & "counter".

Have you considered that besides knowledges there is people giving their TIME to you? What if you have to pay a small fee for every time you get a reply? :eek:
 

Thread Starter

RG23

Joined Dec 6, 2010
304
Why not to stop posting for one week and coming back with what you did not understand after reading what was shown to you.

Google is your friend for basics like "frequency", "period", "timer" & "counter".
________________________________________________________________

I posted this topic after doing that stuff in google etc but still could not get the result

I hope you understand

I could not find anything related to finding the time for the falling/rising
edge of the incoming signal
 
Top