Вы находитесь на странице: 1из 30

Abstract

So many electronic circuits use one form of oscillator or the other each characterized by their
frequencies of oscillation. Hence the need for a portable device which can count the number
of oscillations for any waveform and output the corresponding value on a display. This device
is always referred to as a frequency counter or meter. 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. This
frequency counter has to count the number of cycles per second of an incoming signal. Hence
we need a device to count. In electronics circuits, counter ICs are available for counting.
These IC's can count the input pulses. The count is given as coded output from the IC (in
binary form or BCD form). The count must be converted into decimal digit to be understood
by human beings. More number of IC's can be cascaded to increase the number of digits. The
number of digits required for the counter to display the count value depends on the
application and the accuracy needed. In our design we use a single 4 bit BCD high-speed
CMOS counter chips. One chip is used for one digit and we use 7 similar ICs to get seven
digit counter. Also we use CMOS decoder IC to decode the BCD output of the counter to
drive 7 segment displays.

CHAPTER ONE
1.0

INTRODUCTION

A frequency counter is a measuring equipment used to measure the frequency or number of


cycles per unit time of an input signal. Frequency counter can be of analogue type or digital
type. In analogue type, the frequency is indicated on calibrated a needle type meter. Whereas,
a digital frequency counter shows the frequency reading on a digital display. Digital
frequency counter are easy to read and reading error is minimum. There are so many other
advantages for a digital frequency counter. Nowadays analogue frequency counter are used to
measure Low frequencies only.
The frequency measurement is one of the most important things in radio construction.
Without it you will be unable to set desired frequency in your receiver (and in transmitter
too), without it you will be unable to monitor frequency drift etc sometimes, frequency
counter can be used to verify whether the oscillator works and ensures the stability of the
generator.
This project consist of a power supply section which power the ADC (Analog to digital
converter) and the ADC sends out the decoded signals to seven segment display. Digital
frequency counter is being used for wide range of application. Digital frequency counter
extensively uses digital circuits and hence a fairly good knowledge of digital circuits is
required to understand the operation of the frequency counter.
However, this project has being written in such a way that a person who is not familiar with
electronic circuit knowledge can assemble experimental digital frequency counter that counts
from (10Hz 9990Hz).
The objective of this project work is to construct a frequency meter that can be used to
measure AC frequency and can be mounted on panel to monitor generator output frequency
and other fixed apparatus

CHAPTER TWO
2.0

LITERATURE REVIEW

Frequency measurement is an indispensable practice in the field of Electrical Electronics


Engineering. Without it, it will be difficult to know the frequency by which your equipment is
operating on.
Digital frequency counters by Prof. T.K Mani (VU21Y1). The counter circuit is designed
using discrete digital ICS. The number of ICS is more in the design. The circuit is capable of
counting up, counting down and also capable of programming initial value. This feature is
often required if you want to know the frequency of a station tuned by using your heterodyne
receiver. The counter chip used is 74HCT190. This IC consumes less power and count up to
say 50 MHz. if you are not in a position to get HCT version you can replace the same with
any family of 74 series. The decoder IC is CD 4511. This Cmos IC consisting of catch,
decoder, seven segment LED driver.
Digital frequency counters by valentine Grozder (Ru3AEP) 1973. This unit is made
on KI55 (SN74) TTL chips. They are rather cheap and work up to 30 MHZ, which is
sufficient for turning all harm radio and broadcasting SW equipment. To
extent frequency range, optional pre-divider may be connected to the input. This divides the
input frequency by 10. The latter is made on k500 ECL-chips (ECL-abbreviated Emitter
coupled logic), which work up to 200 MHZ. To add all standard parts internal memory
triggers are introduce to make measurement more convenient and fast. If output indicator are
connected directly (Through corresponding decoders) to the counters, the digits are blinking
during measurement, and it is required to make addition time of indication during which
counter are idle. This reduces the ease of readout and speed of measurement. After the
counting time is finished, the information in triggers is updated by short pulse and the
counters are reset.

CHAPTER THREE
DEFINITION AND IDENTIFICATION OF COMPONENTS
(THEORY OF COMPONENTS USED)
3.0

RESEARCH METHODOLOGY

Basically, the research on this project was done both on the internet and on various computer
and Electrical/Electronics text books. Including some other electronics circuits design books.
We then constructed it on project board and tested its workability. We then transferred it on a
printed circuit board for proper construction.
COMPONENT

