Diklat Mikrontroler

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

itung nilai hambatan resistor karena bendanya kecil maka dibuat kode warna, sebab jika ditulis di badannya sulit untuk dibaca !

Diklat Media Pembelajaran dg Komputer

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Modul Belajar PLC

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Modul Belajar Mikrokontroler

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Minggu, 08 Februari 2015

Mengenal Bahasa Pemograman C


Untuk memogram mikrokontroller sebetulnya tidak hanya menggunakan bahasa C, tetapi kita juga bisa menggunakan bahasa pemograman yang lain misalnya Bahasa Basic, Asembller dan lain-lain. karena pada prinsipnya yang dibaca mikrokontroller bukan Bahasa Pemogramannya tetapi bahasa mesin yaitu .hex (hexadecimal). Jadi bahasa pemograman apa saja bisa untuk memprogram mikrokontroller dengan catatan ada software compiler yang bisa merubah kebahasa mesin (.hex).
Yang akan kita bahas adalah bahasa pemograman C dengan Compiler yang digunakan yaitu Covision AVR. Jika ditanya kenapa saya menggunakan basaha pemograman
C dan Compilernya CodeVision AVR?. Jawabannya sebarnya sederhana karena saya pernah punya buku yang mempelajari bahasa C dan compilernya Codevision AVR dan setelah saya pelajari ternyata tidak terlalu sulit dibanding dengan bahasa Assembler, he… itu sih pendapat pribadi saya sebenarnya dalam belajar itu relativ tergantung balik lagi ke diri masing masing. Tapi saya pernah dapet matakuliah basaha Asembbler dan kayana gak semudah mempelajari bahasa C alias gak bisa2.. he..

bahasa C merupakan high level language (bahasa tingkat tinggi) , dimana memudahkan programmer menuangkan algoritmanya. Untuk mengetahui dasar pemograman bahasa C saya akan memulai dengan sturuktur penulisan program, strukturnya sebagai berikut:

Struktur penulisan program
#include < [libraryA.h] > // Opsional
#include < [libraryB.h] > // Opsional
#define [nama variable] [nilai] ; // Opsional
#define [nama variable] [nilai] ; // Opsional
[global variables] // Opsional 
[functions] // Opsional
void main(void) // Program Utama
{
[inisialisasi]

[Program Utama]
}
Berikut ini contoh Program jadi yang saya buat menggunakan Codevision AVR:
Program ini berfungsi untuk menyalakan dan mematikan led.
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.3 Standard
Automatic Program Generator
© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project : KONTROLL LAMPU ON - OFF
Version : 01
Date    : 12/19/2012
Author  : Aris Munandar
Company : Les Elektronika
Comments: " Belajar Sambil Berbagi Insyaallah Berkah ".
Info Lebih Lanjut :
-www.leselektronika.blogspot.com
-www.budakwarkir.blogspot.com
                                                           
Chip type               : ATmega16
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 256
*****************************************************/
#include
#include
#define tombol_on   PINB.0
#define tombol_off  PINB.1
#define lampu       PORTA.0
#define on          0
#define off          1
bit status_tombol=off;
void lampu_on();
void lampu_off();
void lampu_on(){
                lampu=on;
                delay_ms(10);
                }
void lampu_off()
                {
                lampu=off;
                delay_ms(10);
                }
               
           
 void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=1
PORTA=0x01;
DDRA=0x01;
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=P
PORTB=0x03;
DDRB=0x00;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// USART initialization
// USART disabled
UCSRB=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// ADC initialization
// ADC disabled
ADCSRA=0x00;
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
while (1)
      {
      // Place your code here
       if (tombol_on==on){lampu_on();}
       if (tombol_off==on){lampu_off();}
      }
}

Berikut ini adalah rangkainnya:



Semoga bermanfaat..

Selasa, 01 Januari 2013

Jam Digital LCD tampilan Jumbo

Rangkaian Simulator dg Proteus :




Code List : ( Bascom AVR )
 '-------------------------------------------------------------------
'Title Block
'Author: Suparnom .Pd
'Date :  Dec 2011
'File name: BigDigitTest.V3
'-------------------------------------------------------------------
$crystal = 8000000                                          'speed of processing
$regfile = "m8535.dat"                                      'our micro
'------------------------------------------------------------------
'setup/configure hardware
Config Porta = Input
Config Portb = Input                                        'switches connected here
Config Pina.4 = Output                                      'backlight


'bascom internal features and functions to make a clock in software

