Frequency measurement

Thread Starter

RG23

Joined Dec 6, 2010
304
I want to measure the frequency of the incoming signal using PIC 16F887

I am not sure how to measure frequencies like eg. 2.3 Hz or 3.7 Hz

i also want to display it on LCD

If you have any idea please let me know

Thanks
 

Papabravo

Joined Feb 24, 2006
21,225
The usual method is to define something about the periodic waveform of interest that you can detect like a peak value, low to high transition, or zero crossing. Then you can either count the number of times per second that the event occurs or you can measure the elapsed time between two successive events and take the reciprocal to get the frequency.
 

Thread Starter

RG23

Joined Dec 6, 2010
304
i have defined a timer TMR0

how should I measure the frequency of incoming signal ?

Please let me know
 

Thread Starter

RG23

Joined Dec 6, 2010
304
I have defined one of the ports as an input port in PIC 16f887

Then when I connect the function generator to that port I wish to see the same frequency I set on generator whether its 2.7 Hz or 27 Hz etc

I didn't understand counting the number of events per second
which event????
 

CVMichael

Joined Aug 3, 2007
419
Hi RG23,

You need a timer to be at 10Hz (if you want 1 decimal), 100HZ (if you want 2 decimals), and so on... You will need a counter variable, so for every timer interrupt, have your counter increment, i.e. counter++;

Then you need an interrupt, since you are using PIC16F887, it will have to be on RB0/INT, so connect your incoming signal on that pin.
The counter should have your time since last interrupt, so display that value, you need to display "counter / 100" (for 2 decimals). Then right after that reset the counter back to 0 (zero).

PS. What programming language do you plan to write this in?
 

Thread Starter

RG23

Joined Dec 6, 2010
304
Then you need an interrupt, since you are using PIC16F887, it will have to be on RB0/INT, so connect your incoming signal on that pin.
The counter should have your time since last interrupt, so display that value, you need to display "counter / 100" (for 2 decimals). Then right after that reset the counter back to 0 (zero).

_______________________________________________________________

I am not clear with that
 

BillB3857

Joined Feb 28, 2009
2,570
Hi RG23,

You need a timer to be at 10Hz (if you want 1 decimal), 100HZ (if you want 2 decimals), and so on... You will need a counter variable, so for every timer interrupt, have your counter increment, i.e. counter++;
<snip>
You have me confused, which is not too unusual. I thought that the sample had to be 10 times LONGER to get 0.1 resolution and 100 times LONGER to get 0.01 resolution for low Hertz frequencies i.e. 1/10 Hz for 1 decimal and 1/100 Hz for 2 decimals. Can you enlighten me?
 

SgtWookie

Joined Jul 17, 2007
22,230
i have still not figured out the problem

I would appreciate any further help

Thanks
Did you see the link I posted in reply #8?
It's a complete project, that seems to be well-documented.
It even has the assembly language source code posted.

You will need to convert the souce code from a PIC16F628 to a PC16F887, or simply use a PIC16F628 as the author did.
 

tom66

Joined May 9, 2009
2,595
You could set up the timer to measure the length of each pulse. The reciprocal of this is the frequency. Unfortunately doing a reciprocal on an 8-bit PIC will be a nightmare. Instead, I'd recommend you could the number of pulses in 10 seconds. 27 pulses = 2.7 Hz.
 
Top