PCB design is a must tool to learn to be Industry ready for every electronics engineer. Learn PCB design online in just 20 days and boost your career. Work as freelancer and earn a high amount daily by spending only 2 hours a day part time.

Full width home advertisement

Electronics

PCB Design

Post Page Advertisement [Top]

 500 Khz Frequency-Meter using 89c52


This 500 Khz frequency-Meter, which is based on the well-known AT89C52 microcontroller, will be sufficient to trace and debug the majority of your circuits, to alter the frequency of 555 timers, and to carry out all types of frequency measurements in Digital circuits. 

You will become accustomed to using this tool once you have it in your hands.


500 Khz Frequency-Meter using 89c52




The Block Diagram of the 500 Khz frequency meter


To understand the block diagram below, you should recall the simplest definition of frequency: "the number of occurrences within a given time period". 

What we are trying to do is to count the number of electric pulses during a time of one second. 

To do this we need a counter, to count the pulses, and a timer so that every 1000 milliseconds, the processor stop counting, calculate the frequency and display it, then start counting again from zero.
block diagram of digital frequency meter
This is the principle of operation of a frequency meter, however, to build a reliable frequency meter, we will need to do some more mathematical operations. 

For example: Some operations will accurately predict the frequency before waiting for a whole second to elapse, which will also increase the refresh rate. 

Another minor upgrade is to to display the average of the last 5 reading rather than displaying the frequency instantaneously (which can cause lot of display flickering if the frequency being measured is not very stable).

The circuit diagram


I am sure that you understand that to accomplish this project, we will need to perform some mathematical operations, as mentioned before, to increase the performance of the device. 

Thus we will rely on an AT89C52 microcontroller to perform all the required tasks in this project.

The Display 

While being very simple (as you can see in this diagram), the display system can seem complicated due to the high number of connections (as you can see in the schematic below).

The main idea for this display system, is to connect all the 7-segment cells together in parallel, but only power one of them in the same time.

block diagram of 7 segment display

 here is the sequence to show the number "1984" on 7 segment display built here


1-Send the number "1" though the data lines
2-Energize the first cell while all other cells are off
3-wait for a short time delay (in my code i paused for 0.6 Millisecond)
4-Send the number "9" though the data lines
5-Energize the second cell while all other cells are off
6-wait for a short time delay..
7-Send the number "8" though the data lines
8-Energize the third cell while all other cells are off
9-wait for a short time delay..
10-Send the number "4" though the data lines
11-Energize the fourth cell while all other cells are off
12-wait for a short time delay..
13-Start over from the step No: 1

the human eye wont notice anything wrong, because, with the given delays the display will refresh at the rate of 375 cycles per second (375 Hz!) and the human eye can hardly notice some flickering in a display refreshing at 24 Hz.

The components Properties

Q1,Q2,Q3,Q4 2N2222 switching transistors to drive the 7-segment displays.
DD1 to DD4 7-segmets display, common Anode type.
R21 to R24 1Kohm pull up resistors
R35 to R38 100Kohm pull down resistors
U1 The AT89C52 Micro-Controller 

Where to give input frequency ?

Nothing really critical about this part, since we only intend to measure TTL frequencies, the input is directly fed to the TO pin of the AT89C52, which will be used as a counter.

P1 and P2 are simply the 2 connections for the test leads. 

Note that in order to make any kind of measurements on another circuit, the ground of the Measurement device and of the circuit being tested must be connected together, this is why there are at least 2 leads in any testing device (one for the Ground and one for the measured signal).

The Power Supply

The Power supply here is not critical either, because the device will be powered from a 9V alkaline battery, so we don't need any filter capacitors, we just need to reduce 9V to 5V, and this is simply the job of the IC 7805 (Usually we add decoupling and filter capacitors when there is a lot of disturbance like in motor controllers, or AC to DC power supplies)

+5v regulated power supply for mcu

The Reset Button

reset connections for mcu

This part is standard in any circuit containing an AT89C52.

-The switch SW1 will reset the micro-controller and start the program from the beginning.

-C1 and C2 are 27pF, any nearby value between 20 and 40 pF will work just fine.

The Clock generator


Y1 is a 24 Mhz crystal. it is imperative to use a crystal of this frequency, which is the maximum frequency the AT89C52 can respond to. using a 12Mhz crystals will result in maximum measurable frequency of 250 Khz instead of 500Khz.

Don't forget to connect the PIN 31 to the 5V, otherwise the microcontroller wont work.

----------------------------------------------------------------------------
The software part of the 500khz frequency meter using 89c52

here is a simplified flow chart of the main loop. next to each box, you can see the corresponding source code, this can help you to understand how each step is programmed.

flow chart of 500 khz digital frequency meter

The The Counter and the Timer operations

The function count_pulses() , which is linked to the "Interrupt 1", will be executed each time the TIMER 0 overflows.

Actually this should never happen, because the counting registers are emptied every 1/5 second (if scale = 5, by default), but in case the timer overflows, we should increase the variable: "scale", hence the counting variables will be emptied every 1/6 second, and if the the TIMER 0 still overflows, scale will be increased to 7, and so on, until the system stabilizes at a point where the counting registers are being emptied fast enough, then the calculated frequency is correct.

count_pulses() interrupt 1 //counter 0 interrupt
{
if (scale < 200)
scale++;
}
 The function calc_and_disp() will be executed every 0.66 millisecond (this is defined by the variable TH1 in the setup_interrrupts() function) Each time this function is executed, one of the 4 7-segments is energized, and a corresponding digit is being sent, then, next time the function is called, the next digit is energized to show the next corresponding number... And the sequence goes on as explained before in the display system

Note: dcnt is the variable used to select on of the 4 display cells.

Now you should be able to build your own Frequency meter. If you need the complete working hex code + PCB  layout & c code of the project get Below for $19 USD








































































































































































































































No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib