Top Banner
31 st Jan to 1 st Feb 2008 TECHNOLOGY ROBOTICS SOCIETY Indian Institute of Technology, Kharagpur
15
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Robotix Tutorial 9

31st Jan to 1st Feb 2008

TECHNOLOGY ROBOTICS SOCIETY

Indian Institute of Technology, Kharagpur

Page 2: Robotix Tutorial 9

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

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

ATmega8 – PDIP Package

Page 5: Robotix Tutorial 9

ATmega8 – TQFP Package

Page 6: Robotix Tutorial 9

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

STK200 ISP Dongle

PonyProg Programming Software http://www.lancos.com/prog.html

Page 8: Robotix Tutorial 9

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

WinAVR IDE Screenshot

Page 10: Robotix Tutorial 9

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

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

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

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

Crystal Oscillator Clock Source

Page 15: Robotix Tutorial 9

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