0% found this document useful (0 votes)
54 views4 pages

Nama: Gunawan: Kelas: 5A

This document contains code for controlling a DC motor forward and reverse using a Proteus simulation. The code initializes ports and timers for PWM control of two motors. It reads buttons to increase or decrease the speed of each motor and displays the speed values on an LCD screen. The PWM outputs are updated in a loop based on the button values to control the motor speeds.

Uploaded by

Naw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views4 pages

Nama: Gunawan: Kelas: 5A

This document contains code for controlling a DC motor forward and reverse using a Proteus simulation. The code initializes ports and timers for PWM control of two motors. It reads buttons to increase or decrease the speed of each motor and displays the speed values on an LCD screen. The PWM outputs are updated in a loop based on the button values to control the motor speeds.

Uploaded by

Naw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Nama : Gunawan

Kelas : 5A
Rangkaian pengendali motor dc forward-reverse menggunakan Proteus
Gambar 1,

Gambar Rangkaian Proteus

Codding SuhuRuangan
#include

// Alphanumeric LCD Module functions


#include
#include
//Deklarasi variabel
int SA,SB;
char MA[8];
char MB[8];
void main(void)
{
PORTA=0xFF;
DDRA=0x00;
PORTD=0x00;
DDRD=0xFF;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 12000.000 kHz
// Mode: Fast PWM top=0x00FF
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// 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=0xA1;
TCCR1B=0x09;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

/ Alphanumeric LCD initialization


// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2
// D4 - PORTC Bit 4
// D5 - PORTC Bit 5
// D6 - PORTC Bit 6
// D7 - PORTC Bit 7
// Characters/line: 8

lcd_init(8);

while (1)
{
lcd_gotoxy(0,0);lcd_putsf("M1=");lcd_gotoxy(0,1);lcd_putsf("M2=");
PORTD.0=1; //Motor 1 Forward
PORTD.1=0;
PORTD.3=1; //Motor 2 Reverse
PORTD.4=0;
if(PINA.0==0){SA++;} //Jika pushbutton A0 ditekan naikan kecepatan motor 1
if(PINA.1==0){SA--;} //Jika pushbutton A1 ditekan turunkan kecepatan motor 1
if(PINA.2==0){SB++;} //Jika pushbutton A2 ditekan naikan kecepatan motor 2
if(PINA.3==0){SB--;}

//Jika pushbutton A3 ditekan turunkan kecepatan motor

2
lcd_gotoxy(5,0);itoa(SA,MA);lcd_puts(MA); //Tampilkan nilai kecepatan Motor
1
lcd_gotoxy(5,1);itoa(SB,MB);lcd_puts(MB); //Tampilkan nilai kecepatan Motor
2
OCR1A=SA;
OCR1B=SB;
// Place your code here

}
}

You might also like