Beruflich Dokumente
Kultur Dokumente
Pada artikel ini saya hendak membagikan pengalaman bagaimana cara berkomunikasi serial
antara labview dengan Microcontroler AVR. Bagi rekan-rekan komunitas Microcontroller dan
LabView tentunya sudah memahami AVR microcontroller dan LabView. Disini akan saya bahas
apa saja yang diperlukan untuk bisa berkomunikasi antara AVR dan LabView. Langsung saja ke
tujuan dibawah ini.
Peralatan yang dibutuhkan adalah
Hardware :
1. AVR Development Kit
2. AVR Downloader
3. USB to Serial Cable
Software :
1. CVAVR (CodeVisionAVR Evaluation V3.04)
2. LabView (http://www.ni.com/trylabview/)
//DDRC=0x00;
DDRC=255;
init_lcd();
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1386.900 kHz
// Mode: Ph. correct PWM top=0x00FF
// OC1A output: Non-Inv.
// 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=0xA1;
TCCR1B=0x0C;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x47;
lcd_goto(line1);
printf("1=ECONO; 2=POWER");
lcd_goto(line2);
printf(" 3=BY PASS ");
while (1)
{
data=getchar();
if(data=='1')
{
PORTA.6=0;
PORTB=0xF0;
lcd_clrscr();
lcd_goto(line1);
printf(" ECONO MODE");
}
if(data=='2')
{
PORTA.6=1;
PORTB=0x0F;
lcd_clrscr();
lcd_goto(line1);
printf(" POWER MODE");
}
else if(data=='3')
{
PORTA.6=0;
PORTB=0xFF;
lcd_clrscr();
lcd_goto(line1);
printf(" BY PASS MODE");
}
}
}