New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Introduction to Robotics

by: Antonina Wuckert

Introduction to Robotics ECE 450

Antonina Wuckert
GPA 3.94

Timothy Beatty

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Timothy Beatty
Class Notes
25 ?




Popular in Course


This 89 page Class Notes was uploaded by Antonina Wuckert on Monday September 28, 2015. The Class Notes belongs to ECE 450 at George Mason University taught by Timothy Beatty in Fall. Since its upload, it has received 59 views. For similar materials see /class/215019/ece-450-george-mason-university in ELECTRICAL AND COMPUTER ENGINEERING at George Mason University.

Similar to ECE 450 at Mason



Reviews for Introduction to Robotics


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/28/15
The Use of Microcontrollers Using A TMEL s A Tmega 168 as an example Programming a Microcontroller What s Needed 750 3400 Computer Programmer Microcontroller Software Development Board Connection Write Code JTAGCE DIP Simulate SP SOC AVR Studio 4 Programmer QFN Port BitBang Capabiity Serial ADAFruit ADCDAC Paralel SP PWM USB AVRISP Mk II USB Why Atmel s AVR Microcontroller a 9759 FOWSP lO RISC architecture with mostly xedlength instruction loadstore memory access and 52 generalpurpose reg1sters A twostage instruction pipeline that speeds up execution Majority of instructions take one clock cycle Up to 20Nle clock operation Wide variety of onchip peripherals including digital IO ADC EEPROM Timer UART RTC timer pulse width modulator PWM etc lnternal program and data memory Insystem programmable Available in 8pin to 64pin package size to suit wide variety of applications Up to 12 times performance speedup over conventional CISC controllers Wide operating voltage from 27 V to 60 V A simple architecture offers a small learning curve to the uninitated Scalability r39 w AVRCORE ATtiny25 Block Diagram Fl 1 Ehme W1 4 ATtiny2313 Block Diagram m 0quot w ATmega168 Block diagram T T i n39 1 Mnquot mm cp q Am a L E1 WWW miny Different Types of AVR Controllers AVR a Bit RISC Microcontmllers dill 5 AVE 8395quot 50 M39E39WDW39WE39S W 111111111111111111151111111Mamammmmm1114111 W1 111mm 111m 1121111111111 1111111191191171New 1171 1 11111171111111111 m 711mm 111mm WW 1111 111111 w 1111 mm mum1111111111 111111m111111511111111131quot1111mm1m 111111111117111411n 11 11111111111111 111 1111 111 11mm 1111111 111 1111111191111111111111711111 11111111111111111quotm1m11711111111111111 1411111113121 1wv11 r1112ma1mn1117 511mgizwxmwzmw 111M11u111wm111111117111171111m1c1511171m1111m quotquot quot quot quot W 11111111111111111711mmm 111711 111 mm mun11111711111111111 111 1111 11ms111111113111117m11a1mw111111111111511101111 a 1 117111 quotWNW 11mwmeam1mmm111171111111111111111 1111111111111111111111111111111111 1111wmmm1m1111mm 1 11111111111111 1111115111 mum11111711m51m11m1quot 111111111111 1m 71111 1111111111 111111171471111172111 21 1111111quot 1111 471111 111111 1 13111 111 11 g PM 111 m 5111 11111 111111 1111 1 1111111 111 1 11111 Mr 11121111111 11111111111 1111111 1aquot 1111 am a 1 111 111111 11 1111 1L 1 11 11 11 11 1 1 1 1 7 1 11111 11 11 I 1 1 1 7 11 11 11 1 11 1 11 1 1 1 111quot 12 112 11 7 11 1 7 7 7 7 mm 1111 1 7 1111 11 39 H7 11 1 39 111 11 1 1 W 1111 111 111 1 7 71 11 7 7 7 MW 1111 1 7 1 w W m 1 7 71 1 7 7 7 V 11111 1 7 39139 W W 1 111111 11 1111 1 111 11 1 1 1211 Mum 11 1111 11 1 72111111151331111 1 1 if m 3 1 11 71 7 1 5 WM 111111 1 111 1 11 111 1111111 111 1 11 1 1111 M M r 1511 1711111 11W 1 1 1 11 1 111 1 111 39 17 7 7 39 7 7 1 7 111 i 1 111 WW 1 1111 1 11111 1 1111 11 1 1 11 111 11 11 1 11111111111111 1 1 111111 1 1111 11 WWW 11 1111 111 111 11 11m111111111 1 7 M7 M11 1 111 11 39 1 1111 11 11 11 1111 11 111 1 1w 1 111111 1 lt11 11111111111111111 11 1111 111111 1111 112111 1 11 u v 1 1 1 11 111 111 11 1 7 111391 11111 W V 1 1 1 1 1111111 11111 1 1 11111 1111111111 1 1 1 1 111 11 1 1 1 1 11 111 1 quot1M 1111 1 39 1 1 1 11115111151 1 1 7 1 1 111 7 7 11 1 7 7 VW 111111 7 1 1 mmm n V WM 11111111 111111 11 11111111 1 1 11 11 1 1 511 1 111111 1 111 1 1 1111 1 11 1 11a 11 11 1 1 W 1 1111111 11111 17 11 111 7 a 1 11111111111111 1 73 4411111 1 111 117111 g 1 1 1 111C111 1511 M1111 1 1 11117111111 Indianwhom 1111111 More Product Available Onlin wwwdi ikey1com More Product Available Online wwwdigikeycom 474 mm ToIIrFme 40044130539 Phone 213 81 674 v Fax 21868173390 roIIFm1rsmu4539 Pnone215631v8614 Faxz1ssa13uu mm 475 ATmega168 Pins PDIP J PCINT14RESET PCB C 1 28 1 PCS ADCSSCLPCINT13 PCINT16RXD PDD C 2 27 3 P04 ADC4SDAPCINT12 PCINT17TXD PD1 I 3 26 3 P03 ADC3PCINT11 PCINT18INTO PD2 C 4 25 l PC2 ADCZPCINT10 PCINT19OCZBINT1 PD3 C 5 24 l PC1 ADC1PCINT9 PCINTZOXCKTO PD4 I 6 23 j PCO ADCOPCINTS VCC C 7 22 3 GND GND C 8 21 l AREF PCINTGXTAL1TOSC1 PBB I 9 20 j AVCC PCINT7XTAL2TOSC2 PBT C 10 19 3 PBS SCKPCINT5 PCINT21OCOBT1 PD5 C 11 18 j PB4 MISOPCINT4 PCINT22OCOAAINO PDB C 12 17 j PB3 MOSIOCZAPCINT3 PCINT23AIN1 PD7 C 13 16 j PB2 SOC1BPCINT2 PCINTOCLKOICP1 PBO C 14 15 j PB1 OC1APCINT1 Memory Flash Code Memory 16bit words starting at OXOOOO Size dependent on AVR microcontroller Nonvolatile Readonly memory writing is external to code Data Memory General Purpose Registers 32 8 bit registers O Registers Two 8 bit registers for each O line SRAM 8 bit memory with siz dependent on nVR microcontroller EEPROM Memory Typically reserved for variables that must retain their value in the event of a shutdown e s stem calibration data uni ue to each board Slow speed writing 1 millisecond for l byte of memory Limited number of write cycles AVR Risk Architecture I I Address The Register File 01 39 39 02 32 8bit registers 0F 10 1 1 XRegister Low Byte XRegister High Byte Y Register Low Byte YRegister High Byte 1E ZRegister Low Byte 1 f ZRegister High Byte FIGURE 34 AVR register file IO Memory Registers SREG Status Register SP Stack Pointer Register GIMSK General Interrupt Mask Register GIFR General Interrupt Flag Register MCUCR MCU General Control Register MCUSR MCU Status Register TCNTO TimerCounter 0 Register TCCROA TimerCounter 0 Control Register A TCCROB TimerCounter 0 Control Register B OCROA TimerCounter 0 Output Compare Register A OCROB TimerCounter 0 Output Compare Register B TIMSKO TimerCounter O Interrupt Mask Register TIFRO TimerCounter O Interrupt Flag Register EEAR EEPROM Address Register EEDR EEPROM Data Register EECR EEPROM Control Register PORTB PortB Data Register DDRB PortB Data Direction Register PINB Input Pins on PortB PORTD PortD Data Register DDRD PortD Data Direction Register PIND Input Pins on PortD SPI IO Data Register SPI Status Register SPI Control Register UART IO Data Register UART Status Register UART Control Register UART Baud Rate Register ACSR Analog Comparator Control and Status Register Parallel lO Ports Most generalpurpose lO devices Each lO Port has 3 associated registers 1 DDRX Where X is A B C Data Direction Register Port x Determines which bits of the port are input and whic a oput DDRB 0x02 sets the second lowest of port B to output 2 PORTX Port Driver Register PORTB 0x02 sets the second bit of port B and clears the others 3 PINX Port Pins Registers Returns the status of all 8 port B pins unsigned int x x PINB Places the status of port B into variable x InputOutput Ports All I orts initially set to in ut Must declare all output pins using DDRx Data Direction Registry Port x Input port pins are floating Can supply a pullup resistor by writing logic 1 to the corresponding bit of the port driver register DDRA OXOC lower 2 are input next two bits are output PORTA 0x03 enable internal pullups on lowest 2 bits Port pins in output mode are typically capable of sinking 20 mA but source much less Source 0 01195 XElithcl L 01195 XElithcl Output Port Sink vs Source When does the LED light for the Sink Source Which gives the brighter light x Set DDRBx to 1 5V 0 01195 XElithcl L 01195 XElithcl To Drive an LED include ltavriohgt include ltavrdelayhgt int mainvoid DDRB 1ltltPORTB4 PORTB 0b00010000 while1 deayms 3000 PORTB 0b00000000 deayms 3000 PORTB 0b00010000 To find definitions like PORTB4 open the m48definc file under CProgram FilesAtmeAVR ToosAvrAssemblerAppnotes VCC PCI NT4XTAL2 PB4 GND quot7 LED is on whenever PB4 is zero m168definc Specify Device device ATmega48 Bit Definitions IIO Register Definitions Port B equ PORTB7 7 PORTB equ PORTB6 6 equ OCR1BH 88 TIM1 equ PORTB5 5 equ OCR1BL 8A equ PORTB4 4 equ OCR1 AH 89 equ PORTB3 3 equ OCR1 AL 88 equ PORTB2 2 equ CR1H 87 equ PORTB1 1 equ CR1L 86 equ PORTBO 0 equ TCNT1H 85 equ TCNT1L 84 equ PB7 7 PORTB equ TCCR1C 82 equ PB6 6 equ TCCR1B 81 equ PB5 5 equ TCCR1A 80 equ PB4 4 equ PB3 3 equ TIMSK2 70 TIMER IRQ equ PB2 2 equ TIMSK1 6F equ PB1 1 equ TIMSKO 6E equ PBO 0 equ PCMSK2 6D PCINT equ DDB7 7 DDRB equ PCMSK1 6C equ DDB6 6 equ PCMSKO 68 equ DDB5 5 equ DDB4 4 equ SREG 3F CPU equ DDB3 3 equ SPH 3E equ DDB2 2 equ SPL 3D equ DDB1 1 equ DDBO equ PORTD 08 PORTD equ DDRD 0A equ PINB7 7 PNB equ PIND 09 equ PINB6 6 equ PORTC 08 PORTC equ PINB5 5 equ DDRC 07 equ PINB4 4 equ PINC 06 equ PINB3 3 equ PORTB 05 PORTB equ PINB2 2 equ DDRB 04 equ PINB1 1 equ PINB 03 equ PINBO CProgram FilesAtmeAVR ToosAvrAssemblerAppnotes Limited Agenda for Microprocessor External Interrupts PCINT 24 different interrupts Timers Counters 8bit Pulse Width Modulation Setup of Software Hardware Tools Interrupts Interrupts vs Polling Interrupts may lead to serious problems Disable interrupts before reading variables External Interrupts External Interrupt Request INTO Pin Change Interrupt PCINTO Internal Interrupts Key Registers to enable PCINT external interrupts 1 SREG 2 PCICR 3 PCMSK were is either 0 1 or 2 20 1 SREG AVR Status Register Bit 7 I Global Interrupt Enable The Global Interrupt Enable bit must be set forthe interrupts to be enabled The individual interrupt enable control is then performed in separate control registers If the Global Interrupt Enable Register is cleared none of the interrupts are enabled independent of the individual interrupt enable settings If you don t set the I bit in SREG there will be no internal or external interrupts SREG 1ltltSREGI 21 2 PCICR Pin Change Interrupt Control Register PCIEZ PCIEl PCIEO R R R R R RW RW RW 0 0 0 0 0 0 0 0 Bit PCE Pin Change Interrupt Enable where is 2 1 or 0 Whet the PCE bit is set one and the lbit in the Status Register SEG is set one pin change interrupt is enabled Any change on any enabled pin will cause an interrupt Ihetcorresponding interrupt on Pin Change Interrupt Request is executed from the PCl l interrupt ec or PCE2 enables PCINT 23 16 pins and are enabled individually by the PCMSK2 register PCE1 enables PCINT 14 8 pins and are enabled individually by the PCMSK1 register PCIEO enables PCINT 7 0 pins and are enabled individually by the PCMSKO register in enable PCINTIA you must enable pins 14 through 8 by setting ulc 1 CIEl bit in the PCICR Register PCICR 1ltltPCIE2 22 3 PCMSK Pin Change Mask Register PCINT20 PCINT19 PCINT 1 8 PCINT17 PCINT16 PCINT 23 PCINT22 PCINT21 PCINT14 PCINT13 PCINT12 PCINTl 1 PCINT 1 0 PCINT9 PCINTS PCINT3 PCINT2 PCINTl RNV RNV PCINTO PCINT7 PCINT6 PCINTS PCINT4 RNV RNV RNV RNV O O O O O RNV RNV O O O Bit 7 0 Pin Change Enable Mask Each PCINT bit selects whether pin change interrupt is enabled on the corresponding O pin If PCINT is cleared the pin change interrupt on the corresponding O pin is disabled We ve set the PCIEZ pin in register PCICR to allow interrupts now we must use the Pin Change Mask register to set the speci c pin before the microcontroller will enable an interrupt 0n PCINT16 23 PCMSK2 1ltltPCINT16 Enabling External Interrupts The following code enables interrupts on the PCINT16 pin eg pin 2 SREG 1ltltSREGI PCICR 1ltltPCE2 PCMSK2 1ltltPCNT16 What do you want to happen after an interrupt is detected 24 AVR My Home Page Mam Page User Manual m Libmn Reference Agghab eu cal Index AVR Libc De augment Page Examgle Pm 39ects Here is a List of an mndnles A r ltn l dela lturilpari mam Mayhem 5 ltinm es IntegerType enmersinns 39c ltstdi an ngt esm ltstring ltarrbnnrh BuntlnaderSuppnnfzilivies e 39reeprnmhgt EEYROM handling ltavn fnseJL Fuse Suppnn lta39rinterrnpthgt Imerrnpts lt 7quot AVR devicespeemc Io de nidnns lt239 391 Ln itSnp n Pu er Rednctinn de5hgt Special In I Add l n a innnal nntes mm ans ltavn slee lta r39ers ltavr dx ltn l2mm39 ltnriluc 6 ID rnnernanagemeu nn zxrelibm39ersinn b v chgt azchdng came handl nmpntannns I Cnm39enience unr nn i r5 Bash bns ltn ldela b V hgt Pariq bit genera nn ck r lta39rpgmspzceb ngram Space names Iridefshgt and Sleep Made arms nr busyr mil delay lnnps d lay lnnps avr ljbc NIodules ing Ammicalh and NnnrAmlnically Execmed Cnde Blacks In AVR Studio select Help gt avr Ibc Reference Manual Defining an Interrupt Routines PCINTOvect Pin Change Interrupt Request 0 ATmega162 ATmega165 ATmega165P ATmega168P ATmega169 ATmega169P ATmega325 ATmegaSZSO ATmega3250P ATmega328P ATmega329 ATmega3290 ATmega3290P ATmegaSZHVB ATmega406 ATmega48P ATmega645 ATmega6450 ATmega649 ATmega6490 ATmega88P ATmega168 ATmega48 ATmega88 ATmega640 ATmega1280 ATmega1281 ATmega2560 ATmega2561 ATmega324P ATmega164P ATmega644P ATmega644 ATtiny13 ATtiny43U ATtiny48 ATtiny24 ATtiny44 ATtiny84 ATtiny45 ATtiny25 ATtiny85 AT90USB162 AT90USBBZ AT90U8D287 AT90USB1286 AT90USB647 AT90U88646 PCINT1vect Pin Change Interrupt Request 1 ATmega162 ATmega165 ATmega165P ATmega168P ATmega169 ATmega169P ATmega325 ATmegaSZSO ATmega3250P ATmega328P ATmega329 ATmega3290 ATmega3290P ATmegaSZHVB ATmega406 ATmea48P ATmea645v ATme39a6450 ATmea649v ATme39a6490 ATmega88P ATmega168 ATmega48 ATmega88 ATmega640 ATmega1280 ATmega1281 ATmega2560 ATmega2561 ATmega324P ATmega164P ATmega644P ATmega644 ATtiny43U ATtiny48 ATtiny24 ATtiny44 ATtiny84 AT90USB162 AT90USBBZ PCINT2vect Pin Change Interrupt Request 2 ATmega3250 ATmega3250P ATmega328P ATmega3290 ATmega3290P ATmega48P ATmegm6450 ATmeUMG 0 ATmeDMBJD ATmega168 ATmega48 ATmega88 ATmega640 ATmega1280 ATmega1281 ATmega2560 ATmega2561 ATmega324P ATmega164P ATmega644P ATmega644 ATtiny48 ISRPCNT2vect Code to handle the event Note that this routine is called Whenever pins PCINT2316 have logical changes How do you determine which pin actually changed 26 Example of External Interrupt include ltavriohgt include ltavrinterrupthgt ISR PCINT2vect Code to execute when external interrupt on PCINT23 16 is triggered by a logic change PORTB PORTB quot 0X02 int mainvoid Setup for External Interrupt PCINT16 uses pin 2 or PDO SREG E l 39 1ltltSR G Enables global interrupts PCICR 1ltltPCE2 Enables vector interrupts on PCINT23 16 PCMSK2 1ltltPCNT16 Enables individual interrupt PCINT16 only DDRB 1 ltlt PORTB1 while1 27 TimersCounter Most commonly used complex peripherals Think of them as binary upcounters In timing mode count time periods In counting mode counting events or pulses 8bit and 16bit Timers available ATmega168 TimerCounterO 8bit TimerCounterwith Prescaler Two PWM Channels TimerCounter1 16bit High Speed TimerCounterwith Separate Prescaler 2 High Frequency PWM Outputs TimerCounter2 8bit TimerCounterwith Prescaler Two PWM Channels 28 Fast PWM Mode High Frequency Single Slope Counter Counts only from Bottom to Top Suited for power regulation rectification and DAC application Phase Correct PWM Mode Lower Frequency Dual Slope Counter Counts up the down Suited for motor control applications PWM Modes I op OXFF TimercounterVllLllZOCROX Value Register n Bottom 0X00 lt 4 TCNTn 39 OCn V E Period I 12345e 7 gt I I Top OXFF I TCNTn E E OCROX Value I I l l Bottom 0x00 I I I I I I v v v v V OCn l l L OCH l F Period lt 1 2 3 29 Phase Correct PWM TimerCounter O 8bit Set Frequency Prescaler f flclk71O MW N1TOP N is prescaler divider U 8 64 256 or 1024 Determine Bit Resolution logTOP 1 RPCPWM 10g Set Duty Cycle Determined by OCROX 30 8bit Phase Correct PWM TimerCounter 0 Key Registers to enable Phase Correct PWM 1 TCCROA TimerCounterO Control RegisterA 2 TCCROB TimerCounterO Control Register B 3 OCROx Out ut Com are Reiisterx Output on PD6 Pin 12 for OCOA and PD5 Pin 11 for OCOB Where X stands for either A or B We 7 use A for our example 31 1 TCCROA Register COMOA1 COMOAO COMOB1 COMOBO WGMO1 WGMOO RW RW RW RW R R RW RW 0 0 0 0 0 0 0 0 Bit 7 6 Compare match OutputA Mode These bits control the Output Compare pin OCOA behavior If one or both of the COMOA01 bits are set the OCOA output overrides the normal port functionality of the HO pin it is connected to Note however that the Data Direction Register DDR bit corresponding to the OCOA pin must be set to enable the outut driver 0 0 Normal port operation OCOA disconnected WGM02 0 Normal Port Operation OCOA Disconnected 0 1 WGM02 1 Toggle OCOA on Compare Match Clear OCOA on Compare Match when upcounting Set 1 O OCOA on Compare Match when downcounting Set OCOA on Compare Match when upcounting Clear 1 1 OCOA on Compare Match when downcounting We ll set COMOA to 3 TCCROA 3ltltCOMOAO I 32 1 TCCROA Register Continued COMOA1 COMOAO COMOB1 COMOBO Bit 10 Waveform Generation mode Combined with the WGM02 bit found in the TCCROB Register these bits control the counting sequence ofthe counter the source of the maximum TOP counter value and what type of waveform generation to be used Normal OXFF Immediate MAX PWM Phase Correct OxFF TOP BOTTOM CTC OCRA Immediate MAX Fast PWM OXFF BOTTOM MAX PWM Phase Correct OCRA TOP BOTTOM Fast PWM OCRA BOTTOM TOP Set for Phase Correct PWM Note we still have to set WGM02 in the TCCROB Reister TCCROA 3ltltCOMOAO1ltltWGMOO 33 2 TCCROB Register I ritzgi il FOCOA FOCOB WGM02 CSOZ CSO1 Bit 3 Waveform Generation Mode Use table from previous slide Normal OXFF Immediate MAX PWM Phase Correct OxFF TOP BOTTOM CTC OCRA Immediate MAX Fast PWM OXFF BOTTOM MAX PWM Phase Correct OCRA TOP BOTTOM Fast PWM OCRA BOTTOM TOP Setting for Phase Correct PWM TCCROB OltltWGM02 34 2 TCCROB Register Continued KL FOCOA FOCOB WGM02 CSOZ CSO1 Bit 20 Clock Select These bits select the clock source to be used by the TimerCounter No clock source TimerCounter stopped clkioNo prescaling clkio8 From prescaler clkio64 From prescaler clkio256 From prescaler clkio1024 From prescaler External clock source on T0 pin Clock on falling edge 0 0 0 0 1 1 1 1 oooo O O O O External clock source on T0 pin Clock on rising edge Depends on the Frequency needed We ll choose a prescaler or d TCCROB OltltWGM022ltltCSOO 35 3 OCROA Register The Output Compare RegisterA contains an 8bit value that is continuously compared with the counter value TCNTO A match can be used to generate an Output Compare Interrupt or to generate a waveform output on the OCOA pin For PWM this will be how you set the duty cycle by setting it equal to the duty cycle times to TOP value For example to set this to a 50 duty cycle for our example OCOA 050255 2128 Or we can let the computer do the math I OCOA unsigned int 050 255 36 Bytes Decimal Binary Hexadecimal 0 0000 0x0 1 0001 0x1 2 0010 0x2 3 0011 0x3 4 0100 0x4 5 0101 0x5 6 0110 OX6 7 0111 0x7 8 1000 OX8 9 1001 0x9 10 1010 0xA 11 1011 OXB 12 1100 0x0 13 1101 0xD 14 1110 0xE 15 1111 OXF 37 Arithmetic Operators Data Access and Size Operators Miscellaneous Operators Relational amp Logical vremww Operator Name Example De ned Greater than x39w 1 if 3 is greater than 3 otherwise 0 Greater than 37 1 if x is greater than or equal to or equal to otherwise CI a Less than 1 if x is less than v otherwise 0 Less than or 1 if x is less than or equal to y orhem39ise equal to 0 Equal to 1 if equals 17 olhenrise CI For equal to 351 1 if x is not equal to i2 otherwise 0 l Logical NOT l 1 if is 0 olhem ise D an Logical AND may 0 if either x or y is Os otherwise 1 I Logieal OR a I II if both 2 and j are D otherwise l 41 Bitwise Operators AND OR XOR I 0A00 0amp10 011 0A11 1amp00 101 01 IlSv Steps to Programming 1 Write Program AVR Studio a Write Code b Debug in Simulator mode c Create hex code 2 Transfer code to Chip a Connect USB Programmer AVRISP MKII to computer and breadboard b Use AVR Studio to download program 3 Place chi in final 7 osition and run 43 AVR Studio 413 Select New Project mm mnmna HiMaer7 m an 35 mansand5m resmnymaaus O Emmemsand satg sTKSnnjlmdaps O Emmems and Sahg Pm123 33v WMarZ WU on 39 Create a new Project SelectAVR 600 for programming in C Select Project Name no spaces Set Location to yourfolder Click Next 1 Use AVR Simulator 2 Select ATmega48 3 Click Finish Create the Code 1 Enter Code d 2 Select BUIId DDRE1ltltFORTEM 3 Choose Debug We WW delayJucuLZGUEln up23EIEIEIE 4qu mmm 174 bytes 35 mm mm daca baamaaexy u bytes his naln mm mm a Data mm Debug Program maluhmld 9an nwoxmaa FORTE Dbnnm u n ammo amp Walk through code m Egzriygzzmsasm SREE EIIZIEEEEI FORTE nhnumnnnn PORTB DDRB and PINB in lower right pane Note LED lights up when PB4 is off qumm 174 bytes mm Jan La 5 daca haauaaaezy 17 am n mm mm mm Liara bss mlnlt m Smu atm Mn Setup Breadboard for Programming ATmega48 Connect USB Programmer to computer and 6pin header to breadboard 49 Atmel s AVRISP mkll USB ISP Idle No target power Green Idle With target power Orange Busy Pro rammin Reversed target cable connection or orange blmkmg not correct pullup on the reset line Red blinking Shortcircuit on target I RedOrange blinking Upgrade mode There is also a green LED inside the AVRISP mkll enclosure next tothe USB connector This LED indicates USB tramc MISO 1 2 WC scx 3 4 MOSI RESEr 5 5 GND Make Connection to AVRISP mkll Click Connec nt manVDd DDRE FORTE whlle 1ltltFORTEA r EIbEIEIEIIEIEIEIEI EDMPAWDR 1 EDNVERTER dehyJuuijnnnn FORTE EIbEIEIEIEIEIEIEIEI dehyJuuijnnnn FORTE EIbEIEIEIIEIEIEIEI gunman cuqum 4qu mmm 174 bytes 35 mm mm daca baamaaexy Dana u bytes mm mm mm bss mmm Make Connection to AVRISP mkll Select AVRISP mkll and click Connect WW em ewe Tm Id sum Dunne2K Ad we Dmgvammev used by me mess the ngvammev ndudndn the ddxney Nme that AheJTAE EE eennm he used larvmgvammmg es ang as u s Dunne ed m e dehdddmd sessmn m that eese se ecl SADD Dehugdmd lust D sednneeted Made Verify Parameters 13 IgtltI Mam mm mm 1 mam Advanced HW 52mm HW my Ama and swam am New Correct Device 2 Select ISP Frequency gt 5K Readsmm Caution too high and it won t transfer SETSMmeamayge sgufgs SP Fvequency 57 s WrRe Cluse be by than 14 cf the target Seumgxsvvavamelev SDEIXE3 EIK Verify Parameters 23 la Main ngvam Fugtgt sstrpnaw i RSTDlSBL E DWEN E saw E gov E Be sure to select the Emma Wwaggimam v Internal clock as selecting cm Kum E R an external may lockup the Sigma im m9 W1StalipimemDWNRgsn WWW device until you connect an oscillator mm w W W W W l7 Auiavead Small Wami 5 l7 quotg p My allei WWW Piagiam My A Selling made and device paismeleis uKl Enleiing Diagiammmg made EIKl Reading Vases law in high nxsz nxDF anF uKl Leaving Piugiamming Nada um i Verify Parameters 33 Set Path to HEX file r I IR Distance SENSOR The Sharp GP2D02 IR Distance Measuring Sensor IR Sensor 1 Curve Graph 07 RESPONSIVITY AW 190 300 400 500 600 700 800 900100011001200 WAVELENGTH nm A UVi Enhanced Silicon Detectors B Blue Enhanced Silicon Detectors C Silicon Carbide UV Detectors D Visible Light Detectors E Daylight Filter Detectors F GaAlAs Photodiodes GM CdS Photoconductive Cells IR Sensor 2 GP2D02 SENSOR Measures distance in range from 20 to 80cm Designed to interface to small microcontrollers It s relatively insensitive to the color and texture of the object at which it is pointed Low current consumption at standby mode Approximately 3 HA Actual Sensor Size IR Sensor 3 Distance Measurement by Triangulation a farohjectplane bundled beam to the I t nearobjeclplane Reflected beam IS receive by the photo detector 0 The angle Of the IRLED photodeteclor received beam dependson dlStance Two Different Object Planes of the object plane IR Sensor 4 Structure of Photo Diode Nconductive substrate layer is an I I P Isolation layer 5 Pconductive layer m 3 is embedded in V V isolation layer from 39 39 Structure of a position sensitive IR lrradlated photo diodePSD Contact of the p layer is made on left and right side IR Sensor 5 How Does A PSD Measures Distance Spot irradiation in the center of the p layer both currents 11 12 will have same value Spot irradiation goes to the right the 11 will decrease and 12 will increase by the same amount The difference between the 11 and 12 will give the location of a spot irradiation on PSD IR Sensor 6 Circuit Diagram of a PSD Diodes in the OpAmp s feedback give a logarithmic behavior to the ltoV conversion circuit Collector current Ic in each Opamp is identical to the I1 and I2 Third OpAmp processes the difference of the two output voltages from previous OpAmps Vo vT nl12 UT Inljl 1 10 3 r EE m R2 Circuit for position sensitive Currenttovoltage conversion IR Sensor 7 Distance Chart Distance vs irRange Value Distance inches IR Sensor 8 Timing When interfacing with any type of hardware timing is anissue Vin and Vout are control measurements Vin drops to low for minimum 70ms IR LED transmits 16 pulses towards the object Mean value of 16 measurements reduces possmle errors is 39w m illlilililllllli USE L 3I Timing Diagram for Measurement and data handling IR Sensor 9 Configuration Sensor has four pins Pin 2 IN Green Wire from the sensor connects to IR OUT be careful not to cause a shortcircuit Pin 1 Black connects to ground IR IN digital 7 port Pin 3 Red connects to 5V IR IN Pin 4 Yellow connects to the Signal IR IN Sharp GPZDO2 Pin Out 4 3 2 1 Slgna39 5v IN Ground VOUT ma a wwwzsia t e 5 51 a S a 2 E 32 2 vs wasms if R OUT W E a is 39n a 4m VIN Handy Board Connection IR Sensor 10 Example of Control Program use pulseicb int range pulse1 Update irRange to new detected distance return irRange set variable distance equal to irRange Note You must load the compiled assembly object file pulseicb off the class website to have access to pulse and irRange Put in same folder as your ic project irRange is treated as a local variable and is not available outside this routine Note that you do not have to define irRange in your code IR Sensor 11 Power Sources amp Management ECE 450 Batteries Alkaline Power capacity Weight Life cycle Cost Energy Output Mediumquotlt Heavy 30 Watt hours Kg Onetime use Inexpensive Very Low Performance at low charge Weak Self discharge rate Cell Voltage Low lt 2 of charge per year 152V Power capacity Weight Life cycle Cost Energy Output Low Heavy 30 Watt hours Kg 800 charges Inexpensive Very Low Performance at low charge Weak Self discharge rate Cell Voltage Low lt03 of charge per day 2V NiCad Nickel Cadmium Power capacity Weight Medium Life cycle Cost Energy Output Medium 40 60 Watt hours Kg 1500 charges memory effect Inexpensive Medium Performance at low charge Weak tapers down gradually Self discharge rate Cell Voltage Medium 1 of charge per day 12V httpwwwe1ectrictoolguidecomtypesofbatteries Batteries Power capacity High NIMH Weight Light 60 80 Watt hours Kg NICkel Metal Life cycle 1000 charges Hydride Cost Medium some higher capacity models get expensive Energy output High appropriate for highdemand applications Performance at low charge Strong dies suddenly Self discharge rate High 4 of charge per dayquotlt Cell Voltage 12V Power capacity High Very High thh mm Weight UltraLight 100 Watt hours Kg Liion Life cycle 1200 charges Cost High Energy Output High Performance at low charge Strong usually gives a warning before dying Self discharge rate Low lt02 of charge per day Cell Voltage 36V Power capacity 2 to 3 times over Liion batteries Fuel cell Weight UltraLight 100 Watt hours Kg Life cycle Refilled with methanol or ethanol Cost High 400 httpwwwelectrictoolguidecomtypesofbatteries Capacity Discharge vs Voltage anum Inn an r 25 5 2o 7 um Acid g 5 x W 8 mm mm zn MnOl Alluline zo w so an Percent m carzany mscmmeu Imp waw mamyufmbms cambananas 5mm Temperature Effects Lithium Ion Batteries httpwwwsocietyofrobotscombattedesshtrnl Storage Characteristics Lithium Ion Batteries Storage characteristics 1W3 2039 g BUD I H m i 5 EULD 5 E mm D 3 2cm 110 D 4 E 12 16 Storage Tlrne ISLquot43933ij httpWWWsocietyofrobotscombatte esshtml Discharge Rates Lithium Ion Batteries Va tage m 14C 131 I I n I 4 3 4 E 6 T 3 Capacity I39 An C FO httpWWWsocietyofrobotscombatte esshtml Alkaline Batteries Delivered apae ity vs Fewer Drain Lmnd new ml 05 a ampere Hams m 113 05 9quot Lil I Fewer W Not Fit for High Drain Electronic Devices Battery Connections Parallel Connection Series Connection 15v15v 15V 15V I If GND m EHHHH Voltage Regulators MC7800 MC7800A LM340 LM340A Sen39es NCV7805 APPLICATIONS INFORMATION Design Considerations The MC7800 Series of fixed voltage regulators are designedwith Thermal Overload Protection that shuts down the circuit When 39 an excessive power overload condition Internal Short Circuit Protection that limits e maximum current the circuit Will pass and Out ut Transistor Safer ea Compensation that reduces the output short vo tage across the pass transistor 15 increase many low current applications compensation capacitors are not require However it is that the regulator input be bypassed 39 l 39 to the E l E E 3 a a o 1 S 1 m E r on STANDARD APPLICATION I lnput MC78XX L ON 033 uF I Output J 00quot A common ground is required between the input and the output voltages The input voltage must remain typically 20 V above the output voltage even during the low point on the input ripple voltage XX These two digits of the type number indicate nominal voltage Cm l5 required if regulator l5 located an appreciable distance from power supply lter CO is not needed for stability however ll does improve transient response Values of less than 01 HP could cause instability 11 Typical Bases 39 39 TO220 TO92 8DIP 8SMD E Part number JILEI El E 74LSO4 Index Mark 0582 D EI EI EI EI39EI 1 2 Date code Schematic for a simple 7805based power supply Unregulatedinput From 9V battery Or battery pack 7 VDC to 20 VDC 0 C1 1 HF 39 Regulated Output C2 01m T0 Robot Circuits 5 VDC Schematic for a simple 7805based power supply From 9V battery 0r battery pack T0 Robot Circuits 7 VDC to 20 VDC D 5 VDC OT C3 C1 l C2 100 HF 1 HF 01LF o L T T Circuit Noise Bypassing is the reduction of high frequency current flow in a high impedance path by shunting that path with a bypass usually a capacitor Bypassing is used to reduce the noise current on power supply lines Decoupling is the isolation of two circuits on a common line The decoupling network is usually a low pass filter and the isolation is rarely equal in both directions Decoupling is used to prevent transmission of noise from one circuit to another In practice bypassing is always used when decoupling Most circuits require bypassing not decoupling Using decoupling techniques to accomplish bypassing Will give disappointing if not disastrous results Complete understanding of both concepts is Vital Schematic for a 7805based power supply From 9V battery Or battery pack I 7 VDC to 20 VDC T0 Rigoslggcnlts i l Bulk LIMF I ZZOHF IOOHF ZZOMF C3 ClBulk i C1 Types of Capacitors Mica lpF001uF 100600 Good Good Excellent good at RF Tubular ceramic 05pF100pF 100600 Selectable Several tempcos including zero Ceramic lOpFl uF 5030000 Poor Poor Moderate Small inexpensive very popular Polyester Mylar 0001uF50uF 50600 Good Poor Good Inexpensive good popular Polystyrene lOpF27uF 100600 Excellent Good Excellent High quality large signal lters Polycarbonate lOpF30uF 50800 Excellent Excellent Good High Quality small Polypropylene lOOpFSOHF 100800 Excellent Good Excellent High quality low dielectric absorption Te on lOOOpFZuF 50200 Excellent Best Best High quality lowest dielectric absorption Porcelain lOOpFO 1 HF 50400 Good Good Good Good longterm stability Glass lOpFlOOOpF 100600 Good Excellent Longterm stability Tantalum 01uF500uF 6 100 Poor Poor High capacitance polarized small low inductance Electrolytic 01uFl6F 3600 Terrible Ghastly Awful Powersupply lters polarized short life Double layer 01F10F 156 Poor Poor Good Memory backup high series resistance Oil 01uF20uF ZOO10000 Good Highvoltage lters large long life Vacuum lpFSOOOpF 200036000 Excellent Transmitters Diodes 20mA 39 10mA quotFORWARDquot 41 00V 50V quotREVERSEquot 1AA change mm Figure 167 Diode V I curve Schottky Diode Zener Diode Schematic for a 7805based power supply Reverse Current Flow Protection m 1N5817 SChOtth 5 2 T0 Robot Circuits c J 5 VDC II From 9V battery Cl C2 Or battery pack 1 F 0 1 F 7 VDC to 20 VDC T T 39 H C Schematic for a 7805based power supply Overload 0f Regulated Voltage D1 1N5817 T0 Robot Circuits Schottky D M 5 VDC E11 gr 1121erch C1 7 ZD1 7 VDC to 20 VDC 1 F T T 01uF F 51 223 C 20 Improvements to Simple 7805 Voltage Regulator Include the capacitors suggested by the manufacturer After that add a bulk capacitor to the regulated output and to the unregulated power supply Use a lowresistance pchannel power MOSFET to prevent damage from a reverse battery Add various low and mediumvalue capacitors of different chemistries and technologies at various places on the circuit board to collectively bene t form their individual strengths Include at least one 01 HF capacitor for every chip to bypass board impedance providing a local power supply and to decouple isolate and reduce circuit noise Put each capacitor as close as possible to its targeted chip and keep the lead length of each capacitor as short as possible Add a PPTC overcurrentprotection device to limit the maximum current that can ow through the robot Add a 56 V zener diode to the 5V regulated circuit to prevent damage om overload 21 Improved Schematic for a 7805based power supply 3 a E o E inquot p T0 Robot Circuits battery 1N5817 o a 5 VDC pack Schottky gt C4 C1Bulk C4 C1 C2 C23ulk r ZD1 1000M T 220m T TOJMFTIMF 01MFT TZZOMF 56VZener 1N5232B J 22 nation Auen Butterworth Filters Load 40


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.