9V D.C battery

IN4007 Diode

02D47 Zener diode

C1815 Transistor

Resistor (1k and 330)

Black and Red probes

These devices mentioned above were only used at the power section of this project.

LM109H 7805; Voltage regulator. Analogue to Digital converter (ADC) which


converts measured quality from Analog to Digital.

PIC 16F84A was also gotten and a program was written into it which will serve as the

micro controller of the circuit.

The crystal oscillator 4MHZ is coupled to PIC which control the operation of the

micro controller.

We also got a 74LS47D BCD decoder which will decode the data from the micro

controller (PC) and give an output in the term which can be readily read from the display
unit. After the above mentioned research, we began to construct the project work.
As stated early, we employed a micro-controller chip (PIC 16F 84A). This was an empty
which we then programmed electronically to give a desired output based on the input.

3.2

STEPS TAKEN TO PROGRAM THE MICRO-PROCESSOR

1.

We got a computer system with a micro-chip. Laboratory environment (popularly


known as MPLAB)

2.

We began to write the soft ware

3.

After writing the software, we transferred it to wind PIC programmer environment.

4.

The wind pc programmer programmed the written micro processor

5.

We test run the program for error check.

3.3

COMPONENTS IDENTIFICATION AND VALUES

DC -

Battery 9V

D1

IN4007 Diode

D2

IN4007 Diode

X1

Crystal 4MHZ

R1

330

R2

1K

D3

02D47 zener diode

U1

PIC 16F 84A Micro Controller

U3

74LS47D BCD Decoder

U5, U6, U7 and U8

Seven Segment Display

A1

Analog Digital converter (ADC) DAC 08 (18 pins)

T1

Transistor C1815 (NPN)

U4

Regulator LM 109H (7805)

3.4

STEPS INVOLVED IN BUILDING THE CIRCUIT

1.

We acquired all the needed components

2.

We gathered all the material / equipment needed such as soldering iron, soldering
lead, multimeter and Vero board.

3.

The circuit was built on a bread board and it was working.

4.

After steps (3) above yielded a success we transferred the circuit to a Vero board.

5.

Open circuit, short circuit and continuity test were carried out to eliminate all kings of
error.
5

6.

The entire circuit was coupled properly in a plastic white casing; hence the result gave
positive outcome.

3.5

DEFINITION OF TERMS

Micro Controller: A micro controller unit (MCU) is a small computer on a single integrated
circuit consisting a relatively simple CPU combined with support functions such as a crystal
oscillator, timers, watch dog, serial and analog etc.
Neither program memory in terms of NOR flash or OTP ROM is also often included on
chips, as well as a typically small red/white memory. The first simple chip microprocessor
was the 4 bit Intel 4004 released in 1971 with other more capable processors available over
the next several years.
However, all required chip(s) to implement a working system, raising total system lost and
making if impossible to economically computerized appliances.
ANALOG TO DIGITAL CONVERTER
The ADC 0803 family is a series of CMOS 8-bit successive approximation A/D converters
using resistive ladder and capacitive array together with auto-zero comparator. These
converters are designed to operate with microprocessor.

Controlled buses using

minimum of external circuitry. The 3-state output data lines can be connected directly to the
data bus. The deferential analog Frequency input allows for increased common-mode
rejection and provides a means to adjust the zero-scale offset.
Additionally, the frequency reference input provides a means of encoding small analog
frequency to the full 8 bits of resolution.
SEVEN (7) SEGMENT DISPLAY
The 7 segment display is very common components of digital devices, it is good to be
familiar with the driving circuits behind them and the 4511 is a example of a typical driver
IC. Its operating principle is to improve a four bit BCD (Binary Coded Decimal) value and
energize the proper output lines to form the corresponding decimal digit on the 7-segment
LED display. The BCD input is designed A, B, C and D in order from least significant to
most significant outputs are labeled a, b, c, d, e, f and g each letter corresponding to a
standardized segment designation for 7-segment displays of course since each C6D segment
requires its own dropping resistor, we must use seven 470 resistors place in series between
the 4511s output terminals and the corresponding terminals of the display unit.
The project work has four sections which are the power supply section, powers the ADC and
regulates voltage of 5V and also the voltage is used to power the whole circuit. The ADC
6

