Kontroler untuk PLL MC145151 + Sorce Code

kali ini penulis memposting projeck lama yaitu kontroler PLL yang mengunakan IC MC145151, projeck ini sudah beberapa kali penulis buat dan dijual ke teman-teman penulis. oke langsung saja berikut rangkayan dalam simulasi ISIS Proteus 😀 mc141515_isis berikut kontroler yang sudah dalam satu PCB dengan PLL MC145151 😀 maaf kalo yg ini penulis gak bagi2 layout hehe 😀 foto0483 OK langsung saja kalo yg mau nyoba membuat nya penulis sertakan koding nya, 😀 tingkat keberhasilan nya tergantung dasar kemampuan masing2 yg mencoba nya hehe 😀

$regfile = "m8def.dat"
$crystal = 1000000

Config Lcdpin = Pin , Db4 = Portd.2 , Db5 = Portd.3 , Db6 = Portd.4 , Db7 = Portd.5 , E = Portd.1 , Rs = Portd.0
Config Lcd = 16 * 2

Deflcdchar 0 , 32 , 4 , 2 , 31 , 2 , 4 , 32 , 32
Deflcdchar 1 , 32 , 4 , 8 , 31 , 8 , 4 , 32 , 32

Cmd_up Alias Pind.6
Cmd_en Alias Pind.7
Cmd_dw Alias Pinb.7
Swt_lc Alias Pinb.6

Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Config Portb.3 = Output
Config Portb.4 = Output
Config Portb.5 = Output

Config Portc.0 = Output
Config Portc.1 = Output
Config Portc.2 = Output
Config Portc.3 = Output
Config Portc.4 = Output
Config Portc.5 = Output

Config Cmd_up = Input
Config Cmd_en = Input
Config Cmd_dw = Input
Config Swt_lc = Input

Dim Pll_freq As Word
Dim Pll_eram As Eram Word

Dim Is_set As Byte
Dim Is_lock As Bit

Cursor Off Noblink
Cls

Pll_freq = Pll_eram
Is_set = 0
Is_lock = Not Swt_lc

Gosub Freq_limit
Gosub Write_mc145151
Gosub Write_lcd

Locate 2 , 16
Lcd Chr(0)

Locate 2 , 1
Lcd Chr(1)

Do
 Debounce Cmd_up , 0 , Freq_up , Sub
 Debounce Cmd_en , 0 , Freq_en , Sub
 Debounce Cmd_dw , 0 , Freq_dw , Sub

 If Swt_lc <> Is_lock Then
 Is_lock = Swt_lc

 If Is_set = 0 Then
 If Is_lock = 1 Then
 Locate 2 , 4
 Lcd " PLL LOCK "
 Else
 Locate 2 , 4
 Lcd "PLL UNLOCK"
 End If
 Else
 Locate 2 , 4
 Lcd " SET FREQ "
 End If
 End If
Loop
End

Freq_up:
 If Is_set = 1 Then
 Do
 Pll_freq = Pll_freq + 1

 Gosub Freq_limit
 Gosub Write_lcd

 Waitms 200
 Loop Until Cmd_up = 1
 End If
Return

Freq_dw:
 If Is_set = 1 Then
 Do
 Pll_freq = Pll_freq - 1

 Gosub Freq_limit
 Gosub Write_lcd

 Waitms 200
 Loop Until Cmd_dw = 1
 End If
Return

Freq_en:
 If Is_set = 1 Then

 Pll_eram = Pll_freq

 Gosub Write_lcd
 Gosub Write_mc145151

 Is_set = 0
 Is_lock = Not Swt_lc
 Else
 Locate 2 , 4
 Lcd " SET FREQ "
 Is_set = 1
 End If
Return

Freq_limit:
 If Pll_freq > 1100 Then Pll_freq = 700
 If Pll_freq < 700 Then Pll_freq = 1100
Return

Write_lcd:
 Dim S1 As String * 3
 Dim S2 As String * 1
 Dim Sf As String * 5
 Dim Sl As Byte

 Sf = Str(pll_freq)
 Sl = Len(sf)

 If Sl = 3 Then Sf = " " + Sf

 S1 = Left(sf , 3)
 S2 = Right(sf , 1)
 Sf = S1 + "," + S2

 Locate 1 , 1
 Lcd "FREQ"

 Locate 1 , 7
 Lcd Sf

 Locate 1 , 14
 Lcd "MHz"

 Erase S1
 Erase S2
 Erase Sf
 Erase Sl
Return

Write_mc145151:
 Dim Con As Byte
 Dim Root As Word
 Dim Datapll(12) As Byte

 For Con = 0 To 11
 Root = 2 ^ Con
 Root = Pll_freq And Root
 If Root > 0 Then
 Datapll(con + 1) = 0
 Else
 Datapll(con + 1) = 1
 End If
 Next Con

 Ddrb.0 = Datapll(1)
 Ddrb.1 = Datapll(2)
 Ddrb.2 = Datapll(3)
 Ddrb.3 = Datapll(4)

 Ddrb.4 = Datapll(5)
 Ddrb.5 = Datapll(6)
 Ddrc.0 = Datapll(7)
 Ddrc.1 = Datapll(8)

 Ddrc.2 = Datapll(9)
 Ddrc.3 = Datapll(10)
 Ddrc.4 = Datapll(11)
 Ddrc.5 = Datapll(12)
Return

ini punyanya mas noik efem yg berhasil membuat nya 😀 noik fm

Iklan
Perihal

Pemancar FM, Penerima FM, Microcontroler

Ditulis dalam Microcontroller, Pemancar FM, Uncategorized
%d blogger menyukai ini: