Programming A Robot Using

3,966 views
3,835 views

Published on

This is the presentation covers many concepts about programming the microcontrollers.

Published in: Technology, Business
1 Comment
2 Likes
Statistics
Notes
No Downloads
Views
Total views
3,966
On SlideShare
0
From Embeds
0
Number of Embeds
1,319
Actions
Shares
0
Downloads
133
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide

Programming A Robot Using

  1. 1. PROGRAMMING A ROBOT USING ICC AVR Ver 7.5<br />
  2. 2. ICC AVR ver 7.5<br />ICC AVR is a tool used to program Atmel microcontrollers.<br />It uses a C compiler to compile the high level code into a low level code.<br />ICC AVR then converts this low level code into HEX code.<br />It also has built in tools to program the flash memory of the microcontroller.<br />
  3. 3. HOW TO INSTALL ICC AVR ver 7.5<br />
  4. 4. ICC AVR ver 7.5 is not a freeware and thus you have to purchase it.<br />But 45 days trial versions are available on the net and they give almost the same features.<br />Thus download the setup of the trial version from the site : http://www.imagecraft.com/<br />Run the setup and install ICC AVR ver 7.5<br />
  5. 5. HOW TO USE ICC AVR ver 7.5<br />
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
  13. 13.
  14. 14.
  15. 15. H BRIDGE PIN-OUT<br />
  16. 16. L293D<br />IN1<br />IN2<br />EN1<br />PC2<br />PC3<br />PC4<br />PC5<br />PC6<br />PC7<br />OUT1<br />OUT2<br />OUT3<br />OUT4<br />A<br />T<br />M<br />E<br />G<br />A<br /> 1<br />6<br />IN3<br />IN 4<br />EN2<br />
  17. 17.
  18. 18.
  19. 19.
  20. 20.
  21. 21.
  22. 22.
  23. 23.
  24. 24. IMPORTANT STUFF….<br />
  25. 25. Input Output PORTS<br />• Four, 8 bit I/O ports- PORT A,B,C,D<br />• All I/O ports pins are bidirectional and can be<br />configured individually<br />• Input pins can be configured to utilize<br />internal pullups.<br />• Data Direction Register , DDRn<br />• Port Driver Register, PORTn<br />• Port Pin Register, PINn<br />
  26. 26. Data Direction Register, DDRn<br />• Determines the direction of individual pins of<br />ports<br />• If the bit of the DDR is set the corresponding pin<br />of the port is configured as output pin<br />• If the bit of the DDR is cleared the<br />corresponding pin of the port is configured as<br />input pin<br />• DDRA = 0xF0;<br />• 4 MSB pins of PORTA are output pins<br />• 4 LSB pins of PORTA are input pins<br />
  27. 27. Port Pin Register, PINn<br />• Reading the input pins of port is done by<br />reading PIN register<br />• Temp = PINA;<br />• Read the PORTA input and store in temp variable<br />
  28. 28. Port Drive Register, PORTn<br />• For pins configured as input<br />(DDRn[x] = 0) microcontroller connects a<br />internal pull up register if the<br />corresponding bit of PORTn is set<br />• If the PORTn bit is cleared, pin is Tristated<br />• DDRA = 0x00;<br />• PORTA = 0xF0<br />
  29. 29. Buzzer On / OFF<br />• PORT B pin 7<br />• Pin is configured as output<br />• DDRB= 0x80;<br />• To turn on the buzzer output high<br />• PORTB = 0x80;<br />• To turn off the buzzer output low<br />• PORTB = 0x00;<br />
  30. 30. Buzzer Function<br />void Buzzer_ON(void)<br />{<br />PORTB = 0x80;<br />}<br />void Buzzer_OFF(void)<br />{<br />PORTB = PORTB & 0x7F;<br />}<br />
  31. 31. LED DISPLAY<br />8 bit LED display is connected to PORTD.<br />To display any bit combination on the LED display, we use…<br /> PORTD=0xXX;<br />
  32. 32. CODE FOR LED DISPLAY<br />void main(void)<br />{<br />init_devices();<br /> while(1)<br /> {<br /> PORTD=0xFF;<br /> }<br />}<br />
  33. 33. Analog To Digital Converter<br />• 10 bit resolution<br />• 8 channels<br />• PORTA(0 – 7)<br />• Disable internal pull up<br />• ADCH & ADCL – Data Register<br />• ADMUX- Channel Select Register<br />• ADCSR – Control & Status Register<br />
  34. 34.
  35. 35. unsigned char ADC_conversion (unsigned char ADC_channel_number) <br />{ <br /> unsigned inti = 0;<br /> ADCH = 0x00;<br />i = ADC_channel_number & 0x0F; // keeping the loweatnibbel<br /> ADMUX = i | 0x20; //upper nibbel of 0x20 indicates the result is left adjusted (8 bit ADC conversion)<br /> ADCSR |= 0x40;<br /> for (i = 1; i &lt; 255; i++); //delay of 93.2 uS<br />i = ADCH;<br /> return (i);<br />}<br />void main(void)<br />{ <br /> unsigned char I, value[3];;<br /> for(i=0;i&lt;3;i++)<br /> { <br /> value[i]=ADC_conversion(i);<br /> }<br />}<br />
  36. 36. HOW TO COMPILE AND BUILD YOUR CODE<br />
  37. 37.
  38. 38.
  39. 39.
  40. 40.
  41. 41.
  42. 42.
  43. 43.
  44. 44.
  45. 45.
  46. 46.
  47. 47.
  48. 48.
  49. 49.
  50. 50.
  51. 51.
  52. 52.
  53. 53. After you program your robot, it is ready to run the code written onto the microcontroller.<br />So just power on the microcontroller and it will start the execution of the code.<br />
  54. 54. MOTION CONTROL AND LINE FOLLOWING<br />
  55. 55. PORT CONFIGURATION<br />PORTA is ADC port.<br />3 white line sensors are connected to pin1, pin2, pin 3 of PORTA.<br />PORTC is connected to the H-bridge.<br />
  56. 56. CODE FOR MOTION<br /> void delay(int time)<br /> {<br />inti,j; for(i=0;i&lt;time;i++) for(j=0;j&lt;500;j++);}void backward(void) // subroutine for backward motion{ PORTC=0xB4; delay(100);}void right(void) // subroutine for right motion{ PORTC=0xB8; delay(100);}void left(void) // subroutine for left motion{ PORTC=0xD4; delay(100);}void forward(void) // subroutine for forward motion{ PORTC=0xD8; delay(100);} void stop(void) // subroutine for stop motion{ PORTC=0xFF; delay(100);}<br />//void main(void){init_devices(); //insert your functional code here... forward(); delay(1000); left(); delay(100); forward(); delay(1000); right(); delay(100); backward(); delay(1000); stop(); delay(100);}<br />
  57. 57. CODE FOR LINE FOLLOWER<br />unsigned intADC_conversion (unsigned intADC_channel_number) <br />{ <br /> unsigned inti = 0;<br /> ADCH = 0x00;<br />i = ADC_channel_number & 0x0F; // keeping the loweatnibbel<br /> ADMUX = i | 0x20; <br /> ADCSR |= 0x40;<br /> for (i = 1; i &lt; 255; i++); //delay of 93.2 uS<br />i = ADCH;<br /> return (i);<br />}<br />void forward(void)<br />{<br /> PORTC=0xD8;<br />}<br />void left(void)<br />{<br /> PORTC=0xB8;<br />}<br />void right(void)<br />{<br /> PORTC=0xD4;<br />}<br />void backward(void)<br />{<br /> PORTC=0xB4;<br />} <br />//<br />void main(void)<br />{<br />unsigned char value[3];<br />unsigned char i;<br />init_devices();<br /> while(1)<br /> {<br /> for(i=0;i&lt;3;i++)<br /> {<br /> value[i]=ADC_conversion(i);<br /> }<br /> if (value[1] &lt; 50)<br /> {<br /> forward();<br /> }<br /> else<br /> {<br /> if(value[2] &gt; 90)<br /> {<br />left();<br /> }<br /> else<br /> {<br /> if (value[0] &gt; 90)<br /> {<br />right();<br /> }<br />else<br /> {<br /> backward();<br />}<br />} } } }<br />
  58. 58. THANK YOU…<br />

×