robotix tutorial 9
TRANSCRIPT
![Page 1: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/1.jpg)
31st Jan to 1st Feb 2008
TECHNOLOGY ROBOTICS SOCIETY
Indian Institute of Technology, Kharagpur
![Page 2: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/2.jpg)
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/
![Page 3: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/3.jpg)
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
![Page 4: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/4.jpg)
ATmega8 – PDIP Package
![Page 5: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/5.jpg)
ATmega8 – TQFP Package
![Page 6: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/6.jpg)
ISP Flash Memory ISP : In-System-Programmable Flash
ROM No need of specialized programmer
hardware No need to remove processor from
circuit for reprogramming
![Page 7: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/7.jpg)
STK200 ISP Dongle
PonyProg Programming Software http://www.lancos.com/prog.html
![Page 8: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/8.jpg)
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/
![Page 9: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/9.jpg)
WinAVR IDE Screenshot
![Page 10: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/10.jpg)
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/
![Page 11: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/11.jpg)
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 ();
![Page 12: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/12.jpg)
ADC’s & Analog ComparatorDDRA = 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);
![Page 13: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/13.jpg)
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
}
![Page 14: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/14.jpg)
Crystal Oscillator Clock Source
![Page 15: Robotix Tutorial 9](https://reader036.vdocuments.us/reader036/viewer/2022081514/5561ab9ed8b42afd708b524b/html5/thumbnails/15.jpg)
AVR Fuse settingsCKOPT CKSEL3:0 Frequency
(MHz)C1 & C2
1 1010 0.4 – 0.9 -
1 1101 0.9 – 3.0 12 – 22 pf
1 1111 3.0 – 8.0 12 – 22 pf
0 1011, 1101, 1111
>= 1.0 12 – 22 pf
SUT 1:0 = 11