Summer Ppt

Post on 28-Oct-2014

115 views 0 download

Tags:

transcript

EMBEDDED SYSTEM & ROBOTICS

AVR MICROCONTROLLERATMEGA16

HONEY CHAWLAROLL NO- 101006056

·        16KB of Flash memory        ·        1KB of SRAM        ·        512 Bytes of EEPROM        ·         Available in 40-Pin DIP        ·         8-Channel 10-bit ADC        ·         Two 8-bit Timers/Counters        ·         One 16-bit Timer/Counter        ·         4 PWM Channels        ·         In System Programmer (ISP)        ·         Serial USART        ·         SPI Interface        ·         Digital to Analog Comparator.

Different compilers and burner software information:            Compiler used are                                                                AVR studio,winAVR,CVAVR   C-code converted to hex                                                              AVRGCC   Hex code transferred to hardware programme                        USBASP   Serial hardware programmer                                                       STK500   Parallel hardware programmer                                                    STK200   USB hardware programmer                                                          USBASP   Serial software programmer                                                         Siprog   Parallel software programmer                                                      AVR Dude,ponyprog   USB software programmer                                                            AVR Dude

Configuring I/O Ports :-

Every  PORTX(A,B,C & D) have three registers associated with it to configure I/O Ports . These are• DDRX• PORTX• PINX

Basic overview of program written for AVR Microcontroller i.e ATmega16

#include<avr.io.h>                           //header files#include<util/delay.h>                   //header filesint main(){DDRA=0xff;                                       //data direction registerPORTA=0xff;                                      //values to be supplied at output of port are                  written in this register//}

Home Automation using DTMF Relay Controller

LCD DISPLAY