'requires 32,768 Hz crystal on PortC.6 and PortC.7
Config Date = Dmy , Separator = /
Config Clock = Soft , Gosub = Sectic                        'with 1 second interrupt configured
Enable Interrupts                                           'starts the clock

'setup connection of LCD to micro
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Lcd = 20 * 4

'these characters are used to build the bigdigits
Deflcdchar 1 , 32 , 32 , 32 , 1 , 3 , 7 , 15 , 31
Deflcdchar 4 , 31 , 15 , 7 , 3 , 1 , 32 , 32 , 32
Deflcdchar 2 , 32 , 32 , 31 , 31 , 31 , 31 , 31 , 31
Deflcdchar 3 , 32 , 32 , 32 , 16 , 24 , 28 , 30 , 31
Deflcdchar 5 , 31 , 31 , 31 , 31 , 31 , 32 , 32 , 32        ' replace [x] with number (0-7)
'Deflcdchar 5 , 1 , 3 , 7 , 15 , 31 , 32 , 32 , 32
Deflcdchar 6 , 31 , 31 , 31 , 31 , 31 , 32 , 32 , 32
Deflcdchar 7 , 1 , 3 , 7 , 15 , 31 , 31 , 31 , 31
Deflcdchar 0 , 31 , 30 , 28 , 24 , 16 , 32 , 32 , 32

'  Harware Aliases
Lcdbacklight Alias Porta.4
Piezo Alias Portb.0

Yel_btn Alias Pinb.3
Red_btn Alias Pinb.4
Blu_btn Alias Pinb.5
Blk_btn Alias Pinb.6
White_btn Alias Pinb.7

'8. initialise hardware
Cls                                                         'Clears screen
Cursor Off                                                  'no cursor to be displayed on lcd
Set Lcdbacklight                                            'turn on LCD backlight

'------------------------------------------------------------------
' Declare Constants
Const Delay_time = 100
'------------------------------------------------------------------
' Declare Variables

Dim Digitpos As Byte
Dim Seccount As Word
Dim I As Byte

' Initialise Variables
Date$ = "22/07/10"                                          'preset time on powerup
Time$ = "13:10:00"
Digitpos = 1
'------------------------------------------------------------------
' 12. Program starts here
Do
    Digitpos = 1
    For I = 0 To 9
        Gosub Show_bigtime                                  'Show_bigdigit
        Waitms 100
    Next
    Gosub Show_smalltime
    Wait 1
    Gosub Show_bigtime
    Wait 1
Loop
'------------------------------------------------------------------
' Subroutines
Show_smalltime:                                             'Display time in small digits so that title
   Locate 2 , 4                                             'and the time can fit in to the lcd.
   Lcd "Time: "
   Lcd Time$ ; ""
Return

Show_bigtime:
   'find the digit in the tens of hours position
   I = _hour / 10                                           'e.g. 19/10 = 1 (byte arithmentic!!)
   Digitpos = 1
   Gosub Show_bigdigit
   'find the digit in the units of hours position
   I = _hour Mod 10                                         'e,g. 19mod10 = 9 (finds remainder)
   Digitpos = 5
   Gosub Show_bigdigit

   Locate 2 , 9
   Lcd Chr(5)
   Locate 3 , 9
   Lcd Chr(2)
   'find the digit in the tens of minutes position
   I = _min / 10                                            'e.g. 21/10 = 2 (byte arithmentic!!)
   Digitpos = 11
   Gosub Show_bigdigit
   'find the digit in the units of minutes position
   I = _min Mod 10                                          'e.g 21mod10 = 1 (finds remainder)
   Digitpos = 15
   Gosub Show_bigdigit
   'display the seconds in the bottom corner of the display
   Locate 4 , 19
   If _sec < 10 Then Lcd "0"
   Lcd _sec
Return
Show_bigdigit:
   If I = 0 Then Gosub Disp0
   If I = 1 Then Gosub Disp1
   If I = 2 Then Gosub Disp2
   If I = 3 Then Gosub Disp3
   If I = 4 Then Gosub Disp4
   If I = 5 Then Gosub Disp5
   If I = 6 Then Gosub Disp6
   If I = 7 Then Gosub Disp7
   If I = 8 Then Gosub Disp8
   If I = 9 Then Gosub Disp9
Return

Disp0:
    'line 1
    Locate 1 , Digitpos
    Lcd Chr(1)
    Lcd Chr(2)
    Lcd Chr(3)
    'line 2
    Locate 2 , Digitpos
    Lcd Chr(255)
    Lcd " "
    Lcd Chr(255)
    'line 3
    Locate 3 , Digitpos
    Lcd Chr(255)
    Lcd " "
    Lcd Chr(255)
    'line 4
        Locate 4 , Digitpos
    Lcd Chr(4)
    Lcd Chr(6)
    Lcd Chr(0)

