31 st  Jan to 1 st  Feb 2008 TECHNOLOGY ROBOTICS SOCIETY Indian Institute of Technology, Kharagpur
AVR Family of Microcontrollers 8-bit RISC Architecture, single cycle instructions Principle features include Internal oscillators, timers, UART, SPI, PWM generation, ADC, analog comparator and more… Amenability to C programming In-System-Programmable (ISP) Flash Memory http://www.atmel.com/products/AVR/
ATmega8 – AVR Family Member Up to 16 MIPS throughput 8KB ISP Flash Memory, 1KB SRAM, 512Byte EEPROM 8bit / 16bit timers / counters Three PWM channels 8 Channel 10 bit ADC, Analog Comparator Programmable UART, SPI, TWI
ATmega8 – PDIP Package
ATmega8 – TQFP Package
ISP Flash Memory ISP : In-System-Programmable Flash ROM No need of specialized programmer hardware No need to remove processor from circuit for reprogramming
STK200 ISP Dongle PonyProg Programming Software http://www.lancos.com/prog.html
WinAVR WinAVR is a open source software development suite for Atmel AVR series of RISC microcontrollers GUI Integrated Development Environment Includes the GNU GCC compiler for C and C++. http://winavr.sourceforge.net/
WinAVR IDE Screenshot
Procyon AVRlib AVRlib is a library of easy-to-use C functions for AVR controllers AVRlib aims to allow programmers to work quickly towards their end goal by reducing the time needed to write basic support functions and code http://www.procyonengineering.com/avr/avrlib/
PWM DC Motor Control //Dual 8-bit PWM mode setup of timer 1 timer1PWMInit (8); // Frequency Prescaling to F_CPU_CLOCK / 256 timer1SetPrescaler (4); // Left and right motor speed set timer1PWMASet (lSpeed); // Pin 15 (OC1A) timer1PWMBSet (rSpeed); // Pin 16 (OC1B) // Start on the PWM generation timer1PWMAOn (); timer1PWMBOn ();
ADC’s & Analog Comparator DDRA = 0x00; // Configure Port A (ADC) as Input PORTA = 0x00;// Disable internal pull up resistors // Initialize Analog to Digital Converter a2dInit(); // Set conversion speed a2dSetPrescaler(ADC_PRESCALE_DIV32); // Set analog voltage reference a2dSetReference(ADC_REFERENCE_AVCC); // Acquire analog data into digital format for (i = 0; i < 8; i ++) adcData [i] = a2dConvert8bit(i);
UART - Serial Communication // Initialize UART at 2400 bps uartInit(); uartSetBaudRate (2400); // Check is data received if (!uartReceiveBufferIsEmpty ()) { // if data received then get it in a variable uartReceiveByte (&dataIn); // do whatever u wish with dataIn }
Crystal Oscillator Clock Source
AVR Fuse settings SUT 1:0 = 11 12 – 22 pf >= 1.0 1011, 1101, 1111 0 12 – 22 pf 3.0 – 8.0 1111 1 12 – 22 pf 0.9 – 3.0 1101 1 - 0.4 – 0.9 1010 1 C1 & C2 Frequency (MHz) CKSEL3:0 CKOPT

Robotix Tutorial 9

  • 1.
    31 st Jan to 1 st Feb 2008 TECHNOLOGY ROBOTICS SOCIETY Indian Institute of Technology, Kharagpur
  • 2.
    AVR Family ofMicrocontrollers 8-bit RISC Architecture, single cycle instructions Principle features include Internal oscillators, timers, UART, SPI, PWM generation, ADC, analog comparator and more… Amenability to C programming In-System-Programmable (ISP) Flash Memory http://www.atmel.com/products/AVR/
  • 3.
    ATmega8 – AVRFamily Member Up to 16 MIPS throughput 8KB ISP Flash Memory, 1KB SRAM, 512Byte EEPROM 8bit / 16bit timers / counters Three PWM channels 8 Channel 10 bit ADC, Analog Comparator Programmable UART, SPI, TWI
  • 4.
  • 5.
  • 6.
    ISP Flash MemoryISP : In-System-Programmable Flash ROM No need of specialized programmer hardware No need to remove processor from circuit for reprogramming
  • 7.
    STK200 ISP DonglePonyProg Programming Software http://www.lancos.com/prog.html
  • 8.
    WinAVR WinAVR isa open source software development suite for Atmel AVR series of RISC microcontrollers GUI Integrated Development Environment Includes the GNU GCC compiler for C and C++. http://winavr.sourceforge.net/
  • 9.
  • 10.
    Procyon AVRlib AVRlibis a library of easy-to-use C functions for AVR controllers AVRlib aims to allow programmers to work quickly towards their end goal by reducing the time needed to write basic support functions and code http://www.procyonengineering.com/avr/avrlib/
  • 11.
    PWM DC MotorControl //Dual 8-bit PWM mode setup of timer 1 timer1PWMInit (8); // Frequency Prescaling to F_CPU_CLOCK / 256 timer1SetPrescaler (4); // Left and right motor speed set timer1PWMASet (lSpeed); // Pin 15 (OC1A) timer1PWMBSet (rSpeed); // Pin 16 (OC1B) // Start on the PWM generation timer1PWMAOn (); timer1PWMBOn ();
  • 12.
    ADC’s & AnalogComparator DDRA = 0x00; // Configure Port A (ADC) as Input PORTA = 0x00;// Disable internal pull up resistors // Initialize Analog to Digital Converter a2dInit(); // Set conversion speed a2dSetPrescaler(ADC_PRESCALE_DIV32); // Set analog voltage reference a2dSetReference(ADC_REFERENCE_AVCC); // Acquire analog data into digital format for (i = 0; i < 8; i ++) adcData [i] = a2dConvert8bit(i);
  • 13.
    UART - SerialCommunication // Initialize UART at 2400 bps uartInit(); uartSetBaudRate (2400); // Check is data received if (!uartReceiveBufferIsEmpty ()) { // if data received then get it in a variable uartReceiveByte (&dataIn); // do whatever u wish with dataIn }
  • 14.
  • 15.
    AVR Fuse settingsSUT 1:0 = 11 12 – 22 pf >= 1.0 1011, 1101, 1111 0 12 – 22 pf 3.0 – 8.0 1111 1 12 – 22 pf 0.9 – 3.0 1101 1 - 0.4 – 0.9 1010 1 C1 & C2 Frequency (MHz) CKSEL3:0 CKOPT