INTRODUCTION TO D.T.M.F(DUAL TONE MULTIPLE FREQUENCY DIGIT LOW FREQUENCY(HZ) HIGH FREQUENCY(HZ)

1 697 1209

2 697 1336

3 697 1477

4 770 1209

5 770 1336

6 770 1477

7 852 1209

8 852 1336

9 852 1477

0 941 1336

* 941 1209

# 941 1477

DTMF IC CM8870

INTRODUCTION TO RELAYS

ULN2803

16*2 LCDVSS: power supply(GND)VCC: power supply(+5v)VEE: contrast adjustRS  : 0=Instruction input        1=Data inputR/W: 0=write to LCD 

module        1=read from LCD 

moduleEN  : enable signalD0  : Data bus line 0D1  : Data bus line 1D2  : Data bus line 2D3  : Data bus line 3D4  : Data bus line 4D5  : Data bus line 5D6  : Data bus line 6D7  : Data bus line 7

Basic terminology used in writing LCD programFor executing instruction command will bevoid LCD_cmd(unsigned char item)          //function to execute instruction{PORTB=item;PORTB|=(0<<RS)|(0<<RW)|(1<<EN);_delay_ms(1);PORTB|=(0<<RS)|(0<<RW)|(0<<EN);_delay_ms(1);}

For executing data command will bevoid LCD_data(unsigned char item)        //function to execute data{PORTB=item;PORTB|=(1<<RS)|(0<<RW)|(1<<EN);_delay_ms(1);PORTB|=(1<<RS)|(0<<RW)|(0<<EN);_delay_ms(1);

For initializing of LCD in 4-bit mode logic will bevoid LCD_init()          //function to initialize{dis_cmd(0x02);        //to initialize LCD in 4-bit modedis_cmd(0x28);        //to initialize LCD in 2 lines,5*7 dotsdis_cmd(0x0c);        //display on cursor ondis_cmd(0x06);       //for autoincrement mode}

For instructions masking logic will bevoid dis_cmd(unsigned char item)    //function to send instructions{unsigned int value;value=item & 0xf0;LCD_cmd(value);item=((item<<4)&0xf0);LCD_cmd(item);}

For data masking logic will bevoid dis_data(unsigned char item)    //function to send data{unsigned int value;value=item & 0xf0;LCD_data(value);item=((item<<4)&0xf0);LCD_data(item);}

Code of Program used :-#include<avr/io.h>#include<util/delay.h>

#define LCD_port PORTC#define RS PC0#define RW PC1#define EN PC2

void LCD_cmd(unsigned char item);void LCD_data(unsigned char item);void dis_cmd(unsigned char item);void dis_data(unsigned char item);void LCD_init(void);void LCD_string(unsigned char str[]);

int main(){DDRB=0xff;DDRA=0x00;DDRC=0xff;LCD_init();

while(1){     if((PINA & 0b00001111)==1)      //connect dtmf pins to porta   {   PORTB|=0x01;                      // lcd to portc   dis_cmd(0x83);   LCD_string("relay1");           //relay to portb   }

   if((PINA & 0b00001111)==2)   {   PORTB|=0x02;   dis_cmd(0x83);   LCD_string("relay2");   }   if((PINA & 0b00001111)==3)   {   PORTB &=0xfe;   }

   if((PINA & 0b00001111)==4)   {   PORTB|=0x04;   dis_cmd(0x83);   LCD_string("relay3");   }

 if((PINA & 0b00001111)==5)   {   PORTB &=0xfd;   }if((PINA & 0b00001111)==6)   {   PORTB &=0xfb;   }

   if((PINA & 0b00001111)==8)   {   PORTB|=0x08;   dis_cmd(0x83);   LCD_string("relay4");   }   if((PINA & 0b00001111)==9)   {   PORTB &=0xf7;   }

}   return 0;}void LCD_cmd(unsigned char item){    LCD_port=item;    LCD_port|=(0<<RS)|(0<<RW)|(1<<EN);   _delay_ms(1);    LCD_port|=(0<<RS)|(0<<RW)|(0<<EN);   _delay_ms(1);}

void LCD_data(unsigned char item){    LCD_port=item;    LCD_port|=(1<<RS)|(0<<RW)|(1<<EN);   _delay_ms(1);    LCD_port|=(1<<RS)|(0<<RW)|(0<<EN);   _delay_ms(1);}void dis_cmd(unsigned char item){    unsigned int value1;    value1=item & 0xf0;    LCD_cmd(value1);    item=(item<<4) & 0xf0;    LCD_cmd(item);}

void dis_data(unsigned char item){    unsigned int value1;    value1=item & 0xf0;    LCD_data(value1);    item=(item<<4) & 0xf0;    LCD_data(item);}

void LCD_init(void){    dis_cmd(0x02);    _delay_ms(1);

    dis_cmd(0x28);   _delay_ms(1);

    dis_cmd(0x06);   _delay_ms(1);

    dis_cmd(0x0c);   _delay_ms(1);

    dis_cmd(0x80);   _delay_ms(1);}void LCD_string(unsigned char str[]){     unsigned int i=0;   while(str[i]!='\0')   {   dis_data(str[i]);   _delay_ms(1);    i++;   }}

DIGITAL CLOCK USING 7 SEGMENT DISPLAY

Hardware Details

Code of Program for Digital Clock#include<avr/io.h>#include<util/delay.h>

int main(){ DDRB=0xff;

DDRD=0xff;

while(1){ clk();}return 0;

}

void display(int x){ if(x==0){PORTD=0b10000001;}

if(x==1){PORTD=0b10110111;}if(x==2){PORTD=0b11000010;}if(x==3){PORTD=0b10010010;}if(x==4){PORTD=0b10110100;}if(x==5){PORTD=0b10011000;}if(x==6){PORTD=0b10001000;}if(x==7){PORTD=0b10110011;}if(x==8){PORTD=0b10000000;}if(x==9){PORTD=0b10110000;}

}

void ssd_number(int x,int y){ if(y==1){PORTB=0x01;display(x);}

if(y==2){PORTB=0x02;display(x);}if(y==3){PORTB=0x04;display(x);}if(y==4){PORTB=0x08;display(x);}if(y==5){PORTB=0x10;display(x);}if(y==6){PORTB=0x20;display(x);}

}

void clk(void){for(int b=0;b<3;b++){     for(int a=0;a<10;a++)          {for(int i=0;i<6;i++)

       { for(int j=0;j<10;j++)   { for(int k=0;k<6;k++)

{ for(int l=0;l<10;l++){

for(int p=0;p<10;p++)            {

ssd_number((l%10),1);_delay_ms(5);ssd_number((k%10),2);_delay_ms(5);ssd_number((j%10),3);_delay_ms(5);ssd_number((i%10),4);_delay_ms(5);ssd_number((a%10),5);_delay_ms(5);ssd_number((b%10),6);_delay_ms(5);

}}}}}

                }}                }

Apart from the project what I have learnt during Summer Training in I3 Indya are:-

• Interfacing of LEDS with ATmega16• Displaying digits using 7 segment display• Motor Interfacing with ATmega16• Interfacing of keypad with ATmega16 • Introduction to ADC• Introduction to Sensors• Introduction to Interrupts• Introduction to Touch Screen• Introduction to RF Communication• Introduction to Serial Communication