Consultar ensayos de calidad


Implementation of PIC based Digital Frequency Counter




Implementation of PIC based Digital Frequency Counter

Abstract—The main process of this research is to display the
frequency ranges of input frequency. Any desired input frequency from 10Hz to 30 MHz can be counted and displayed using Peripheral Interfacing Controller (PIC) 16f84A and seven digits of Seven Segment Light emitting diodes (LED) display. The input frequency is counted by PIC16F84A and the output from this PIC pins are decoded by analog multiplexer, 4051 Integrated Circuit (IC). Seven digits are displayed by passing seven NPN Bipolar Junction transistors (BJT), BC547.The main desired output is the high resolution display in MHz range of frequency. Studying the PIC Microcontroller, seven segments LED display and the decoders are included in this research. PIC Assembler Software Techniques are also implemented with this research. In this research, the complete design of the advanced frequency Counter is provided. By the help of components, such as, transistors, diodes, the hardware and software technology are combined and developed in this project.



Keywords—Input frequency, Peripheral Interfacing Controller (PIC), Seven Segment Light emitting diodes (LED), 4051 Integrated Circuit (IC), BC547 BJT, Assembler Software Techniques, hardware and software technology. I. INTRODUCTION N several occasions counting isrequired, but manual counting becomes time-consuming and inaccurate when objects to be connected are very large in number or they pass through in quick succession. In such situations, counter using electronic circuits are more reliable then manual counting. A counter with suitable connectivity can work as a stopwatch, or as frequency counter. Various types of frequency counter may have analogue or digital forms. Some of the instruments commonly used for measuring various frequency ranges are, Oscilloscopes, Wein Bridge Frequency Meters, Zero-beat Frequency Meters, Direct reading Frequency Meters, Binary Frequency Counters, Digital Frequency Counters and University time-counters. The oscilloscope can measure a wide range of frequencies. However, the accuracy of oscilloscope is somewhat limited. The Wein Bridge Frequency Meter is a device designed only to produce accurately known audio-frequency signals. Zerobeat Frequency Meter is used to measure the radio-frequency range. The University time-counter can be used to measure both frequency and time intervals. But it can be only used to
Manuscript received August 15, 2008. This work was supported in part by the Ministry of Science and Technology, Union of Myanmar. Wai Phyo Aung is with the Mandalay Technological University, Mandalay, Myanmar (phone: 095-2-88704(Electronic Engineering Department), fax: 095-2-88702 (Office,MTU), e-mail: aungwp@gmail.com).

accuratelymeasure low frequencies instead of frequency counters. Digital frequency counters are the most accurate and flexible instruments available for measuring unknown frequencies. Frequencies from dc to the giga-hertz range can be measured with digital frequency counters. In this thesis, the author used the most advanced microcontroller to build the digital frequency counter. Most modern microcontrollers have the following built-in features: 1. Built-in monitors /debugger program 2. Built-in program memory program-ming from a direct host connection 3. Interrupt capability (from a variety of sources) 4. Analog input and output 5. Serial input and output 6. Bus / external memory interfaces (for RAM and ROM) PIC microcontroller has become a real powerhouse with regards to available support. In many ways, the PIC microcontroller has more support available than other electronics device. In this research, the PIC 16F84A is used to construct a high resolution frequency counters which can measure up to 30 MHz. II. HARDWARE DESIGN OF PIC BASED FREQUENCY COUNTER The frequency counter to be designed in this research is the PIC 16F84A based 10 Hz-30 MHz range frequency counter. The most advanced technique of microcontroller is used to design the HF frequency counter. There are many PIC microcontrollers such as PIC 16C54, PIC 16F84, PIC 16F628 and PIC 16F877 that can operate as frequency counter. In this research, the frequencycounter using PIC 16F84A is used. The block diagram of this frequency counter is shown in Fig. 1.

O

Fig. 1 Block Diagram of PIC 16F84A based Frequency Counter

348


World Academy of Science, Engineering and Technology 42 2008