Return

Disp1:
   'line 1
   Locate 1 , Digitpos
   Lcd " "
   Lcd Chr(1)
   Lcd " "
   'line 2
   Locate 2 , Digitpos
   Lcd Chr(5)
   Lcd Chr(255)
   Lcd " "
   'line 3
   Locate 3 , Digitpos
   Lcd " "
   Lcd Chr(255)
   Lcd " "
   'line 4
   Locate 4 , Digitpos
   Lcd Chr(6)
      Lcd Chr(6)
   Lcd Chr(6)
Return


Disp2:
   'line 1
   Locate 1 , Digitpos
   Lcd Chr(1)
   Lcd Chr(2)
   Lcd Chr(3)
   'line 2
   Locate 2 , Digitpos
   Lcd Chr(6)
   Lcd " "
   Lcd Chr(255)
   'line 3
   Locate 3 , Digitpos
   Lcd Chr(7)
   Lcd Chr(6)
   Lcd Chr(0)
   'line 4
   Locate 4 , Digitpos
   Lcd Chr(6)
   Lcd Chr(6)
   Lcd Chr(6)
Return
Disp3:
   'line 1
    Locate 1 , Digitpos
    Lcd Chr(1)
    Lcd Chr(2)
    Lcd Chr(3)
   'line 2
    Locate 2 , Digitpos
    Lcd " "
    Lcd Chr(2)
    Lcd Chr(255)
   'line 3
    Locate 3 , Digitpos
    Lcd " "
    Lcd " "
    Lcd Chr(255)
   'line 4
    Locate 4 , Digitpos
    Lcd Chr(4)
    Lcd Chr(6)
    Lcd Chr(0)
Return

Disp4:
   'line 1
   Locate 1 , Digitpos
   Lcd Chr(2)
   Lcd " "
   Lcd " "
   'Line 2
   Locate 2 , Digitpos
   Lcd Chr(255)
   Lcd " "
   Lcd Chr(255)
   'line 3
   Locate 3 , Digitpos
   Lcd Chr(255)
   Lcd Chr(255)
   Lcd Chr(255)
   Locate 4 , Digitpos
   Lcd "  "
   Lcd Chr(6)
Return

Disp5:
   'line 1
   Locate 1 , Digitpos
   Lcd Chr(2)
   Lcd Chr(2)
   Lcd Chr(2)
   'line 2
   Locate 2 , Digitpos
   Lcd Chr(255)
   Lcd Chr(2)
   Lcd Chr(2)
   'line 3
   Locate 3 , Digitpos
   Lcd Chr(2)
   Lcd " "
   Lcd Chr(255)
   'line 4
    Locate 4 , Digitpos
    Lcd Chr(4)
    Lcd Chr(6)
    Lcd Chr(0)
Return

Disp6:
   'line 1
   Locate 1 , Digitpos
   Lcd Chr(1)
   Lcd Chr(2)
   Lcd Chr(3)
   'Line 2
   Locate 2 , Digitpos
   Lcd Chr(255)
   Lcd Chr(2)
   Lcd Chr(3)
      'line 3
   Locate 3 , Digitpos
   Lcd Chr(255)
   Lcd " "
   Lcd Chr(255)
   'line 4
    Locate 4 , Digitpos
    Lcd Chr(4)
    Lcd Chr(6)
    Lcd Chr(0)
Return

Disp7:
   'line 1
   Locate 1 , Digitpos
   Lcd Chr(1)
   Lcd Chr(2)
   Lcd Chr(3)
   'line 2
   Locate 2 , Digitpos
   Lcd "  "
   Lcd Chr(255)
   'line 3
   Locate 3 , Digitpos
   Lcd "  "
   Lcd Chr(255)
   'line 4
   Locate 4 , Digitpos
   Lcd "  "
   Lcd Chr(4)
Return

Disp8:
    'line 1
    Locate 1 , Digitpos
    Lcd Chr(1)
    Lcd Chr(2)
    Lcd Chr(3)
    'line 2
    Locate 2 , Digitpos
    Lcd Chr(255)
    Lcd Chr(2)
    Lcd Chr(255)
    'line 3
    Locate 3 , Digitpos
    Lcd Chr(255)
    Lcd " "
    Lcd Chr(255)
    'line 4
    Locate 4 , Digitpos
    Lcd Chr(4)
    Lcd Chr(6)
    Lcd Chr(0)
