# frequency meter with 8052 ( 8051)

Started by December 11, 2005
```is there any body knows how i can build ''6-digit frequncy meter''  by
using 8051 (or 8052).?

```
```In article <1134317937.058382.117790@g43g2000cwa.googlegroups.com>,
kabacik@gmail.com says...
> is there any body knows how i can build ''6-digit frequncy meter''  by
> using 8051 (or 8052).?
>
>
I know, but if I told you,  I'd have to charge you!    ;-)

Seriously,  you've asked a question that can't be answered fully
in a few paragraphs.   There are  people here who know how to build a
6-digit frequency counter by using an 805X processor, but it's
a job that requires signifcant engineering.

Do you need to measure 10.0000Hz to 6 digits, or
350,000Hz to 1 Hz?

What are the input signals like?   (sine waves of variable
amplitude, or digital signals)

What will you use to display the output?  LED or LCD digit
array, or serial connection to a PC?

The answers to questions like these can make a major difference
in the design of the hardware and firmware.

Mark Borgerson

```
```zotdall wrote:
> is there any body knows how i can build ''6-digit frequncy meter''  by
> using 8051 (or 8052).?
>
There seem to be a lot of choices on Google:

http://www.google.com/search?hl=en&q=8051+frequency+counter

I am sure you can find something close.

```
```zotdall wrote:
> is there any body knows how i can build ''6-digit frequncy meter''  by
> using 8051 (or 8052).?

What is your target Fmax ? & Gate times ?

A generic old 89C52 is not the ideal device;
Look at AT89C51ED2, (newer, better peripherals),
or maybe the AT89LP2052, or C8051F3xx series.

The simplest scheme is to use the uC HW as much as possible;
for Freq you want Cycles/FixedTimeSample.

The 89C51ED2 allows true HW, where you use Timer2+T2OE, in FREQ_OUT
mode, to trigger a CAPTURE of the Externally [Fu] Clocked PCA
[Needs external wire T2 -> CEX0], on a fixed capture timebase.
Those hard-sampled cycle values are then further added/averaged in SW.

A 22.1184MHz Xtal and Timer2, reload value of 55296, will give 10ms
snapshot edges on T2 output pin, to capture the Fu counts.

Then total 10,50,100 of those, for 0.1, 0.5, 1.0 second gate times.
Fmax in is just over 5MHz, as the PCA counts at <= Pclk/4.

You want to avoid gated topologies, as they can have aperture effects,
and do not naturally scale.
With the capture design above, you can have a smart decimal point mode,
that gives a quick answer in the first 10ms, then another digit after
100ms, and another after 1 second (etc) - no edges are lost, so this
is possible : you can get 7/8+ digits of result at 1MHz Fin.

Once you have this mastered, you can really impress your tutor
by also doing a Reciprocal counter design - that gives high
resolutions, independant of input frequencies.

-jg

```
```On Mon, 12 Dec 2005 10:43:15 +1300, Jim Granville
<no.spam@designtools.co.nz> wrote:

>you can get 7/8+ digits of result at 1MHz Fin.

While you can get a large number of (meaningless) digits, you really
need an accurate time base/clock source. To get 6 meaningful digits,
you need a clock better than 1 ppm, for 7/8 digits, you would need
some kind of TXCO or run the crystal in a temperature compensated
oven. With a typical microprocessor crystal, you would expect to get 4
or 5 meaningful digits, unless you lock your time base to an external
accurate source such as GPS or NTP (with long integration times).

Paul

```
```zotdall wrote:
> is there any body knows how i can build ''6-digit frequncy meter''  by
> using 8051 (or 8052).?

It's only possible if you want a fairly low spec unless you use an
external counter/timebase and just use the micro to control it.

```
```zotdall wrote:
> is there any body knows how i can build ''6-digit frequncy meter''  by
> using 8051 (or 8052).?

If it can be a PIC then look at

http://ironbark.bendigo.latrobe.edu.au/%7Erice/newfm/newfm.html

It goes up to 50MHz and is really simple.

```
```i have to build it for my microcontroler lesson, and i will not use it
for money ofcourse. it should have LCD screen.

```
```"zotdall" <kabacik@gmail.com> writes:
> i have to build it for my microcontroler lesson, and i will not use it
> for money ofcourse. it should have LCD screen.

You could always connect a controller to a frequency
meter via GPIB.
```
```Don't use a 8051. Takes 12 clocks to execute one instruction.
Use a modern micro that has a "capture" function.

Something like an Atmel ATmega88.

If you must use the 8051, use a variant. Dallas Semi (now Maxim)
makes a tripler that executes instructions every 4 clock cycles.
Crystal makes the only 8051 that executes an instruction in one clock cycle.

"zotdall" <kabacik@gmail.com> wrote in message
news:1134317937.058382.117790@g43g2000cwa.googlegroups.com...
> is there any body knows how i can build ''6-digit frequncy meter''  by
> using 8051 (or 8052).?
>
>

```