Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

frequency measurement with mcu

Status
Not open for further replies.

usbman

Advanced Member level 4
Joined
Sep 22, 2002
Messages
118
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Germany
Activity points
1,019
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
 

Epegic

Member level 5
Joined
Mar 29, 2002
Messages
84
Helped
24
Reputation
46
Reaction score
19
Trophy points
1,288
Activity points
597
Set up timer for one second interrupt and monitor the frequency signal on T0 or T1 pin
 

klug

Advanced Member level 1
Joined
Jul 4, 2002
Messages
476
Helped
12
Reputation
24
Reaction score
7
Trophy points
1,298
Activity points
4,382
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.
 

usbman

Advanced Member level 4
Joined
Sep 22, 2002
Messages
118
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Germany
Activity points
1,019
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
 

STOYANOV

Member level 1
Joined
Jan 26, 2002
Messages
40
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,288
Location
Sofia, Bulgaria
Activity points
328
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
 

usbman

Advanced Member level 4
Joined
Sep 22, 2002
Messages
118
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Germany
Activity points
1,019
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
 

MITSUKO

Member level 2
Joined
Jun 6, 2001
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
340
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
 

usbman

Advanced Member level 4
Joined
Sep 22, 2002
Messages
118
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Germany
Activity points
1,019
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
 

CADIX

Junior Member level 2
Joined
Mar 24, 2002
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
84
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)
 

engraxate

Member level 3
Joined
Sep 2, 2001
Messages
63
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
376
try to look this

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

tanveerriaz

Full Member level 5
Joined
May 14, 2001
Messages
295
Helped
33
Reputation
66
Reaction score
25
Trophy points
1,308
Location
Pakistan
Activity points
1,503
frequency meter on microcontroller AT89C52
htt*p://ww*w.qrx.narod.ru/izm/rad.htm
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top