Return
Disp9:
   'line 1
   Locate 1 , Digitpos
   Lcd Chr(1)
   Lcd Chr(2)
   Lcd Chr(3)
   'line 2
   Locate 2 , Digitpos
   Lcd Chr(255)
   Lcd " "
   Lcd Chr(255)
   'line 3
   Locate 3 , Digitpos
   Lcd Chr(4)
   Lcd Chr(6)
   Lcd Chr(255)
   'line 4
   Locate 4 , Digitpos
   Lcd Chr(4)
   Lcd Chr(6)
   Lcd Chr(0)
Return


Sectic:
   Incr Seccount
Return

Jumat, 28 Desember 2012

Simulator Pengendali Motor DC Putar kanan Kiri

Pada artikel kali ini saya posting sebuah simulator pengendali motor DC dengan Proteus untuk :
  1. Putar kanan
  2. Putar Kiri
  3. Stop
  4. Overload
dilengkapi dengan tampilan LCD 2 x 16 yang dapat melihat kondisi jalannya program :
Gambar Rangkaianya lengkap :

List Code Bascom AVR :
$regfile = "m8535.dat"
$crystal = 4000000

Declare Sub Kanan()
Declare Sub Kiri()
Declare Sub Berhenti()
Declare Sub Ol()
Declare Sub Siap()

Ddrc.0 = 0 : Portc.0 = 1
Ddrc.1 = 0 : Portc.1 = 1
Ddrc.2 = 0 : Portc.2 = 1
Ddrc.3 = 0 : Portc.3 = 1
Ddrc.4 = 0 : Portc.4 = 1

Portb = 8

Config Portb = Output
Config Portc = Input
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Cursor Off

Locate 1 , 1
Lcd "  MOTOR READY  "
Locate 2 , 1
Lcd "BINA ELEKTRONIKA"
Wait 2



Do
If Pinc.0 = 0 And Portb = 8 Then
Locate 1 , 1
Lcd "MOTOR SEDANG    "
Locate 2 , 1
Lcd "PUTAR KANAN >>> "
Gosub Kanan
End If

If Pinc.1 = 0 And Portb = 8 Then
Locate 1 , 1
Lcd "MOTOR SEDANG    "
Locate 2 , 1
Lcd "PUTAR KIRI <<<  "
Gosub Kiri
End If

If Pinc.2 = 0 Then
Locate 1 , 1
Lcd "MOTOR BERHENTI "
Locate 2 , 1
Lcd "               "
Gosub Berhenti
End If

If Pinc.3 = 0 Then
Locate 1 , 1
Lcd "WADUH OVERLOAD "
Locate 2 , 1
Lcd "SILAHKAN RESET "
Gosub Ol
End If

If Pinc.4 = 0 Then
Locate 1 , 1
Lcd "MOTOR SIAP     "
Locate 2 , 1
Lcd "DIJALANKAN     "
Gosub Siap
End If

Loop

Kanan:
Portb = 2
Waitms 0.3
Return

Kiri:
Portb = 1
Waitms 0.3
Return

Berhenti:
Portb = 8
Waitms 0.3
Return

Ol:
Portb = 4
Waitms 0.3
Return

Siap:
Portb = 8
Waitms 0.3
Return

End

Selamat mencoba dan semoga bermanfaat ......

Selasa, 20 Maret 2012

Demo Nokia 3530L

Rangkaian :


Kontrol LCD yang digunakan :
PCF8833    - Nokia 6100/6610/6610i
S1D15G14 - Nokia 3530/3510i/3595
PCF8814    - Nokia 1100

Download: Nokia LCDs - Proteus VSM Models.zip
(MODELS + LIBRARY + some demos)

Tampilan LCD menggunakan Mikro ATMega8535 dan Bahasa BASCOM-AVR

Belajar menggunakan LCD dengan ATMega8535 tidaklah sulit, dengan menggunakan bahasa Bascom AVR hal ini menjadi mudah dilakukan terutama bagi pemula. Berikut adalah rangkaian konfigurasi pin pada mikro ATMega8535 dan contoh program yang dapat dicoba. Selamat Mencoba.

Gambar Rangkaian :

Rangkaian Tampilan LCD.

List program :
$regfile = "m8535def.dat"
$crystal = 4000000

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

Config Date = Mdy , Separator = /
Config Clock = Soft

Date$ = "11/26/08"
Time$ = "08:16:00"
'-----------------------
Cls
Do
Locate 1 , 1
Lcd "Tanggal:" ; Date$
Locate 2 , 1
Lcd "Pukul:" ; Time$
Loop
End

Footer Widget 3