translates the analog data to binary code requires for data processing and transmission in the
control system. The micro controller processes the data received from the ADC and sends
it to the decoder. The decoder decodes the processed signal from the micro processor and
displays it on the seven segment display unit as an output frequently.
DIODE
This is a two terminal device consisting of a PN junction forward either in Ge or Si crystal.
Its circuit symbols are shown below.

Cathode

Anode

Circuit symbol of a Diode

The P and N type regions are referred to as anode and cathode respectively. In the fig (3.7)
the arrow head indicates the conventional direction of current flow when forward based. It is
in the same direction in which hole flow takes place. Commercial available diode usually
have some means to indicate which lead is P and which lead is N. standard notation consist of
type numbers proceeded by N such as IN240 and IN1250. In this project work, the diode
used is IN4007.
CAPACITOR
It is an electronic device constructed by two parallel conductive plates, separated by an
insulated material called dielectric. A charged capacitor is called temporary battery. The
amount if charge of a capacitor can store per unit frequency across its plate and its
capacitance denoted by C. Its capacitance is a measure of a capacitor ability to store charge. It
is expressed by the formula C = QIV, where c is the capacitance and its unit is Farad (F)
while the coulomb is the unit of electrical charge represented by q. Most capacitors value
used in electronics are rated in micro-farad (f) or in Pico farad (pf). It can be seen that a
capacitor is more complicated than that of a resistor. The current is not simply proportional to
the frequency but rather to the rate of shapes and sizes. The basic construction is simply two
conductors near each other but not touching. In fact the simplest capacitors are just that for
greater capacitance, more area and greater spacing is needed. The usual approach is to place
some conductor into a tin insulated material called dielectric. Other popular types of
capacitor, are thin ceramic, waters, metal coils with oxide insulator (i.e. electrolytic and
materialized mica) each of those types of capacitors has unique properties.

220F
25v
101F
63v

Schematic Diagram
Electrolytic Capacitor

RESISTOR
Resistors are one of the most common components in an electronic current. The basic
operation is to limit the flow of current in the circuit.
HOW TO READ RESISTOR COLOUR CODE

Black
0

Brown
1

Red
2

Orange
3

Yellow
4

Green
5

Blue
6

Violet
7

Green
8

White
9
8

2nd band

Tolerance band

Third band

First band

First find the tolerance band, it will typically be gold (5%) and sometimes silver (10%).
Starting from the other end, identify the first Band write down the number associated with
the colour. In this case Brown is 1 (one), now read the next, here it is black so write down a
o next to the six. (You should have 10 so far) now read the third or multiplier exponent
band is Black (for zero) dont write any zero down. If the multiplier exponent band is gold
move the decimal point one to the left. If the multiplier exponent band is silver move the
decimal point two places to the left. If the resistor has one more band past the tolerance band,
it is a quantity band.
BS 1852 CODING FOR RESISTOR VALUES
BS 1852 (British standard 1852) the letter R, is used for ohms and (m) and placed where
the decimal point would go. At the end is a letter that represents tolerance where m = 20%,
k=10%, j=5%, a=2% and f=1%, D=0.5%, C=0.25%, B=0.1%
REGULATOR
This is an electronic device use in regularizing linear voltage (i.e. D.C voltage). They
comprises y Vin GND, and Vout A simplified diagram is given below

Vout

Vin
GND
Schematic diagram of a regulator
Voltage regulator, are made up of two typed;
1.

Transistor

2.

Zener diode
9

The transistorize type of regulator are: 7805, 7806, 7803, 7809, 7812, 7815, 7818 and 7824.
This transistorize regulators are known as a positive voltage regulators, while those that start
with 79xx are known as negative frequency regulators. The zener diode regulator is in form
of a diode. A simplifies zener diode is shown below.

Schematic diagram of a Zener Diode


In this project, we used a transistorized voltage regulator which is 7805. The 0.5v is a real
voltage of the regulator while the 78 is the family name of the regulator. When an input
voltage of 9v is forward bias into a transistorized voltage regulator, VIN as the name implies
or the number 7805, Vout is green 5v.

10

CHAPTER FOUR
4.0

CONSTRUCTION BASED ON DIFFERENT SEGMENTS

This project has five stages as shown in the block diagram below

POWER
SUPPLY

ADC

Processor

Bus decoder

Block diagram of a digital voltmeter using microprocessor with seven segment


