Cara Menciptakan Robot Light Follower Micro Atmega 8 Dan Driver L293d
Robot-ID.Com, Robot light follower merupakan robot yang gampang dan sederhana tanpa micro pun kita dapat membuatnya hanya dengan sebuah ic opamp dan transistor driver menyerupai yang sudah dibahas sebelumnya dalam postingan saya Cara Membuat Robot Light Following Simple dan Mudah
Butuh Aplikasi android tentang Robot Light Follower Analog, Instal aja langsung DISINI atau klik DOWNLOAD APLIKASI
Butuh Aplikasi android tentang Robot Light Follower Analog, Instal aja langsung DISINI atau klik DOWNLOAD APLIKASI
PCB LFR Micro sudah dirakit |
Untuk siswa SMP/SMA/SMK atau pemula yang ingin menyebarkan robot light follower memakai micro atmega 8 anda dapat ikuti panduan berikut ini:
Desain PCB minimum system atmega 8 yang ditambahkan 2 buah photodioda dan ic driver L293D sebagai pemacu motor dc 12v, adapun pin-pin yang digunakan adalah:
PIN MICRO ATMEGA 8 YANG DIPAKAI
SENSOR PD1 = PIN PC2 (ADC2)
SENSOR PD2 = PIN PC4 (ADC4)
SAMBUNGAN KE L293D
0C1A => PB1 ENABLE PD7
0C1B => PB2 ENABLE PD6
LAMPU LED INDICATOR SENSOR DETEKSI PB0
Untuk desain pcb dapat memakai software diptrace sbb:
Desain PCB Diptrace |
PCB Tampak atas |
PCB Tampak Bawah |
Kode kegiatan CAVR dapat anda kembangkan lagi, silahkan dicek:
/*****************************************************
This kegiatan was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project : light-follow-micro
Version : 1
Date : 12/15/2015
Author : Tim Mutekla
Company : Mutekla robotic center
Comments: TokoRobot.NET
Chip type : ATmega8
Program type : Application
AVR Core Clock frequency: 11.059200 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
#include
#include
#define ADC_VREF_TYPE 0x20
// Read the 8 most significant bits
// of the AD conversion result
unsigned char read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCH;
}
// Declare your global variables here
#define LED PORTB.0
int sensorL,sensorR;
//==Motor==================================================
// PWM plus(+) maju ,, PWM minus(-) mundur
void motor(int pwmL,int pwmR){
if(pwmL>255){pwmL=255;}
else
if(pwmL<-255 pwml="-255;}</p"> if(pwmR>255){pwmR=255;}
else
if(pwmR<-255 pwmr="-255;}</p">
//kiri maju
if(pwmR>=0){
PORTD.7=0;
OCR1A=pwmR;
}
else{
//kiri mundur
PORTD.7=1;
OCR1A=255+(pwmR);
}
//kanan maju
if(pwmL>=0){
PORTD.6=0;
OCR1B=pwmL;
}
else{
//kanan mundur
PORTD.6=1;
OCR1B=255+(pwmL);
}
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0x07;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=Out Func6=Out Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=0 State6=0 State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0xC0;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 172.800 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=0x0B; //0x03; 0x0D;
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
MCUCR=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 Clock frequency: 691.200 kHz
// ADC Voltage Reference: AREF pin
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x84;
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
while (1)
{
// Place your code here
//baca adc
sensorL=read_adc(2);
sensorR=read_adc(4);
if(sensorL<80 amp="" sensorr="">80){LED=1;motor(60,0);delay_ms(10);}else 80>
if(sensorR<80 amp="" sensorl="">80){LED=1;motor(0,60);delay_ms(10);}else80>
if(sensorL<80 amp="" delay_ms="" motor="" p="" sensorr=""> else{LED=0;motor(0,0);delay_ms(50);};
}
}80>-255>-255>
/*****************************************************
This kegiatan was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project : light-follow-micro
Version : 1
Date : 12/15/2015
Author : Tim Mutekla
Company : Mutekla robotic center
Comments: TokoRobot.NET
Chip type : ATmega8
Program type : Application
AVR Core Clock frequency: 11.059200 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
#include
#include
#define ADC_VREF_TYPE 0x20
// Read the 8 most significant bits
// of the AD conversion result
unsigned char read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCH;
}
// Declare your global variables here
#define LED PORTB.0
int sensorL,sensorR;
//==Motor==================================================
// PWM plus(+) maju ,, PWM minus(-) mundur
void motor(int pwmL,int pwmR){
if(pwmL>255){pwmL=255;}
else
if(pwmL<-255 pwml="-255;}</p"> if(pwmR>255){pwmR=255;}
else
if(pwmR<-255 pwmr="-255;}</p">
//kiri maju
if(pwmR>=0){
PORTD.7=0;
OCR1A=pwmR;
}
else{
//kiri mundur
PORTD.7=1;
OCR1A=255+(pwmR);
}
//kanan maju
if(pwmL>=0){
PORTD.6=0;
OCR1B=pwmL;
}
else{
//kanan mundur
PORTD.6=1;
OCR1B=255+(pwmL);
}
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0x07;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=Out Func6=Out Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=0 State6=0 State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0xC0;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 172.800 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=0x0B; //0x03; 0x0D;
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
MCUCR=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 Clock frequency: 691.200 kHz
// ADC Voltage Reference: AREF pin
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x84;
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
while (1)
{
// Place your code here
//baca adc
sensorL=read_adc(2);
sensorR=read_adc(4);
if(sensorL<80 amp="" sensorr="">80){LED=1;motor(60,0);delay_ms(10);}else 80>
if(sensorR<80 amp="" sensorl="">80){LED=1;motor(0,60);delay_ms(10);}else80>
if(sensorL<80 amp="" delay_ms="" motor="" p="" sensorr=""> else{LED=0;motor(0,0);delay_ms(50);};
}
}80>-255>-255>
Hasil testing robot berjalan dengan baik, lihat video dibawah ini:
Berminat dapat wa/sms : 085788800225