The HF input is fed into the PIC at pin 2 and pin 3 (RA3 and RA 4) by passing through the 470 resistor and this input signal is amplified by a BC 547 Transistor, an inductor, etc. The supply voltage for two circuits: PIC and 4051 Decoder are +5 V DC. The incoming signal is measured by PIC 16F84A with the help of software. Three PORTA pins, RA0 to RA2 are connected to 4051 Decoder and these 3-bytes outputs are multiplexed in this Decoder. The seven output pins of the 4051 Decoder are fed into seven number of Common Cathode 7 segments LED display at common pin. The main process of 4051 Decoder is that to convert the incoming 3bytes from PIC to Digit Numbers. The anode pins of 7 x Common Cathode 7 segment LED display are connected with the PORTB pins (RB7:RB0) of PIC microcontroller. The cathode pins are grounded and connected to 4051 Decoder passing through 7 x NPN Si-Transistors. The power supply circuit is built to convert the AC 220 V to the required +5 V DC, the actual requirement is between +2.5 and +5 V DC. The Transformer converts 220 V to 12 V AC. This 12 V is changed to the required +5 V by using 7805 IC with the help of two capacitors. III. OPERATION OF PIC 16F84AAS FREQUENCY COUNTER In this application, the PIC 16F84A operated as a frequency counter which can read frequencies from 10 Hz to 30 MHz. It is used the method of measuring the 24-bits (3-bytes) counter value from the prescaler, TMR0 (timer 0 module) and some other registers, such as Option Register. The basic hardware for the measurement circuit is depicted in Fig. 2. It consists of the frequency input at TMR0 or TOCKI (pin3 in a PIC 16F84A). This pin is connected to RA3 and the input frequency is connected to TOCKI through a 470 resistor. TMR0 is configured to measured the input frequency, at RA4 of the PIC 16F84A. The input frequency is “gated” for a precise duration of time. Before starting this precise “gate”, TMR0 is cleared and the RA3 pin is configured as an input. The precise “gate” is implemented in software as an accurate delay. A 24-bit value of the input frequency is now saved in TMR0, Registers and 8-bit prescaler. By concatenating the calculated value and the original value from TMR0 (256-N), the 24-bit value for the frequency is determined.

+5V is to it at pin 3, 4 and the desired requirement of 7 digits can get through 7 transistors of BC547. The circuit of this IC is shown in Fig 3. Three PORTA pins, RA0 to RA2 are connected to 4051 Decoder and these 3-bytes outputs are multiplexed in this Decoder. The seven output pins of the 4051 Decoder are fed into 7 x Common Cathode 7 segment LEDdisplay at common pin. The main process of 4051 Decoder is that to convert the incoming 3- bytes from PIC to Digit Numbers. This IC is the analog 8-channel multiplexer type decoder.

Fig. 3 Connections Diagram of the 4051 IC

V. FEATURES OF DESIRED PIC BASED FREQUENCY COUNTER The features of the frequency counter in this project are: 1. 7-digits Frequency Counter counting the frequency in the range of minimum 10 Hz to maximum 30 MHz. 2. In actual, it can be counted up to 35 MHz. 3. Decimal point is after MHz digit. 4. Power consumption of 7-segment display is 2.5V/9mA or 3V/13mA or 5V/35mA. 5. Measuring period is assigned with 0.1 second (100 000 µsec). 6. Number of processor cycle is 25 000/fx; fx = crystal frequency. 7. Three timing loops, T1 = 7, T2 = 3 and T3 = 20, rough timing loop, timing loop and fine timing loop. 8. Total timing formula is: N = 60 x [(36+3 x T1+X) x 7+2+3 x T2+Y] +19+3 x T3+Z (Where X, Y and Z are the additional tuning NOPs). 9. Only one display range of steady decimal point MHz rating is used. VI. PROCESS DESCRIPTION OF SOFTWARE IMPLEMENTATION This is 7-digit counter counting up to 35 MHz. The decimal point is after MHz digit. Power consumption with seven segment display is 2.5V/9mA or 3V/13mA or 5 V/35mA. Hardware is very simple, it contains: 1. PIC 16F84 2. 4051 (BCD -> 1 of 8 decoder) 3. 8 NPN low power Si transistors 4. 7-digit seven segment display 5. Some resistors, somecapacitors and two switching diodes. Both common cathode and common anode can be used. Software is written for common cathode display. For common anode displays it requires very slight software and hardware

Fig. 2 PIC 16F84A operated as a Frequency Counter

IV. 4051 DECODER USED IN FREQUENCY COUNTER This circuit is used in frequency counter as a decoder or multiplexer/de-multiplexer IC. In this research, this IC outputs the required BCD to 1 of 8 decoded values. The supply of

349


World Academy of Science, Engineering and Technology 42 2008

modification.
The counter uses internal prescaler of PIC as low byte of counter, TMR0 as middle byte and some register as high byte of counter. Timing loop values must be from 1 to 255. -Values for 4 194 kHz: T1 = 7 (rough timing loop), T2 = 3(timing loop), T3 = 2(fine timing loop). -Measuring period is 100000 us. [MHz], (fX is Crystal -Processor cycle is T = 4/ fX us frequency). -Number of processor cycles per measuring period: N = 100 000/T processor cycles N = fX x 100 000/4 = 25 000 x fX The program of the whole process is done as following steps: 1. Start measurement, 2. Pre-code decimal value of digit to segments, 3. If the 5th digit set decimal point, 4. Output to Port B, 5. Output digit number to Port A (numbers from left to right be 6543210), 6. Test TMR0 overflow bite, if YES increase Timer H, 7. Leave digit to light, 8. Increase digit number, 9. If


Política de privacidad