SEVENdisplay.

SEGMENT
DISPLAY
POWER SUPPLY: this section of the circuit has to do with the power available for
utilization in the circuit. During the construction stage, we used AC rectified circuit to
achieve our aim. For the portability sake, and the nature of our project, it requires DC source.
Hence we bypass the AC with DC supply (9V).
VOLTAGE REGULATION STAGE
The output from DC is still 9v which goes to the 7805 is a regulator which regulates the
input 9v and gives output of 5v because the ADC and PIC 16f 84A requires 5v for its
powering.

ANALOG TO DIGITAL CONVERTER (ADC)


IC-1 is an ADC which converts the input analog to digital through the reference point. This
measures the average value of the input frequency over a fixed integrated period. The basic
idea of this device is to pulse width proportional to the analog input frequency by making the
time comparison between two integration. The first integration is the unknown input analog
signal, it proceeds for a fixed interval of time equal to the maximum number of count times
the clock period. The input is then switch to a known reference frequency. D3 is a Zener
Diode which regulates the frequency into the ADC.
MICRO CONTROLLER
U1 is a micro controller which decodes the out coming data from ADC and processes the
incoming data so as to give an output to BCD7 segment decoder.
SEVEN SEGMENT BCD DECODER

11

The BCD7 segment decoder decodes the binary coded decimal unit. It receives its input from
the processor via the 4 pins labeled ABCD and give a corresponding output from 7pins OA,
OB, OC, OD, OF and OG which tarries with 7 segment of the display.
SEVEN SEGMENT DISPLAY
The seven segment display unit. One common requirement for many digital devices is a
visual numeric display and this is used in this project to display the numeric value of the
measured frequency.
4.1

RESULT ANALYSIS

Below are the analyses of the result gotten when tests were carried out during and after the
construction of this project
-

Open circuit tests:

This is a test conducted to check whether there is a break or cut in any of the components
and between the jumpers. The result obtained.
Note: The entire test was carried using multimeter. We first tested the two resistors R1 and
R2. R1 gave readings which correspond with manufacturers value. R2 was tested; it gave a
value that was too low compared with the original value of the manufacturer.
The same open circuit test was carried among the legs of the ADC, BCD and seven
segment display.
-

Short circuit test:

This test is carried out to ensure that the component do not bridge with one another when
they are not supported to do so. When we conducted this test
on the capacitor, there was no reading in the meter i.e. the meter indicates zero, which meant
that it is alright.
-

Continuity test:

This test was conducted after building the circuit. It was carried out on the legs or terminals
of the components in contact with probe of the multimeter and the other probe on the body of
the Vero board. The multimeter gives a reading of high value; it shows the continuity is
sound. But if the meter shows zero reading, this implies that there is no continuity between
the terminals tested.

12

4.2

TEST CONDUCTED AFTER COUPLING

We plugged the probes of the instruments on a 13amps socket outlet and we obtained a
reading of 50HZ. We further built an astable multivibrator with a varying frequency. The
output was connected to the probes of our meter, frequency was varied and the reading was
compared to a multimeter testing.
This project comprises power supply (D.C 9V) which powered the ADC (Analogue to digital
converter). The ADC converts the analogue waveform to digital numbers and sent out the
signal to micro controller where the program is written according to the aim of the project.
Then, the micro controller releases the information to seven segments display which counts
the frequency of the input signal.

13

PRINCIPLE OF OPERATION
This project comprises power supply (D.C 9V) which powered the ADC (Analogue to digital
converter). The ADC converts the analogue waveform to digital numbers and sent out the
signal to micro controller where the program is written according to the aim of the project.
Then, the micro controller releases the information to the BCD decoder via seven segment
display which shows the frequency of the input signal.
4.5

THE EXECUTED PROGRAM

;FREQUENCY COUNTER BASE ON MICROCONTROLLER PIC 16F84A


org 0h
sjmp start
;
org 0bh ; address interrupt for timer0
ljmp Timer_Interupsi0 ; long jump to timer interrupt 0 TF0
;
start: call ResetRAM
call Init_LCD
AgainD:call lcd_demo
jnb button,$
;
setb P2.0; mode no filter TCS230
clr P2.1 ; mode no filter TCS230
clr P2.2 ; output enable TCS230
call init_lcd
call init_interupsi_Timer0
;
call LCD_Flow
Forever:
call DisplayFlowRate
14

