17 Februari 2009

Frekuensi Meter Digital Menggunakan AT89c2051

Dengan sebuah sistem mikrokontroler AT89c2051 dan sebuah display LCD kita bisa membuat sebuah frequensi meter digital yang bisa mengukur frekuensi sampai dengan 250KHz. LCD yang digunakan adalah LM16200.

an35-lcd2

an35-pinlm

Rangkaian Frekuensi Meter Digital Menggunakan AT89c2051 adalah sebagai berikut:

an35-schematic

untuk memprogram AT89c2051, kita menggunakan BASCOM 8051, berikut ini flowchart program Frekuensi Meter Digital Menggunakan AT89c2051:

an35-flow

Source Code Frekuensi Meter Digital Menggunakan AT89c2051, adalah sebagai berikut:

'--------------------------------------------------------
' 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

Download source code, rangkaian lengkap Frekuensi Meter Digital Menggunakan AT89c2051 | Sumber

Ikuti Blog ini

Langganan

Mau dapet Update-an Blog ini lewat e-mail? Masukkin aja alamat Email kamu disini:

Dikirim Oleh FeedBurner