Penulis Topik: kontroler untuk MC145151, dan bisa juga dipake untuk veronika  (Dibaca 2150 kali)

0 Anggota dan 1 Pengunjung sedang melihat topik ini.

Offline purwanto-amm

  • Administrator
  • Hero Member
  • ********
  • Tulisan: 1066
  • Nikola Tesla
    • purwanto-apriana
kontroler untuk MC145151, dan bisa juga dipake untuk veronika
« pada: Maret 11, 2012, 07:47:00 PM »



Codeing BascomAVR
Kode: [Pilih]
$regfile = "M8def.dat"
$crystal = 8000000

$hwstack = 32
$swstack = 10
$framesize = 40

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

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 Pinb.6 = Input
Config Pinb.7 = Input

Config Pind.2 = Input
Config Pind.3 = Input

Declare Sub Printlcd
Declare Sub Setmc145151

Const Minfreq = 8750
Const Maxfreq = 10800

Dim Eeromfreq As Eram Word
Dim Mainfreq As Word

Dim Isstereo As Bit
Dim Islock As Bit

Dim Flagset As Bit

Cursor Off Noblink
Cls

Mainfreq = Eeromfreq


If Mainfreq < Minfreq Then Mainfreq = Minfreq
If Mainfreq > Maxfreq Then Mainfreq = Maxfreq

Isstereo = Not Pind.2
Islock = Not Pind.3

Locate 1 , 3
Lcd "ATmega8  PLL"
Locate 2 , 4
Lcd "Controller"

Waitms 2000

Cls
Call Printlcd
Call Setmc145151

Program:

   If Pinb.6 = 1 Then

      Mainfreq = Mainfreq + 5
      If Mainfreq > Maxfreq Then
         Mainfreq = Minfreq
      End If

      Call Printlcd
      Call Setmc145151
   End If

   If Pinb.7 = 1 Then

      Mainfreq = Mainfreq - 5
      If Mainfreq < Minfreq Then
         Mainfreq = Maxfreq
      End If

      Call Printlcd
      Call Setmc145151
   End If

   If Pind.3 <> Islock Then
      Islock = Pind.3

      If Islock = 1 Then
         Locate 1 , 11
         Lcd "  LOCK"
      Else
         Locate 1 , 11
         Lcd "UNLOCK"
      End If

   End If

   If Pind.2 <> Isstereo Then
      Isstereo = Pind.2

      If Isstereo = 1 Then
         Locate 1 , 1
         Lcd "STEREO"
      Else
         Locate 1 , 1
         Lcd "MONO  "
      End If
   End If

Goto Program

Sub Setmc145151
Dim Con As Byte
Dim Root As Word
Dim Subfreq As Word
Dim Temroot As Word
Dim Datapll(12) As Byte

   Subfreq = Mainfreq / 5

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

   Portb.0 = Datapll(1)
   Portb.1 = Datapll(2)
   Portb.2 = Datapll(3)
   Portb.3 = Datapll(4)
   Portb.4 = Datapll(5)
   Portb.5 = Datapll(6)
   Portc.0 = Datapll(7)
   Portc.1 = Datapll(8)
   Portc.2 = Datapll(9)
   Portc.3 = Datapll(10)
   Portc.4 = Datapll(11)
   Portc.5 = Datapll(12)

   Eeromfreq = Mainfreq
End Sub

Sub Printlcd
Dim Strfreq As String * 5
Dim Comfreq As Byte
Dim Lenfreq As Byte

   Strfreq = Str(mainfreq)
   Lenfreq = Len(strfreq)
   Comfreq = Lenfreq - 2

   Locate 2 , 1

   If Lenfreq = 4 Then
      Lcd "FREQ   "
      Locate 2 , 7
   Else
      Lcd "FREQ  "
      Locate 2 , 6
   End If

   Lcd Left(strfreq , Comfreq) + "." + Right(strfreq , 2)

   Locate 2 , 14
   Lcd "MHz"

   Waitms 500
End Sub

End
Kontak INBOX ke FB
facebook.com/purwanto.apriana

BLOG
purwanto1987.wordpress.com

Offline DhannyDhuzell

  • Newbie
  • *
  • Tulisan: 14
Re:kontroler untuk MC145151, dan bisa juga dipake untuk veronika
« Jawab #1 pada: Maret 17, 2012, 08:07:54 PM »
maksudnya gimana ini gan .. sambil di kasih cara pengoperasiannya ... cari1

Offline Ayon

  • Full Member
  • ****
  • Tulisan: 108
Re:kontroler untuk MC145151, dan bisa juga dipake untuk veronika
« Jawab #2 pada: Januari 30, 2015, 06:39:58 PM »
ok sip mas pur apa sy bisa coba?