jb button, Forever
jnb button,$
call lcd_Search
call ldelay
call init_lcd
call LCD_maxFLow
Finish:
call DisplayFlowRateMax
call stopcounter
jb button,Finish
jnb button,$
call resetcounter
sjmp start
;
DisplayFlowRate:
mov DataFlowRateL,NewDataL
mov DataFlowRateH,NewDataH
;
call Hex16toBCD
;
mov R3,#086h
call write_inst
mov R3,tenthousands
call write_data
;
mov R3,#087h
call write_inst
mov R3,thousands
call write_data
;
mov R3,#088h
call write_inst
mov R3,hundreds
call write_data
;
15

mov R3,#089h
call write_inst
mov R3,tens
call write_data
;
mov R3,#08ah
call write_inst
mov R3,ones
call write_data
ret
;
DisplayFlowRateMax:
call SearchingMax
;
mov DataFlowRateL,DataCounter_MaxL
mov DataFlowRateH,DataCounter_MaxH
;
call Hex16toBCD
;
mov R3,#0c6h
call write_inst
mov R3,tenthousands
call write_data
;
mov R3,#0c7h
call write_inst
mov R3,thousands
call write_data
;
mov R3,#0c8h
call write_inst
mov R3,hundreds
call write_data
;
mov R3,#0c9h
16

call write_inst
mov R3,tens
call write_data
;
mov R3,#0cah
call write_inst
mov R3,ones
call write_data
ret
;
;==========================================================
;Subroutine Hex16toBCD
;===========================================================
;To convert hex 16 bit to 5 digit decimal
;input Data 8 High byte = R1
;input Data 8 Low byte = R2
;
;Output tenthousands = R7
;Output thousands = R6
;Output hundreds = R5
;Output tens = R4
;Output ones = R3
;
;Contoh: 1A2C h ----> 06799 d
;=======================================================
Hex16toBCD:
ANL PSW,#11101111b ; Aktivasi bank 1
MOV R1,DataFlowRateH; MSByte
MOV R2,DataFlowRateL; LSByte
MOV R3,#00D
MOV R4,#00D
MOV R5,#00D
MOV R6,#00D
MOV R7,#00D
17

MOV B,#10D
MOV A,R2
DIV AB
MOV R3,B ;
MOV B,#10 ; R7,R6,R5,R4,R3
DIV AB
MOV R4,B
MOV R5,A
CJNE R1,#0H,HIGH_BYTE ; CHECK FOR HIGH BYTE
SJMP ENDD
HIGH_BYTE:
MOV A,#6
ADD A,R3
MOV B,#10
DIV AB
MOV R3,B
ADD A,#5
ADD A,R4
MOV B,#10
DIV AB
MOV R4,B
ADD A,#2
ADD A,R5
MOV B,#10
DIV AB
MOV R5,B
CJNE R6,#00D,ADD_IT
SJMP CONTINUE
ADD_IT:
ADD A,R6
CONTINUE:
MOV R6,A
DJNZ R1,HIGH_BYTE
MOV B, #10D
18

MOV A,R6
DIV AB
MOV R6,B
MOV R7,A
ENDD:
Mov A,R3
Add A,#30h
MOV ones,A
;
Mov A,R4
Add A,#30h
Mov tens,A
;
Mov A,R5
Add A,#30h
Mov hundreds,A
;
Mov A,R6
Add A,#30h
Mov thousands,A
;
Mov A,R7
Add A,#30h
Mov tenthousands,A
ANL PSW,#11100111b ;Aktivasi Bank 0
ret
;============================================================
;Subrutine Timer_Interupsi0
;===================================================
;This subruoutine is to give an interruption and will overflow
;every 0.05 second or 50000 u second.
;and data that loadee is 65.536-50.000=15536 d = ( 3CB0h )
;B0 h loaded to TL1 and data 3C loaded to TH1
;
;Each this subroutine read, pencacah20 will decrement till Pencacah20=0
19

;this will happen every 20 X 50000 uS = 20 X 0,05s = 1 s,and then


