Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

frequency measurement with mcu

Status
Not open for further replies.

usbman

Advanced Member level 4
Full Member level 1
Joined
Sep 22, 2002
Messages
118
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Germany
Visit site
Activity points
1,020
I need some advices how to measure frequencies f<100kHz
with a mcu. I want to use 89c52 for that task.

I already tried this with a simple aproach using some timers
but the result is not exact enough. :cry:

Hany hints are welcome :idea:

Cheers UsbMan
 

Set up timer for one second interrupt and monitor the frequency signal on T0 or T1 pin
 

89c52 frequency meter.

Hi UsbMan!

The best way is to use timer in counter mode. In this mode your counter is counting takts directly from pin of processor. Only you need is to start counter, look to its overflow flag, count overflows and stop it after exact period of time.

You can use one timer of 89c52 in 16 bit mode to count external signal takts, (it can count up to 1/24 of Fosc, so it will be enough to your 100kHz), and another timer with prescaler to count time of measuring.

After first counting, if counted frequency is too low than you can increase mesuring time by 10 and count again in more precision. So your precision will only depends of measuring time.

Best wishes & 73! Klug.
 

Re: 89c52 frequency meter.

klug said:
After first counting, if counted frequency is too low than you can increase mesuring time by 10 and count again in more precision. So your precision will only depends of measuring time.

Hi klug,
thanks for your sugestion, at the moment i am doing the freuency measurement
with a gatetime of 1 s and the result is ok for higher frequencies
I will give your idea about increasing the gatetime a try.

Thanks UsbMan
 

Frequency measurements

usbman,

If you want to measure low frequency faster, it is better to measure the period instead of frequency. Set your timer to count up with fixed, relative high frequency and use your measuring input as a start/stop input for the timer. It is good to use a divide by two circuit ( D trigger) on this input. Start the timer on ( for example ) leading edge and stop and read the result failing edge. Convert the result to frequency.
This way, your measuring time is equal to one cycle (period) of your measured signal, instead of fixed 1 or 10s.

Best of luck!

STO
 

Re: Frequency measurements

Thanks to all who made sgestinons....

The idea from STOYANOV dit the trick for the lower freqs (< 100 Hz)

Thanks again

UsbMan
 

usbman

do you speak dutch ?
There was an article in elektor a few years ago about a uPC
freq counter that used some kind of mixing two frequencies
algorithm . One was the unknown , and the other a ref frequencie
It was sayd to be correct down to half a period .

But i only have the article it in dutch , somewhere .
Let me know if you want it .

Mitsuko
 

MITSUKO,
MITSUKO said:
usbman

do you speak dutch ?
There was an article in elektor a few years ago about a uPC
freq counter that used some kind of mixing two frequencies
algorithm . One was the unknown , and the other a ref frequencie
It was sayd to be correct down to half a period .

Mitsuko

I don't speek dutch. I allready know that article. In my oppinion the
algorithm isn't explained very clear.
I think its almost meassuring the period like i am dining it do now.

Anyway thanks

UsbMan
 

Freq / period measurment

The method who gives a constant accuracy (1 clock) is as follows:

Start counting simultaneously (with 2 counters) the periods of signal( Ns) and these of clock (Nc) ; stop counting after a time T > lowest period to be measured.
Measured freq is then : Fs = (Ns/Nc) x Fc
(Fc = Clock freq.)
If you synchronise start and stop with entering signal precision is constant. (prop. to T, and clock freq.)

With a MCU it's a good solution, but you have to write arthmetical routines. (It gives you frequency or period, as you want)
 

try to look this

Hi
Try to look this circuit. Maybe it can help you.
ww*w.geocities.com/mpu51/fc50mhz/fc50mhz.html
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top