- Open Access
- Total Downloads : 112
- Authors : Akinkuade Shadrach Tunde , Olanipekun Mabel Usunobun
- Paper ID : IJERTV6IS110093
- Volume & Issue : Volume 06, Issue 11 (November 2017)
- Published (First Online): 14-11-2017
- ISSN (Online) : 2278-0181
- Publisher Name : IJERT
- License: This work is licensed under a Creative Commons Attribution 4.0 International License
Design and Construction of an Autorange Digital Frequency Meter using a Microcontroller
Akinkuade Shadrach Tunde Science Technology Department The Federal Polytechnic
Ado-Ekiti, Nigeria
Olanipekun Mabel Usunobun
Electrical and Electronics Engineering Department Federal University of Agriculture
Abeokuta, Nigeria
Abstract An autorange digital frequency meter was designed and constructed using AT89S52 microcontroller and a liquid crystal display (LCD). Periods of 1, 0.1, 0.01 and 0.001 seconds were internally generated in the microcontroller using timer 0 (T0); external clock pulses that were applied to T1 clock input of the microcontroller within any of the periods were counted in hexadecimal using timer 1 (T1) of the microcontroller which was configured as a 16-bit counter. The count was converted to Binary-Coded-Decimal (BCD) and American Standard Code for Information Interchange (ASCII) respectively and the result displayed as four-digit decimal number with appropriate unit on the LCD. The meter was designed and simulated with Proteus software, the source code was written in assembly language of 8051 using MIDE software which also generated the machine code. The machine code was burnt into the microcontroller using Topwin universal programmer. A TTL square wave signal obtained from MCP Lab electronics function generator, model SG 1634 N, was applied to a UNI-T digital storage oscilloscope (model UTD 2102 CEL) and the meter simultaneously. Frequency of the signal was increased in ten steps within 1 to 10 Hz, 10 to 100 Hz, 100 to 1000 Hz, 10 to 100 kHz and 100 kHz to
1 MHz ranges of measurement. Readings of the meter and oscilloscope were recorded for comparison; results showed that the maximum frequency the meter could measure was 416.5 kHz.
KeywordsAutorange; frequency; counter; time-base; hexadecimal; microcontroller
-
INTRODUCTION
Frequency is the rate of occurrence of a repetitive event with time. It is usually calculated as the ratio of the number of occurrence to the period of the event. It is inversely proportional to period of the event; frequency is measured in hertz (Hz) or cycles per second [1].
One of the numerous areas where measurement of frequency is important is in electric power generation, the frequency of an alternating current (ac) from a generator depends on the rotational speed of its alternator, and the frequency affects the impedance of any circuit in which it flows, so the frequency needs to be kept constant or between a narrow range to keep the load from deviating from the desired value and to prevent damage to mechanical systems in the generator [2]. In telecommunication, equipment such
as radio transmitters and receivers must be tuned correctly to comply with governments regulation [3], so their frequencies of operation need be monitored. Application of quartz crystal microbalance (QCM) used in determination of thickness of films in semiconductor industry depends of
frequency measurement [4], measurement of heart rate, a parameter that cannot be overlooked in medicine to determine fitness of individuals, involves frequency measurement. In science and engineering, it is often necessary to measure physical quantities, these quantities when converted to appropriate electronic signals can easily be measured with electronic measurement systems. One of the various methods of converting a physical quantity to an electronic signal involves generation of square waves whose frequency or period is proportional to the magnitude of the quantity. Many techniques of frequency measurement had been described, in the classical digital counter method explained by [5], a selected digital logic state is detected and counted, and a measure of frequency is determined by the number of complete cycles counted during a fixed time interval, determined by a time-base of the counter. According to [6], the classical methods for frequency measurement do not allow for fast response, they are complex and it is expensive to incorporate equipment whose operation is based on these methods in mechatronics systems. It is against this backdrop that the authors designed and constructed a frequency meter with the consideration that a reduction in circuitry will be made possible by using a microcontroller to implement the digital counter, time-base generator, gating and reset network, which are features of the classical method; the meter will be simple, reliable, accurate and economical since common errors associated with frequency measurement will be carefully and drastically reduced through debugging of the source code of the frequency meter.
-
DESIGN OF THE FREQUENCY METER
Timer 1 of the microcontroller, was made to operate as a 16-bit counter, it is capable of counting up to maximum value of FFFF16 which is equivalent to 6553510, as a result of this, a five-digit number 9999910 could not be held in the timer register. The number of digits to be displayed in each range of measurement was therefore limited to four, therefore 999910 is the maximum decimal number that can be displayed. A decimal point is placed anywhere between the digits to make the results be displayed in units, tens and hundreds. Pin 15 of the microcontroller was used to sense external clock pulses. Content of the timer 1 register increases by one whenever the logic state of the pin changes from 1 to 0.
The period of counting was controlled by timer 0 which has a 16-bit register. Maximum delay that can be generated by this timer is 6553510 machine cycles. The machine cycle
mc in AT89S52 microcontroller depends on the frequency f
of the crystal used in its circuit as:
mc = 12/f (1)
For a 12 MHz crystal that was to be used, the machine cycle would be 1s. Therefore, periods of 0.001s and 0.01s (1000 and 10000 mc) were generated using timer 0 only, whereas 0.1s and 1s were generated using timer 0 and another register to obtain multiples of 50,000 machine cycles (0.05 s).
-
CIRCUIT DIAGRAM
The circuit diagram of the frequency meter is shown in the Fig. 1.
-
OPERATION
Pulses to be counted are fed to pin 15 (P3.5 or T1 input) of the microcontroller.
-
The microcontroller generates a delay of 1 s within which the pulses are counted, it checks if there is an overflow in the timer 1 high register (TH1), if there is no overflow, it checks if the count is greater than 3E7h (99910); If the count is not greater than 3E7h, it is converted to Binary-Coded- Decimal (BCD), then to American Standard Code for Information Interchange (ASCII) and displayed as frequency in Hertz (Hz) as a whole number. However, if the count is greater than 3E7h, but less than 270Fh (999910), it is converted to BCD and ASCII and then displayed to three places of decimal in kilohertz (kHz).
-
If there is an overflow in TH1 within a period of 1 s
or the count is greater than 270Fh, the period of counting is reduced to 0.1 s and pulses are counted again; If there is no overflow in the counter and the new count is less than 270Fh, it is converted to BCD and then to ASCII and displayed to two places of decimal in kilohertz.
-
If the new count in (ii) is greater than 270Fh or there
is an overflow, the period is reduced to 0.01 s, pulses are counted again. If there is no overflow or if count is less than 270Fh, the result is displayed to one place of decimal in kilohertz after the count is converted to BCD and ASCII.
Generally, whenever there is an overflow in the timer 1 high register or the count is greater than the expected maximum value in a particular rang of measurement, the period is reduced by a factor of 10, position of decimal point is determined and the unit of measurement is adjusted appropriately.
-
-
MATERIALS AND METHOD
The frequency meter was constructed as shown in Fig. 1; the circuit was designed and simulated using Proteus software. Source code of the frequency meter was written in assembly language of Intel 8051 microcontroller and compiled using MIDE software. The program was burnt into an AT89S52 microcontroller using Topwin Universal Programmer. A Transistor-Transistor Logic (TTL) signal obtained from a signal generator (MCP Lab electronics Function Generator, model SG 1634 N) was applied simultaneously to the frequency meter and a digital storage oscilloscope (UNI-T, model UTD 2102 CEL). Frequency of the signal was gradually adjusted in each of the following range of frequencies: 1-10 Hz, 10-100 Hz, 100 Hz- kHz, 1 kHz-10 kHz, 10 kHz-100 kHz and 100 kHz-1 MHz, readings of the storage oscilloscope and the frequency meter were recorded.
-
RESULTS AND DISCUSSION
Results of measurement are shown in Tables 1 and 2. The meter measured frequency to the nearest whole number for frequencies between 1 and 999 Hz. In the frequency range of 1 to 10 Hz, the oscilloscope readings were in whole numbers, so no error was observed in the readings of the meter when compared with those of the oscilloscope. Measurement of frequencies below 6 Hz was possible with the meter but impossible with the oscilloscope. For frequencies above 10 Hz, readings of the oscilloscope were given to two places of decimal; consequently, errors in the readings of the readings of the meter compared with readings of digital oscilloscope varied between 0.03 to 1.4 % and 0.01 to 0.2 %, in the range: 10- 100 Hz and 100 Hz 1 kHz respectively. However the percentage error was very low between 1 to 10 kHz and 100 kHz to 1 MHz where the meter readings were to three places and one place of decimal respectively. Readings of the meter compared well with readings of the oscilloscope with minimum values of percentage error. Maximum frequency that could be measured with the meter was found to be 416.5 kHz. Counters in Intel 8051 families of microcontroller are synchronized with the internal clock, the maximum frequency they can measured is limited to 1/24 of the crystal clock, therefore the maximum frequency expected to be measured using 12 MHz crystal is 500 kHz.
Fig. 1. Circuit diagram of the meter
TABLE 1: READINGS OF THE METER IN 1-10 Hz, 10 – 100 Hz AND 100 Hz – 1 kHz RANGE OF FREQUENCIES
1
-10 Hz
10 Hz – 100 Hz
100
Hz- 1 kHz
Readings
(kHz)
Abs % error
Readings
(kHz)
Abs % error
Readings
(kHz)
Abs % error
Oscilloscope
Meter
Oscilloscope
Meter
Oscilloscope
Meter
–
1
–
10.11
10
1.088
101.03
101
0.030
–
2
–
20.30
20
1.478
204.98
205
0.010
–
3
–
30.04
30
0.133
301.02
301
0.007
–
4
–
40.05
40
0.125
401.20
401
0.050
–
5
–
50.06
50
0.120
504.24
503
0.246
6
6
0
60.14
60
0.233
604.16
604
0.026
7
7
0
70.03
70
0.043
699.50
700
0.071
8
8
0
80.27
80
0.336
806.19
806
0.024
9
9
0
90.03
90
0.033
903.15
903
0.017
10
10
0
100.15
100
0.150
–
–
–
TABLE 2: READINGS OF THE METER IN 1-10 kHz, 10 – 100 kHz AND 100 kHz – 1 MHz RANGE OF FREQUENCIES
1 kHz-10 kHz
10 kHz – 100 kHz
100 kHz- 1 MHz
Readings
(kHz)
Abs % error
Readings
(kHz)
Abs % error
Readings
(kHz)
Abs % error
Oscilloscope
Meter
Oscilloscope
Meter
Oscilloscope
Meter
1.33
1.332
0.150
10.92
10.92
0.00
100.23
100.3
0.070
2.05
2.046
0.195
20.19
20.18
0.05
204.92
204.9
0.010
3.06
3.059
0.033
31.02
31.02
0.00
301.93
301.9
0.010
4.06
4.062
0.049
41.07
41.07
0.00
400.09
400.1
0.003
5.03
5.026
0.080
50.47
50.47
0.00
–
–
–
6.09
6.089
0.016
60.39
60.39
0.00
–
–
–
7.10
7.103
0.042
70.49
70.49
0.00
–
–
–
8.03
8.032
0.025
80.33
80.32
0.01
–
–
–
9.09
9.088
0.022
90.33
90.33
0.00
–
–
–
10.09
10.09
0.000
101.08
101.08
0.00
–
–
–
-
CONCLUSION
The digital frequency meter was capable of use in measuring frequency of TTL signal from 1 Hz to 416.5 kHz. The circuit of the meter can easily be incorporated into systems to measure and provide readout of frequencies. With a modification of the source code, the meter can be made to measure other frequency-dependent quantities and display the results in expected units. Input signal conditioning circuit needs be added to the circuit to make the meter suitable for measuring real-world signals. Attempt will be madeto improve on this work in order to increase the accuracy of the meter and maximum frequency it can measure using the same microcontroller.
ACKNOWLEDGEMENT
This work was not supported financially by any organization; however the authors wish to acknowledge the support of Department of Science Technology, Federal Polytechnic, Ado Ekiti, Nigeria, for making the electronics laboratory available for use while carrying out this work.
REFERENCES
-
A. S. Moris, Measurement & Instrumentation Principles, 1st ed. Oxford: Butterworth-Heinemann, 2001.
-
A. Soundarrajan, S. Sumathi, and G. Sivamurugan, Voltage and frequency control in power generating system using hybrid evolutionary algorithms, 2011.
-
B. Stahlin, Introduction to Electronic Instruments and Measurements. 2004.
-
A. Khadeer, T. Mcloed, F. H. Schlereth, A. K. Mahabalagiri, J.T. Spencer and K. S. Sweder, Frequency Measurement for QCM Applications, in International Conference on Industrial Instrumentation and Control (ICIC), 2015, no. Icic, pp. 11401143.
-
Gupta B. J., Electronic Measurements & Instrumentation, 5th ed. Daiyaganj Delhi: S.K Kataria & Sons, 2006.
-
F. N. R. Murrieta, O. Y. Sergiyenko, V. V Tyrsa, D. B. Hernández, and
W. Hernandez, Frequency domain automotive sensors: resolution improvement by novel principle of rational approximation, pp. 13131318, 2010.