;subrutine updatedata-stopcounter-savedatacounter
;dan resetcounter will call.
;==========================================================
Timer_Interupsi0:
mov tl0,#0B0h
mov th0,#03ch
djnz Count10,EndInterupsi
mov Count10,#20
call UpdateData
call StopCounter
call SaveDataCounter
call ResetCounter
EndInterupsi:
reti
;
;=====================================================
;Subrutine Init_interupsi_timer0
;=====================================================
;This subroutine is used to initiate RAM low byte and RAM high byte
;Initiate mode timer: timer 0 is functioned as timer 16 bit mode 1
;timer 1 is functioned as counter 16 bit mode 1
;Initiate register counter TL0 dan TH0: with data 3CB0h so counter will over
;flow every 0,05 second
;Initiate register counter TL1 dan TH1: with data 0000h so counter
;start rock and roll in start condition 0000
;Initate Timer0 Interrupt
;=====================================================
Init_interupsi_Timer0:
mov DataRamCounterL,#30h
mov DataRAMCounterH,#50h
mov Count10,#20
;Initiate for counter down 10 x 0.05 = 0.5 second
mov tl0,#0B0h
mov th0,#03ch
20

mov tl1,#00h
mov th1,#00h
Mov TMOD,#01010001b
;timer0 = as timer 16 bit, timer1 = as counter16 bit
setb ET0 ; Enable timer 0 interruption
Setb EA ; Master Enable All Interuppt
setb TR0 ; start rock and roll timer 0
setb TR1 ; start rock and roll timer 1
ret
;
UpdateData:
mov NewDataL,TL1
mov NewDataH,TH1
ret
;
StopCounter:
clr TR0
clr TR1
ret
;
;=======================================================
;Subrutine Savedatacounter
;=======================================================
;This subruoutine is to save data to register counter 16 bit TL1 and TH1
;Data register TL1 is saved in RAM with address 30h s/d 4fh
;Data register TH1 is saved in RAM with address 50h s/d 6fh
;this subroutine will be called every timer 0 over flow each 20x 0.05 second = 1second
;after data is saved than address RAM will increment
;
;Index Transfer Data : mov @R0,Data1
;

mov Data2,@R0

; Example:
;

org 0h

mov R0,#30h

;start:mov DataADC,P2 ;gets data from ADC


21

mov @R0,DataADC ; saves data ADC in addresss 30h

inc R0 ; increment, R0:= R0 + 1, to save the next data

call delay ; next address is 31h

sjmp start

;======================================================
SaveDataCounter:
mov R0,DataRamCounterL
mov @R0,TL1
mov R1,DataRAMCounterH
mov @R1,TH1
inc DataRAMCounterL
inc DataRAMCounterH
mov A,DataRAMCounterL
cjne A,#50h,QuitSDC
mov DataRamCounterL,#30h; Reset to base Address 30h
mov DataRamCounterH,#50h; Reset to base Address 50h
QuitSDC:
ret
;
ResetCounter:
mov TL1,#0
mov TH1,#0
Setb TR0
Setb TR1
ret
;
ResetRAM:
mov R1,#64
mov R0,#30h
NextRam:mov @R0,#0
inc R0
djnz R1,NextRam
ret
;
delay: mov R6,#25
22

del1: mov R5,#255


djnz R5,$
djnz R6,del1
ret
;
ldelay: mov R7,#30
ldel1: call delay
djnz R7,ldel1
ret
;==========================================================
; Subrutine SearchingMax ( Oleh: Triwiyanto )
;==========================================================
;This subroutine is to search data 16 bit betwen 30 data
;with metode, to compare data betwen now and next data
;RAM have capacity ony 1 byte so low byte will be saved to 30h .. 40h
;and high byte will be saved on 50h..61h
;by using the algorith from high programmming language then :
;===========================================================
;DataMax:=DataNext[0]
;for i:=1 to 30 do
; begin
; if DataNext[i] > DataMax then DataMax := DataNext[i]
; end
;=======================================================
;How to detect if a data is bigger then others, is
; by using instruction SUBB A,Data and JNC Label
; for example A=19, Data=20 then C = 1
;

A=21, Data=20 then C = 0

;=======================================================
SearchingMax:
mov R7,#30
;number address ram is 2 x 30 address
mov R0,#30h
mov R1,#50h
mov DataCounter_MaxL,@R0
23

