Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009

4,546
views

Published on

CS4062 Masters in Interactive Media - Third Arduino Lecture - March 11th 2009 - University of Limerick. This lecture presents an introduction to motors, LEDs and Arduino with examples. This was aimed …

CS4062 Masters in Interactive Media - Third Arduino Lecture - March 11th 2009 - University of Limerick. This lecture presents an introduction to motors, LEDs and Arduino with examples. This was aimed at a digital media / music technology masters student audience.

4 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
4,546
On Slideshare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
236
0
Likes
4
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. Making Things Move, Lighting Things Up and AVR Programming CS4062 - Eoin Brazil - Semester 2 - 2009
• 2. Servos and Motors Motion linear or rotary Stepper Servo conversion issues Types DC Gearhead DC Motor Servo Stepper Gearhead
• 3. DC Motor 2 Connections Continual spin, given current & voltage Reversing current, reverses the direction Increasing the voltage, spins faster, decreasing the voltage, slows the spin High speed but low torque Gearbox can add torque but at the expense of speed
• 4. DC Motor Example
• 5. DC Motor Example
• 6. DC Motor Example
• 7. Three Pieces
• 8. Gearhead Motor DC Motor with gearbox Not fast but provide more torque Servo Motor Gearhead Gearhead motor with position feedback Feedback is often from potentiometer Pulsing the motor moves it to particular position within 180 degree range Can’t move 360 degrees but can be Servo positioned precisely within the 180 degree range
• 9. Stepper Motor Precise positioning & 360 degrees range Move in discrete steps around a circle A 200 step motor would move 1.8 degrees per step around the full 360 degrees Continuous rotation in either direction Good torque Complex to connect
• 10. Solenoids and Actuators Microactuators Linear Motion Actuator Pull or Push Types Solenoid Solenoid Actuator Microactuator
• 11. Motor Characteristics gears or direct rated voltage current (efﬁciency) - stall / running speed - spin / rpm, rps, Hz torque size, shaft diameter, shaft length position resolution (Servos & Steppers)
• 12. Advanced Mediation Lisa McElligott, 2000 interactive confessional box used real confessional box confessor was computer program interacted using a voice interface. scripted interactions with random noises to add to immersion suspension of disbelief realism
• 13. Weave Mirror Daniel Rozin, Weave Mirror, 2007 Mechanical mirror Any person standing in front of one of these pieces is instantly reﬂected on its surface. Side and back views Uses video cameras, motors and computers to achieve mirroring Sound aspect - soothing sound
• 14. Weave Mirror Daniel Rozin, Weave Mirror, 2007
• 15. Organic Energy Cloud
• 16. Motorised Cloud
• 17. PWM Analog input / output Duration of the digital pulse of voltage Microcontroller - HIGH 5V or LOW 0V ``Fake’’ it using PWM Duty cycle, ratio from low to high to low cycle LED dimming, DC Motor speed control, Piezo speakers, RC Servo positioning
• 18. Pulse Width Modulation
• 19. Wiring Diagram Schematic Diagram
• 20. RC Servo Motor Servo Motor Connections on Arduino Black wire would go to Grd pin Red wire would go to 5V power pin White wire would go to one of the digital pins on the board Colours can vary, Ground (black or brown), Power (red), Control (orange, yellow or white)
• 21. /* * NewSerialServo * -------------- * Servo control from the Serial port * * Alteration of the control interface to use < and > keys * to slew the servo horn left and right. Works best with * the Linux/Mac terminal quot;screenquot; program. * * Created 10 December 2007 * copyleft 2007 Brian D. Wendt * http://principialabs.com/ * * Adapted from code by Tom Igoe, http://itp.nyu.edu/physcomp/Labs/Servo */ /** Adjust these values for your servo and setup, if necessary **/ int servoPin = 2; // control pin for servo motor int minPulse = 600; // minimum servo position int maxPulse = 2400; // maximum servo position int turnRate = 100; // servo turn rate increment (larger value, faster rate) int refreshTime = 20; // time (ms) between pulses (50Hz) /** The Arduino will calculate these values for you **/ continued int centerServo; // center servo position int pulseWidth; // servo pulse width on next int moveServo; // raw user input long lastPulse = 0; // recorded time (ms) of the last pulse slide
• 22. /* Setup the necessary * NewSerialServo * -------------- * Servo control from the Serial port control values and * * Alteration of the control interface to use < and > keys * to slew the servo horn left and right. Works best with variables to store * the Linux/Mac terminal quot;screenquot; program. * * Created 10 December 2007 information * copyleft 2007 Brian D. Wendt * http://principialabs.com/ * * Adapted from code by Tom Igoe, http://itp.nyu.edu/physcomp/Labs/Servo */ /** Adjust these values for your servo and setup, if necessary **/ int servoPin = 2; // control pin for servo motor int minPulse = 600; // minimum servo position int maxPulse = 2400; // maximum servo position int turnRate = 100; // servo turn rate increment (larger value, faster rate) int refreshTime = 20; // time (ms) between pulses (50Hz) /** The Arduino will calculate these values for you **/ continued int centerServo; // center servo position int pulseWidth; // servo pulse width on next int moveServo; // raw user input long lastPulse = 0; // recorded time (ms) of the last pulse slide
• 23. // Main program setup void setup() { pinMode(servoPin, OUTPUT); // Set servo pin as an output pin centerServo = maxPulse - ((maxPulse - minPulse)/2); pulseWidth = centerServo; // Give the servo a starting point (or it ﬂoats) Serial.begin(9600); Serial.println(quot; Arduino Serial Servo Controlquot;); Serial.println(quot;Press < or > to move, spacebar to centerquot;); Serial.println(); } void loop() { // wait for serial input if (Serial.available() > 0) { // read the incoming byte: moveServo = Serial.read(); // ASCII '<' is 44, ASCII '>' is 46 (comma and period, really) if (moveServo == 44) { pulseWidth = pulseWidth - turnRate; } if (moveServo == 46) { pulseWidth = pulseWidth + turnRate; } continued if (moveServo == 32) { pulseWidth = centerServo; } // stop servo pulse at min and max on next if (pulseWidth > maxPulse) { pulseWidth = maxPulse; } if (pulseWidth < minPulse) { pulseWidth = minPulse; } } slide
• 24. // Main program setup void setup() { pinMode(servoPin, OUTPUT); // Set servo pin as an output pin centerServo = maxPulse - ((maxPulse - minPulse)/2); pulseWidth = centerServo; // Give the servo a starting point (or it ﬂoats) Serial.begin(9600); Setup servo its Serial.println(quot; Arduino Serial Servo Controlquot;); Serial.println(quot;Press < or > to move, spacebar to centerquot;); pin, its pulse, and Serial.println(); } its position. Setup void loop() { // wait for serial input serial connection if (Serial.available() > 0) { // read the incoming byte: moveServo = Serial.read(); for control // ASCII '<' is 44, ASCII '>' is 46 (comma and period, really) if (moveServo == 44) { pulseWidth = pulseWidth - turnRate; } if (moveServo == 46) { pulseWidth = pulseWidth + turnRate; } continued if (moveServo == 32) { pulseWidth = centerServo; } // stop servo pulse at min and max on next if (pulseWidth > maxPulse) { pulseWidth = maxPulse; } if (pulseWidth < minPulse) { pulseWidth = minPulse; } } slide
• 25. // Main program setup void setup() { pinMode(servoPin, OUTPUT); // Set servo pin as an output pin centerServo = maxPulse - ((maxPulse - minPulse)/2); pulseWidth = centerServo; // Give the servo a starting point (or it ﬂoats) Serial.begin(9600); Serial.println(quot; Arduino Serial Servo Controlquot;); Serial.println(quot;Press < or > to move, spacebar to centerquot;); Serial.println(); The serial input controls the } servo by the ‘<‘ or ‘>’ and keep void loop() { // wait for serial input if (Serial.available() > 0) { its speed within the safe range // read the incoming byte: moveServo = Serial.read(); // ASCII '<' is 44, ASCII '>' is 46 (comma and period, really) if (moveServo == 44) { pulseWidth = pulseWidth - turnRate; } if (moveServo == 46) { pulseWidth = pulseWidth + turnRate; } continued if (moveServo == 32) { pulseWidth = centerServo; } // stop servo pulse at min and max on next if (pulseWidth > maxPulse) { pulseWidth = maxPulse; } if (pulseWidth < minPulse) { pulseWidth = minPulse; } } slide
• 26. // pulse the servo every 20 ms (refreshTime) with current pulseWidth // this will hold the servo's position if unchanged, or move it if changed if (millis() - lastPulse >= refreshTime) { digitalWrite(servoPin, HIGH); // start the pulse delayMicroseconds(pulseWidth); // pulse width digitalWrite(servoPin, LOW); // stop the pulse lastPulse = millis(); // save the time of the last pulse } } // END of Main program
• 27. Pulse the servo every 20ms, this is where the desired change actually happens and its based on the previous serial input // pulse the servo every 20 ms (refreshTime) with current pulseWidth // this will hold the servo's position if unchanged, or move it if changed if (millis() - lastPulse >= refreshTime) { digitalWrite(servoPin, HIGH); // start the pulse delayMicroseconds(pulseWidth); // pulse width digitalWrite(servoPin, LOW); // stop the pulse lastPulse = millis(); // save the time of the last pulse } } // END of Main program
• 28. Switches Types and contacts Knives and toggles Knive (SPST) Single pole = control of one circuit Double pole = two circuits controlled at once Single throw = one path for circuit Double throw = two paths for circuit Toggle (SPDT) Foot, tape / mat, roller, hair trigger, tilt, magnetic / reed
• 29. High and Low Practical switching Arduino looks for 0V (low) to 5V (high) Digital inputs ﬂoat between these values Resistor “pulls” input to ground (0 volts) Pressing switch “pushes” input to 5 volts Switch pressed = HIGH, not pressed = LOW setup(): pinMode(myPin,INPUT) loop(): digitalRead(myPin)
• 30. Sketching your work Bill Verplank Interaction Design Sketchbook Bill Buxton
• 31. Embodiment using Animatronics Stefan Marti 2005, Autonomous Interactive Intermediaries 2005, Physical Embodiments for Mobile Communication Agents
• 32. Kinematics Gears and mechanical models Geometry of pure motion without reference to force or mass Cornell University Library, Kinematic Examples from Models for Design Digital Library www.ﬂying-pig.co.uk (KMODDL) Tutorials, models, e-books, e.g. Linkages Chapter 3 in Building Robot Drive Trains
• 33. PWM Tutorials ITP Servo tutorial Principial Labs Arduino Servo Driving a Unipolar Stepper Motor Driving a Bipolar Stepper Motor ITP Servo lab, uses a potentiometer to Making an RC Servo wall following car control the servo.
• 34. Arduino Library Software Servo Library attach(int) Turn a pin into a servo driver. detach() Release a pin from servo driving. write(int) Set the angle of the servo in degrees, 0 to 180. read() return that value set with the last write(). attached() return 1 if the servo is currently attached. refresh() must call once every 50ms to keep servos updated, won't call more than every 20ms setMinimumPulse(uint16_t) set the duration of the 0 degree pulse in microseconds. (default minimum value is 544 microseconds) setMaximumPulse(uint16_t) set the duration of the 180 degree pulse in microseconds. (default maximum pluse value is 2400 microsconds) Need to ﬁrst send position with write() before you can receive any control signals
• 35. Projects and Prototyping Trade-offs
• 36. Projects and Prototyping Trade-offs Re-programmable
• 37. Projects and Prototyping Trade-offs Size matters
• 38. Capacitors Stores charge With resistors I = C * dV/dt RC Circuit, parallel or series low-pass or high-pass ﬁltering removal of electrical noise
• 39. Resistor Color Code 4-band Color Code 10K ! ± 5% 5 - band Color Code 47.5 K ! ± 1% 6 - band Color Code 276 ! ± 5% Multiplier Tolerance SLV 0.01 SLV ± 10% 1st Digit 2nd Digit 3rd Digit GLD 0.1 Temperature GLD ± 5% Coefficient BLK-0 BLK-0 BLK-0 BLK-1 BRN-100ppm BRN-1 BRN-1 BRN-1 BRN-10 BRN ± 1% RED-50ppm RED-2 RED-2 RED-2 RED-100 RED ± 2% ORN-15ppm ORN-3 ORN-3 ORN-3 ORN-1K YEL-25ppm YEL-10K YEL-4 YEL-4 YEL-4 GRN-100K GRN-5 GRN-5 GRN-5 GRN ± 0.5% BLU-6 BLU-6 BLU-6 BLU-1M BLU- ± 0.25% VIO-7 VIO-7 VIO-7 VIO-10M VIO ± 0.1% GRY-8 GRY-8 GRY-8 GRY-8 WHT-9 WHT-9 WHT-9
• 40. Measuring Resistance
• 41. Measuring Voltage
• 42. Diodes LEDs, Zener, Schottky, Photo Pass current in one direction only Forward voltage drop e.g. forward voltage drop of 0.7 V in circuit where input is 5V will have voltage of 4.3V on its far side Rectiﬁcation Removal of negative voltages from signal, i.e. a bridge rectiﬁer LED, 1.6V forward voltage drop, current limit 36mA, circuit total voltage 5V. VR = 5 - 1.6 = 3.4V R = V / I = 3.4 / 0.036 = 94.44 Ohm (at least 100 Ohm) P = V * I = 3.4 * 0.036 = 0.1224 W (at least 0.125W)
• 43. RGB LEDs
• 44. RGB LEDs
• 45. RGB LEDs Ambient orb Cube of LEDS
• 46. RGB LEDs TiniTinct, Arduino-based monome compatible
• 47. AVR Programmer
• 50. /* Two LEDs, tied to pin b0 and to b1 which correspond to physical pins 5 and 6 on ATTINY13 are turned on for 100ms and then off for 200ms */ #include <avr/io.h> #deﬁne F_CPU 1000000 // set to 1 MHz as delay.h needs F_CPU #include <util/delay.h> #include quot;pin_macros.hquot; // Leah Buechley's pin macros for AVRs - very useful int main(void) { // Set Port B pins for 3 and 4 as outputs b0_output; //initialize LED pin b1_output; //initialize LED pin b0_high; //LED is off b1_high; //LED is off DDRB = 0x18; // In binary this is 0001 1000 (note that is bit 3 and 4) for ( ; 1==1 ; ) // loop while 1 equals 1 - forever - C style loop { // Set Port B pins for 3 and 4 as HIGH (i.e. turn the LEDs on) b0_low; //LED is on b1_low; //LED is on _delay_loop_2(65535); b0_high; //LED is off b1_high; //LED is off _delay_loop_2(65535); } return 1; }
• 51. /* Two LEDs, tied to pin b0 and to b1 which correspond to physical pins 5 and 6 on ATTINY13 are turned on for 100ms and then off for 200ms */ #include <avr/io.h> Include the #deﬁne F_CPU 1000000 // set to 1 MHz as delay.h needs F_CPU #include <util/delay.h> #include quot;pin_macros.hquot; // Leah Buechley's pin macros for AVRs - very useful libraries and set int main(void) the speed of chip { // Set Port B pins for 3 and 4 as outputs b0_output; //initialize LED pin b1_output; //initialize LED pin b0_high; //LED is off b1_high; //LED is off DDRB = 0x18; // In binary this is 0001 1000 (note that is bit 3 and 4) for ( ; 1==1 ; ) // loop while 1 equals 1 - forever - C style loop { // Set Port B pins for 3 and 4 as HIGH (i.e. turn the LEDs on) b0_low; //LED is on b1_low; //LED is on _delay_loop_2(65535); b0_high; //LED is off b1_high; //LED is off _delay_loop_2(65535); } return 1; }
• 52. /* Two LEDs, tied to pin b0 and to b1 which correspond to physical pins 5 and 6 on ATTINY13 are turned on for 100ms and then off for 200ms */ #include <avr/io.h> #deﬁne F_CPU 1000000 // set to 1 MHz as delay.h needs F_CPU #include <util/delay.h> #include quot;pin_macros.hquot; // Leah Buechley's pin macros for AVRs - very useful Setup LED pins, Data int main(void) { // Set Port B pins for 3 and 4 as outputs Direction Register and b0_output; //initialize LED pin b1_output; //initialize LED pin turn LEDS off. b0_high; //LED is off b1_high; //LED is off DDRB = 0x18; // In binary this is 0001 1000 (note that is bit 3 and 4) for ( ; 1==1 ; ) // loop while 1 equals 1 - forever - C style loop { // Set Port B pins for 3 and 4 as HIGH (i.e. turn the LEDs on) b0_low; //LED is on b1_low; //LED is on _delay_loop_2(65535); b0_high; //LED is off b1_high; //LED is off _delay_loop_2(65535); } return 1; }
• 53. /* Two LEDs, tied to pin b0 and to b1 which correspond to physical pins 5 and 6 on ATTINY13 are turned on for 100ms and then off for 200ms */ #include <avr/io.h> #deﬁne F_CPU 1000000 // set to 1 MHz as delay.h needs F_CPU #include <util/delay.h> #include quot;pin_macros.hquot; // Leah Buechley's pin macros for AVRs - very useful Loop - Turn the pins int main(void) { // Set Port B pins for 3 and 4 as outputs on, wait for 262ms, and b0_output; //initialize LED pin b1_output; //initialize LED pin turn off. Repeat. b0_high; //LED is off b1_high; //LED is off DDRB = 0x18; // In binary this is 0001 1000 (note that is bit 3 and 4) for ( ; 1==1 ; ) // loop while 1 equals 1 - forever - C style loop { // Set Port B pins for 3 and 4 as HIGH (i.e. turn the LEDs on) b0_low; //LED is on b1_low; //LED is on _delay_loop_2(65535); b0_high; //LED is off b1_high; //LED is off _delay_loop_2(65535); } return 1; }
• 54. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command # default target when quot;makequot; is run w/o arguments all: sample_led_program.rom # compile sample_led_program.c into sample_led_program.o sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 55. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command When Make is run, # default target when quot;makequot; is run w/o arguments all: sample_led_program.rom needs a target # compile sample_led_program.c into sample_led_program.o sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 56. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command Use avr-gcc to compile # default target when quot;makequot; is run w/o arguments all: sample_led_program.rom ‘c’ program # compile sample_led_program.c into sample_led_program.o sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 57. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command Use avr-gcc on `o’ obj # default target when quot;makequot; is run w/o arguments all: sample_led_program.rom ﬁle to create `elf’ ﬁle # compile sample_led_program.c into sample_led_program.o sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 58. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command Use avr-objcopy to # default target when quot;makequot; is run w/o arguments create rom from elf ﬁle all: sample_led_program.rom # compile sample_led_program.c into sample_led_program.o sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 59. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command Use avrdube and a # default target when quot;makequot; is run w/o arguments usbtiny to copy to the all: sample_led_program.rom # compile sample_led_program.c into sample_led_program.o ATtiny13 chip sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 60. # Makeﬁle for sample_led_program for ATtiny13 chip # Note: to use makeﬁle with a different chip change all # mmcu statements (-mmcu=attiny13) to reﬂect new chip # also change the part option (-p t13) for the avrdude install command Clean up the ﬁles # default target when quot;makequot; is run w/o arguments all: sample_led_program.rom created # compile sample_led_program.c into sample_led_program.o sample_led_program.o: sample_led_program.c avr-gcc -c -g -O0 -Wall -mmcu=attiny13 sample_led_program.c -o sample_led_program.o # link up sample_led_program.o into sample_led_program.elf sample_led_program.elf: sample_led_program.o avr-gcc sample_led_program.o -Wall,-nm,-Map=sample_led_program.map,--cref - mmcu=attiny13 -o sample_led_program.elf # copy ROM (FLASH) object out of sample_led_program.elf into sample_led_program.rom sample_led_program.rom: sample_led_program.elf avr-objcopy -O ihex sample_led_program.elf sample_led_program.rom # command to program chip (invoked by running quot;make installquot;) install: avrdude -c usbtiny -p t13 -e -U ﬂash:w:sample_led_program.rom # command to clean up junk (no source ﬁles) (invoked by quot;make cleanquot;) clean: rm -f *.o *.rom *.elf *.map *~
• 61. Call the Makeﬁle
• 62. Call the Install part of Makeﬁle which calls avrdude
• 63. Run avrdude, it reads the rom, writes it to the chip and veriﬁes this process
• 64. Things To Remember Safety ﬁrst, last, and always do not take another person’s work about the state of a piece of equipment, always check yourself and make sure its safe for you to work use the right tool for the job treat each tool with respect and rack them back in their correct place when they are not in use, don’t leave a dangerous tool loose when it can harm somebody else don’t leave your safety glasses on the bench or in your pocket don’t work on a live circuit, turn the power off ﬁrst don’t solder in an enclosed area without proper ventilation read the datasheet ﬁrst and double check it to be sure get twice or three times the number of parts that you need for your circuit, you will make mistakes and sometimes you will have to throw an almost ﬁnished piece away
• 65. Data Sheets Manufacturer’s details for particular electronic product typical device performance minimum and maximum requirements and characteristics device tolerances, what you can do without harming it suggestions for applications, uses, or just hints You don’t need to understand everything only need to focus on the parts that are of interest to your current problem
• 66. Features • High Performance, Low Power AVR® 8-Bit Microcontroller • Advanced RISC Architecture – 120 Powerful Instructions – Most Single Clock Cycle Execution – 32 x 8 General Purpose Working Registers – Fully Static Operation – Up to 20 MIPS Througput at 20 MHz • High Endurance Non-volatile Memory segments – 1K Bytes of In-System Self-programmable Flash program memory – 64 Bytes EEPROM 8-bit – 64K Bytes Internal SRAM – Write/Erase cyles: 10,000 Flash/100,000 EEPROM Microcontroller – Data retention: 20 years at 85°C/100 years at 25°C(1) – Optional Boot Code Section with Independent Lock Bits with 1K Bytes In-System Programming by On-chip Boot Program True Read-While-Write Operation – Programming Lock for Software Security In-System • Peripheral Features – One 8-bit Timer/Counter with Prescaler and Two PWM Channels Programmable – 4-channel, 10-bit ADC with Internal Voltage Reference Example: – Programmable Watchdog Timer with Separate On-chip Oscillator Flash – On-chip Analog Comparator • Special Microcontroller Features – debugWIRE On-chip Debug System – In-System Programmable via SPI Port ATtiny13V – External and Internal Interrupt Sources Models – Low Power Idle, ADC Noise Reduction, and Power-down Modes ATtiny13 – Enhanced Power-on Reset Circuit – Programmable Brown-out Detection Circuit ATtiny13 – Internal Calibrated Oscillator • I/O and Packages Summary – 8-pin PDIP/SOIC: Six Programmable I/O Lines – 20-pad MLF: Six Programmable I/O Lines • Operating Voltage: – 1.8 - 5.5V for ATtiny13V If it is the short summary – 2.7 - 5.5V for ATtiny13 • Speed Grade or longer full datasheet – ATtiny13V: 0 - 4 MHz @ 1.8 - 5.5V, 0 - 10 MHz @ 2.7 - 5.5V – ATtiny13: 0 - 10 MHz @ 2.7 - 5.5V, 0 - 20 MHz @ 4.5 - 5.5V • Industrial Temperature Range • Low Power Consumption – Active Mode: 1 MHz, 1.8V: 240µA – Power-down Mode: < 0.1µA at 1.8V One page overview of models and capabilities Date Rev. 2535HS–AVR–10/07