Rangkaian Frekuensi Counter Digital

Tags

a microcontroller system AT89c2051 and an LCD display we can create a digital frequency counter which can measure frequencies up to 250KHz. LCD is used LM16200.

LCD LM16200
LM16200 LDC Pic

Table LM16200.
Pin LCD LM16200

Scheme of frequency counter digital using AT89c2051 are as follows:
Frekuensi Counter DigitalSkema Rangkaian Frekuensi Counter Digutal

AT89c2051 to program, we use the Bascom 8051, the following programs Frequency caunter Digital Using AT89c2051:


'--------------------------------------------------------
' file: efy20fm24.BAS 25-12-05
' Frequency Meter Program using AT89c2051 micro controller
' written using bascom-51 from www.mcselec.com holland
' an embedded visual basic compiler for 8051 micro
' controllers
' by K.S.Sankar Web: www.mostek.biz
'------------------------------------------------------
' Connect the timer0 input P3.4 to a frequency generator
' with 24 mhz xtal accuracy ok upto 250khz
' define crystal speed and include file
$regfile = "89c2051.dat"
$crystal = 24000000
' define variables used
Dim A As Byte
Dim C As Long , D As Long
Dim Count As Word
Dim T0ic As Long
Dim Delayword As Word

' Initialize variables
Count = 0
T0ic = 0
D = 0
' initialize ports
P1 = 0
P3 = 255
' configure lcd display
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6 = P1.6 , Db7 = P1.7 , E = P1.3 , Rs = P1.2
Cls
'clear the LCD display
Lcd " EFY Freq Meter "
' define timer0
Config Timer0 = Counter , Gate = Internal , Mode = 1
'Timer0 = counter : timer0 operates as a counter
'Gate = Internal : no external gate control
'Mode = 1 : 16-bit counter
' set t0 internal interrupt
On Timer0 Timer_0_overflow_int
' interrupt will be generated on every 65536 count
Priority Set Timer0
Enable Interrupts
Enable Timer0

Counter0 = 0
'clear counter
Start Counter0
'enable the counter to count
Do
'set up a 1 sec accurate DO NOTHING loop
Enable Interrupts
'wait 1 as per BASCOM-51 is not accurate
For Delayword = 1 To 45440
Next Delayword
Disable Interrupts
C = Counter0
'get counter value
D = T0ic * 65536
Lowerline
C = C + D
T0ic = 0
Lcd " "
Lowerline
' show the frequency
Lcd "f=" ; C ; " Hz"
Waitms 255
Waitms 255
C = 0
Counter0 = 0
Start Counter0
're-start it because it was stopped by accessing the COUNTER
Loop

' timer0 int subroutine
Timer_0_overflow_int:
Rem timer0 overflow ( 65535 ) interrupt comes here
' increment the variable
Incr T0ic
Return
End
' end of program
' uses 1106 bytes of program memory


EmoticonEmoticon

Advertisement