mov DataCounter_MaxH,@R1
NextData:
inc R0
inc R1
mov DataCounter_NextL,@R0
mov DataCounter_NextH,@R1
;
mov A,DataCounter_NextL
clr C
subb A,DataCounter_MaxL
mov A,DataCounter_NextH
subb A,DataCounter_MaxH
;
jnc SaveDataCounterMax
djnz R7,NextData
Sjmp QuitS
SaveDataCounterMax:
mov DataCounter_MaxL,DataCounter_NextL
mov DataCounter_MaxH,DataCounter_NextH
djnz R7,NextData
QuitS: ret
;
init_lcd:
mov R3,#dispclr
acall write_inst
mov R3,#funcset
acall write_inst
mov R3,#dispon
acall write_inst
mov R3,#entrmod
acall write_inst
ret
;
Write_inst:
Clr RS

; mode write instruction


24

Mov PortLCD,R3 ; D7 s/d D0 = P0 = R1


Setb EN

; EN = 1 = Enable data

Acall delay

; calldelay time

Clr EN

; EN = 0

ret
;
Write_data:
Setb RS

; mode write instruction

Mov PortLCD,R3 ; D7 s/d D0 = P0 = R1


Setb EN

; EN = 1

Acall delay

; call delay time

Clr EN

; EN = 0

ret

;
LCD_Demo:
mov dptr,#tulisDemo; DPTR = [ tulisan1 ]
mov r7,#16 ; R3=16,Number character to display
mov r3,#080h ; R1=80h,character position row=1,col=1
acall write_inst
;
Demo: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r3,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r7,Demo ;R3=R3-1,jump to tulis1 if R3 = 0
ret
;
LCD_Flow:
mov dptr,#tulisFlow; DPTR = [ tulisan1 ]
mov r7,#16 ; R3= 16, Number character to display
mov r3,#080h ;R1= 80h,character position row=1, col=1
acall write_inst
Flow: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r3,A ; R1 = A
25

inc dptr ; DPTR = DPTR +1


acall write_data
djnz r7,Flow ; R3 = R3-1,jump to tulis1 if R3=0
ret
;
LCD_Search:
mov dptr,#tulisSearch; DPTR = [ tulisan1 ]
mov r7,#16 ; R3=16,Number character to display
mov r3,#080h ;R1=80h,character position row=1,col=1
acall write_inst
;
Search:clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r3,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r7,Search ; R3 = R3-1,jump to tulis1 if R3=0
ret
;
LCD_MaxFlow:
mov dptr,#tulisFlow; DPTR = [ tulisan1 ]
mov r7,#16 ;R3=16,Number character to display
mov r3,#0c0h;R1=80h,character position row=1, col=1
acall write_inst
MaxFlow:
clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r3,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r7,MaxFlow ;R3=R3-1,jump to tulis1 if R3=0
ret
;
TulisDemo:
DB 'Spirometer 89s51'
26

TulisFlow:
DB 'FLowR: ml/s'
TulisSearch:
DB 'Searching...Max '
;
end

27

CHAPTER FIVE
PROBLEM ENCOUNTERED DURING THIS PROJECT
The major problem encountered during this project was programming the micro-processor
but at the end, through guidance from a colleague we were able to program the chip.
CONCLUSION
The aim of the project was achieved. i.e.; the various test carried out and results obtained
(measurement carried out and results obtained) demonstrate that the digital frequency counter
measures the frequency of voltage from a signal source using a digital frequency meter with
microcontroller and a seven segment display.
RECOMMENDATION
This project; experimental digital frequency counter is recommended for measuring voltage
frequency because it is reliable and easy to operate and to be mounted on panel to monitor
generator output frequency and other fixed apparatus.

28

REFERENCE
Adam, o. An Introduction to Micro computer volume one Basic concepts: 2 nd Edition
1980.
Horowitz, p and Hill. W. The Art of Electronics Cambridge. Cambridge University press,
2004.
Hughes, E. Electrical and Electronics Technology.
Theraja, B.L and Theraja, A.K A Text book of Electrical Technology New Delhi; Rajindra
and Ravindra press, 2003.
Mosbys Medical Dictionary. 8th Edition 2009, Elsivier.
Pic 16F84A data sheet 18pin enhanced flash / EEPROM 8-Bit micro controller, micro chip
Technology incooperated, 2001.
http:// www.simple.wikipedia.org/wiki/ frequency counter.
http:// www.encyclopidia2. the free dictionary.com / digital frequency counter.
http:// en.wikipedia.org/wiki/seven segment display
http:// www.dnate.chindia.com

29

30

Вам также может понравиться