arduino lecture 2 - electronic, leds, communications and datasheets

52
Electronics, LEDs, Communications and Data-sheets CS4062 - Eoin Brazil - Semester 2 - 2008

Upload: eoin-brazil

Post on 14-May-2015

3.910 views

Category:

Technology


2 download

DESCRIPTION

Continuing the coverage of the Arduino platform with some electronics revisions, an introduction to some communication issues, and some pointers about datasheets. Part of the Interactive Media Master's program at the University of Limerick.

TRANSCRIPT

Page 1: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Electronics, LEDs, Communications and

Data-sheetsCS4062 - Eoin Brazil - Semester 2 - 2008

Page 2: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Ohm’s Law

Page 3: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Power

Page 4: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Calculating power using resistance and current or voltage

Page 5: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

first law / current law The current flowing through a given circuit

point is equal to the sum of the currents flowing into that point and is equal to the sum of currents flowing out of that point.

Resistors in series - RTOTAL = R1 + R2

VOUT = VIN * R2 / (R1 + R2)

e.g. 5V input, 2 x 1 k Ohm Resistors

5V * 1k / (1k + 1k) ... 5V * 1k/2k ... 5V * 0.5 = 2.5V = VOUT

Kirchhoff’s Laws

Page 6: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

second law / voltage law The sum of the voltage differences

around a closed circuit is zero.

Resistors in parallel - RTOTAL = 1 / (1/R1 + 1/R2)

Kirchhoff’s Laws

V3 = VT * R2/(R1 + R2)

e.g. VT = 9V, R1 = 2K, R2 = 1K

V3 = 9*1000/2000+1000 = 3V

Page 7: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Practical use - variable LED brightness

Some parts of the circuit may require different voltage

Arduino had 6 ADC (10 bit), typically use voltage divider circuit for control with connections to ground and to +5V on the board

10 bit = 1024 values on input of 0 to 5V so 5/1024 = 4.8mV lowest measurable value

Ranged input

Potentiometers

Page 8: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Potentiometers

Page 9: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Potentiometers

Page 10: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Types and contacts Knives and toggles 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

Foot, tape / mat, roller, hair trigger, tilt, magnetic / reed

Switches

Knive (SPST)

Toggle (SPDT)

Page 11: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Practical switching Arduino looks for 0V (low) to 5V (high)

Digital inputs float 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)

High and Low

Page 12: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* Digital reading, turns on and off a light emitting diode (LED) connected to digital * pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of * Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.*/

int ledPin = 13; // choose the pin for the LEDint inPin = 7; // choose the input pin (button)int buttonval = 0; // variable for reading the pin status

void setup() { pinMode(ledPin, OUTPUT); // set LED as output pinMode(inPin, INPUT); // set pushbutton as input beginSerial(19200); // start serial communication to computer}

void loop() { buttonval = digitalRead(inPin); // read the pin and get the button's state if (buttonval == HIGH) { // check if the input is HIGH (button released) digitalWrite(ledPin, LOW); // turn LED OFF serialWrite('0'); // Button off (0) sent to computer } else { digitalWrite(ledPin, HIGH); // turn LED ON serialWrite('1'); // Button on (1) sent to computer }}

Page 13: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* Digital reading, turns on and off a light emitting diode (LED) connected to digital * pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of * Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.*/

int ledPin = 13; // choose the pin for the LEDint inPin = 7; // choose the input pin (button)int buttonval = 0; // variable for reading the pin status

void setup() { pinMode(ledPin, OUTPUT); // set LED as output pinMode(inPin, INPUT); // set pushbutton as input beginSerial(19200); // start serial communication to computer}

void loop() { buttonval = digitalRead(inPin); // read the pin and get the button's state if (buttonval == HIGH) { // check if the input is HIGH (button released) digitalWrite(ledPin, LOW); // turn LED OFF serialWrite('0'); // Button off (0) sent to computer } else { digitalWrite(ledPin, HIGH); // turn LED ON serialWrite('1'); // Button on (1) sent to computer }}

Setup the LED, switch pins and variable to hold switch values

Page 14: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* Digital reading, turns on and off a light emitting diode (LED) connected to digital * pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of * Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.*/

int ledPin = 13; // choose the pin for the LEDint inPin = 7; // choose the input pin (button)int buttonval = 0; // variable for reading the pin status

void setup() { pinMode(ledPin, OUTPUT); // set LED as output pinMode(inPin, INPUT); // set pushbutton as input beginSerial(19200); // start serial communication to computer}

void loop() { buttonval = digitalRead(inPin); // read the pin and get the button's state if (buttonval == HIGH) { // check if the input is HIGH (button released) digitalWrite(ledPin, LOW); // turn LED OFF serialWrite('0'); // Button off (0) sent to computer } else { digitalWrite(ledPin, HIGH); // turn LED ON serialWrite('1'); // Button on (1) sent to computer }}

Set the LED pin for output, set the switch

pin for input, and setup for serial communications

Page 15: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* Digital reading, turns on and off a light emitting diode (LED) connected to digital * pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of * Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.*/

int ledPin = 13; // choose the pin for the LEDint inPin = 7; // choose the input pin (button)int buttonval = 0; // variable for reading the pin status

void setup() { pinMode(ledPin, OUTPUT); // set LED as output pinMode(inPin, INPUT); // set pushbutton as input beginSerial(19200); // start serial communication to computer}

void loop() { buttonval = digitalRead(inPin); // read the pin and get the button's state if (buttonval == HIGH) { // check if the input is HIGH (button released) digitalWrite(ledPin, LOW); // turn LED OFF serialWrite('0'); // Button off (0) sent to computer } else { digitalWrite(ledPin, HIGH); // turn LED ON serialWrite('1'); // Button on (1) sent to computer }}

Loop - Read the switch, if its pressed

turn LED off and send a 0 otherwise turn LED on and

send a 1

Page 16: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Stores charge I = C * dV/dt

removal of electrical noise

With resistors RC Circuit, parallel or series

low-pass or high-pass filtering

Capacitors

Page 17: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

BLK-0BRN-1RED-2ORN-3YEL-4GRN-5BLU-6VIO-7GRY-8WHT-9

BLK-0BRN-1RED-2ORN-3YEL-4GRN-5BLU-6VIO-7GRY-8WHT-9

BLK-0BRN-1RED-2ORN-3YEL-4GRN-5BLU-6VIO-7GRY-8WHT-9

GLD 0.1SLV 0.01

BLK-1BRN-10RED-100ORN-1KYEL-10K

GRN-100KBLU-1MVIO-10M

GLD ±±±± 5%SLV ±±±± 10%

RED ±±±± 2%BRN ±±±± 1%

GRN ±±±± 0.5%BLU- ±±±± 0.25%VIO ±±±± 0.1%

BRN-100ppmRED-50ppmORN-15ppmYEL-25ppm

1st Digit 2nd Digit 3rd Digit

Multiplier Tolerance

TemperatureCoefficient

276 !!!! ±±±± 5%

47.5 K !!!! ±±±± 1%

10K !!!! ±±±± 5%

Resistor Color Code

6 - band Color Code

5 - band Color Code

4-band Color Code

GRY-8

Page 18: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Measuring Resistance

Page 19: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Measuring Voltage

Page 20: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

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

Rectification Removal of negative voltages from signal, i.e. a

bridge rectifier

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)

Page 21: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

RGB LEDs

Page 22: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

RGB LEDs

Page 23: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Cross Fading 3 LEDS

Page 24: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Cross Fading 3 LEDS

Page 25: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* * Code for cross-fading 3 LEDs, red, green and blue, or one tri-color LED, using PWM * The program cross-fades slowly from red to green, green to blue, and blue to red * The debugging code assumes Arduino 0004, as it uses the new Serial.begin()-style functions * originally "dimmingLEDs" by Clay Shirky <[email protected]> */

/ Outputint redPin = 9; // Red LED, connected to digital pin 9int greenPin = 10; // Green LED, connected to digital pin 10int bluePin = 11; // Blue LED, connected to digital pin 11

// Program variablesint redVal = 255; // Variables to store the values to send to the pinsint greenVal = 1; // Initial values are Red full, Green and Blue offint blueVal = 1;

int i = 0; // Loop counter int wait = 15; // 50ms (.05 second) delay; shorten for faster fadesint DEBUG = 0; // DEBUG counter; if set to 1, will write values back via serial

void setup(){ pinMode(redPin, OUTPUT); // sets the pins as output pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); if (DEBUG) { // If we want to see the pin values for debugging... Serial.begin(9600); // ...set up the serial ouput on 0004 style }}

continuedon next

slide

Page 26: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* * Code for cross-fading 3 LEDs, red, green and blue, or one tri-color LED, using PWM * The program cross-fades slowly from red to green, green to blue, and blue to red * The debugging code assumes Arduino 0004, as it uses the new Serial.begin()-style functions * originally "dimmingLEDs" by Clay Shirky <[email protected]> */

/ Outputint redPin = 9; // Red LED, connected to digital pin 9int greenPin = 10; // Green LED, connected to digital pin 10int bluePin = 11; // Blue LED, connected to digital pin 11

// Program variablesint redVal = 255; // Variables to store the values to send to the pinsint greenVal = 1; // Initial values are Red full, Green and Blue offint blueVal = 1;

int i = 0; // Loop counter int wait = 15; // 50ms (.05 second) delay; shorten for faster fadesint DEBUG = 0; // DEBUG counter; if set to 1, will write values back via serial

void setup(){ pinMode(redPin, OUTPUT); // sets the pins as output pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); if (DEBUG) { // If we want to see the pin values for debugging... Serial.begin(9600); // ...set up the serial ouput on 0004 style }}

continuedon next

slide

Setup the LED pins, LED variables, and program variables

Page 27: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

/* * Code for cross-fading 3 LEDs, red, green and blue, or one tri-color LED, using PWM * The program cross-fades slowly from red to green, green to blue, and blue to red * The debugging code assumes Arduino 0004, as it uses the new Serial.begin()-style functions * originally "dimmingLEDs" by Clay Shirky <[email protected]> */

/ Outputint redPin = 9; // Red LED, connected to digital pin 9int greenPin = 10; // Green LED, connected to digital pin 10int bluePin = 11; // Blue LED, connected to digital pin 11

// Program variablesint redVal = 255; // Variables to store the values to send to the pinsint greenVal = 1; // Initial values are Red full, Green and Blue offint blueVal = 1;

int i = 0; // Loop counter int wait = 15; // 50ms (.05 second) delay; shorten for faster fadesint DEBUG = 0; // DEBUG counter; if set to 1, will write values back via serial

void setup(){ pinMode(redPin, OUTPUT); // sets the pins as output pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); if (DEBUG) { // If we want to see the pin values for debugging... Serial.begin(9600); // ...set up the serial ouput on 0004 style }}

continuedon next

slide

Setup the LED pins for output

and if in DEBUG mode,

setup serial communications

Page 28: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// Main programvoid loop(){ i += 1; // Increment counter if (i < 255) // First phase of fades { redVal -= 1; // Red down greenVal += 1; // Green up blueVal = 1; // Blue low } else if (i < 509) // Second phase of fades { redVal = 1; // Red low greenVal -= 1; // Green down blueVal += 1; // Blue up } else if (i < 763) // Third phase of fades { redVal += 1; // Red up greenVal = 1; // Green lo2 blueVal -= 1; // Blue down } else // Re-set the counter, and start the fades again { i = 1; }

continuedon next

slide

Page 29: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// Main programvoid loop(){ i += 1; // Increment counter if (i < 255) // First phase of fades { redVal -= 1; // Red down greenVal += 1; // Green up blueVal = 1; // Blue low } else if (i < 509) // Second phase of fades { redVal = 1; // Red low greenVal -= 1; // Green down blueVal += 1; // Blue up } else if (i < 763) // Third phase of fades { redVal += 1; // Red up greenVal = 1; // Green lo2 blueVal -= 1; // Blue down } else // Re-set the counter, and start the fades again { i = 1; }

continuedon next

slide

Start the counter and setup the

first fade

Page 30: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// Main programvoid loop(){ i += 1; // Increment counter if (i < 255) // First phase of fades { redVal -= 1; // Red down greenVal += 1; // Green up blueVal = 1; // Blue low } else if (i < 509) // Second phase of fades { redVal = 1; // Red low greenVal -= 1; // Green down blueVal += 1; // Blue up } else if (i < 763) // Third phase of fades { redVal += 1; // Red up greenVal = 1; // Green lo2 blueVal -= 1; // Blue down } else // Re-set the counter, and start the fades again { i = 1; }

continuedon next

slide

Setup the second and the third fades

Page 31: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// Main programvoid loop(){ i += 1; // Increment counter if (i < 255) // First phase of fades { redVal -= 1; // Red down greenVal += 1; // Green up blueVal = 1; // Blue low } else if (i < 509) // Second phase of fades { redVal = 1; // Red low greenVal -= 1; // Green down blueVal += 1; // Blue up } else if (i < 763) // Third phase of fades { redVal += 1; // Red up greenVal = 1; // Green lo2 blueVal -= 1; // Blue down } else // Re-set the counter, and start the fades again { i = 1; }

continuedon next

slide

Restart the counter for the next set of

fades

Page 32: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// we do "255-redVal" instead of just "redVal" because the // LEDs are hooked up to +5V instead of Gnd analogWrite(redPin, 255 - redVal); // Write current values to LED pins analogWrite(greenPin, 255 - greenVal); analogWrite(bluePin, 255 - blueVal);

if (DEBUG) { // If we want to read the output DEBUG += 1; // Increment the DEBUG counter if (DEBUG > 10) { // Print every 10 loops DEBUG = 1; // Reset the counter Serial.print(i); // Serial commands in 0004 style Serial.print("\t"); // Print a tab Serial.print("R:"); // Indicate that output is red value Serial.print(redVal); // Print red value Serial.print("\t"); // Print a tab Serial.print("G:"); // Repeat for green and blue... Serial.print(greenVal); Serial.print("\t"); Serial.print("B:"); Serial.println(blueVal); // println, to end with a carriage return } } delay(wait); // Pause for 'wait' milliseconds before resuming the loop}// END of Main program

Page 33: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// we do "255-redVal" instead of just "redVal" because the // LEDs are hooked up to +5V instead of Gnd analogWrite(redPin, 255 - redVal); // Write current values to LED pins analogWrite(greenPin, 255 - greenVal); analogWrite(bluePin, 255 - blueVal);

if (DEBUG) { // If we want to read the output DEBUG += 1; // Increment the DEBUG counter if (DEBUG > 10) { // Print every 10 loops DEBUG = 1; // Reset the counter Serial.print(i); // Serial commands in 0004 style Serial.print("\t"); // Print a tab Serial.print("R:"); // Indicate that output is red value Serial.print(redVal); // Print red value Serial.print("\t"); // Print a tab Serial.print("G:"); // Repeat for green and blue... Serial.print(greenVal); Serial.print("\t"); Serial.print("B:"); Serial.println(blueVal); // println, to end with a carriage return } } delay(wait); // Pause for 'wait' milliseconds before resuming the loop}// END of Main program

Write the current values to the LED

pins

Page 34: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// we do "255-redVal" instead of just "redVal" because the // LEDs are hooked up to +5V instead of Gnd analogWrite(redPin, 255 - redVal); // Write current values to LED pins analogWrite(greenPin, 255 - greenVal); analogWrite(bluePin, 255 - blueVal);

if (DEBUG) { // If we want to read the output DEBUG += 1; // Increment the DEBUG counter if (DEBUG > 10) { // Print every 10 loops DEBUG = 1; // Reset the counter Serial.print(i); // Serial commands in 0004 style Serial.print("\t"); // Print a tab Serial.print("R:"); // Indicate that output is red value Serial.print(redVal); // Print red value Serial.print("\t"); // Print a tab Serial.print("G:"); // Repeat for green and blue... Serial.print(greenVal); Serial.print("\t"); Serial.print("B:"); Serial.println(blueVal); // println, to end with a carriage return } } delay(wait); // Pause for 'wait' milliseconds before resuming the loop}// END of Main program

The DEBUG section sents information

back every 10 loops about the current

LED states

Page 35: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

// we do "255-redVal" instead of just "redVal" because the // LEDs are hooked up to +5V instead of Gnd analogWrite(redPin, 255 - redVal); // Write current values to LED pins analogWrite(greenPin, 255 - greenVal); analogWrite(bluePin, 255 - blueVal);

if (DEBUG) { // If we want to read the output DEBUG += 1; // Increment the DEBUG counter if (DEBUG > 10) { // Print every 10 loops DEBUG = 1; // Reset the counter Serial.print(i); // Serial commands in 0004 style Serial.print("\t"); // Print a tab Serial.print("R:"); // Indicate that output is red value Serial.print(redVal); // Print red value Serial.print("\t"); // Print a tab Serial.print("G:"); // Repeat for green and blue... Serial.print(greenVal); Serial.print("\t"); Serial.print("B:"); Serial.println(blueVal); // println, to end with a carriage return } } delay(wait); // Pause for 'wait' milliseconds before resuming the loop}// END of Main program

Pause for a time in ms determined by

wait variable

Page 36: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Lab Exercise

Page 37: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

RGB LEDs Ambient orb Cube of LEDS

Page 38: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

RGB LEDs TiniTinct, Arduino-based monome compatible

Page 39: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Accelerometer & RGB LED

Page 40: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Accelerometer & RGB LED

Page 41: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Communications

Wired XPort TCP/IP for

Ethernet connectivity

RS232

I3C

CAN

Wireless IrDa

Bluetooth

"RF" / Radio

WiPort TCP/IP

Cell Phone Data GPRS

ZigBee & 802.15.4

802.11b,g,n

Page 42: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Botanicalls @ ITP

Botanicalls, thirsty plants make phone calls for human help.

Wired & Wireless Light & Soil sensors

Arduino

XBee

XPort

Asterisk

Page 43: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

802.15.4 Topologies

Single peer

Broadcast

Multi peer

Page 44: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

ZigBee Topologies

Peer

Star

Mesh

Routing

Page 45: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Protocols and ProxiesProxy: Conversion of communication to another type

Network serial (Serial to TCP) TinkerProxy / Griffin Proxi osculator Girder (Windows) Shion, Indigo Sydewynder

Protocol: Structured conversation

Midi / OSC DMX512 X10, INSTEON

Page 46: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Beware Communications Troubleshooting

use wired versions of your project or idea first, debugging a problem is hard when its wired directly together, wireless adds an additional layer of problems

chatter, too much or too fast can result in loss

wireless is slower than wired

more expensive approaches can improve speed and reliability but all are battery hogs

NAT, routers, and traversing firewalls

Sessions or Messages TCP or UDP

Session makes connection, does handshaking, information is transferred, and then closed

Datagram, similar to physical letter or postcard

Point to Point, Point to Many (multicast), Point to All (Broadcast)

Page 47: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

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

Page 48: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

2535HS–AVR–10/07

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

– 64K Bytes Internal SRAM

– Write/Erase cyles: 10,000 Flash/100,000 EEPROM

– Data retention: 20 years at 85°C/100 years at 25°C(1)

– Optional Boot Code Section with Independent Lock Bits

In-System Programming by On-chip Boot Program

True Read-While-Write Operation

– Programming Lock for Software Security

• Peripheral Features

– One 8-bit Timer/Counter with Prescaler and Two PWM Channels

– 4-channel, 10-bit ADC with Internal Voltage Reference

– Programmable Watchdog Timer with Separate On-chip Oscillator

– On-chip Analog Comparator

• Special Microcontroller Features

– debugWIRE On-chip Debug System

– In-System Programmable via SPI Port

– External and Internal Interrupt Sources

– Low Power Idle, ADC Noise Reduction, and Power-down Modes

– Enhanced Power-on Reset Circuit

– Programmable Brown-out Detection Circuit

– Internal Calibrated Oscillator

• I/O and Packages

– 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

– 2.7 - 5.5V for ATtiny13

• Speed Grade

– 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

8-bit

Microcontroller

with 1K Bytes

In-System

Programmable

Flash

ATtiny13V

ATtiny13

Summary

Rev. 2535HS–AVR–10/07

One page overview of models and capabilities

Date

Models

If it is the short summaryor longer full datasheet

Example: ATtiny13

Page 49: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Example: ATtiny13

2 ATtiny132535HS–AVR–10/07

Pin Configurations Figure 1. Pinout ATtiny13

Overview The ATtiny13 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced

RISC architecture. By executing powerful instructions in a single clock cycle, the

ATtiny13 achieves throughputs approaching 1 MIPS per MHz allowing the system

designer to optimize power consumption versus processing speed.

1234

8765

(PCINT5/RESET/ADC0/dW) PB5(PCINT3/CLKI/ADC3) PB3

(PCINT4/ADC2) PB4GND

VCCPB2 (SCK/ADC1/T0/PCINT2)PB1 (MISO/AIN1/OC0B/INT0/PCINT1)PB0 (MOSI/AIN0/OC0A/PCINT0)

8-PDIP/SOIC

12345

20-QFN/MLF

1514131211

20 19 18 17 16

6 7 8 9 10

(PCINT5/RESET/ADC0/dW) PB5(PCINT3/CLKI/ADC3) PB3

NCNC

(PCINT4/ADC2) PB4

NC

NC

GN

DN

CN

C

VCCPB2 (SCK/ADC1/T0/PCINT2)NCPB1 (MISO/AIN1/OC0B/INT0/PCINT1)PB0 (MOSI/AIN0/OC0A/PCINT0)

NC

NC

NC

NC

NC

NOTE: Bottom pad should be soldered to ground.NC: Not Connect

12345

10-QFN/MLF

10 9 8 7 6

(PCINT5/RESET/ADC0/dW) PB5(PCINT3/CLKI/ADC3) PB3

NC(PCINT4/ADC2) PB4

GND

VCCPB2 (SCK/ADC1/T0/PCINT2)NCPB1 (MISO/AIN1/OC0B/INT0/PCINT1)PB0 (MOSI/AIN0/OC0A/PCINT0)

NOTE: Bottom pad should be soldered to ground.NC: Not Connect

PDIP or SOIC are the only two

package types we'll use. The

other types require SMD soldering.

Date

Page 50: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Example: ATtiny13

4 ATtiny132535HS–AVR–10/07

Interrupt system to continue functioning. The Power-down mode saves the register con-

tents, disabling all chip functions until the next Interrupt or Hardware Reset. The ADC

Noise Reduction mode stops the CPU and all I/O modules except ADC, to minimize

switching noise during ADC conversions.

The device is manufactured using Atmel’s high density non-volatile memory technology.

The On-chip ISP Flash allows the Program memory to be re-programmed In-System

through an SPI serial interface, by a conventional non-volatile memory programmer or

by an On-chip boot code running on the AVR core.

The ATtiny13 AVR is supported with a full suite of program and system development

tools including: C Compilers, Macro Assemblers, Program Debugger/Simulators, In-Cir-

cuit Emulators, and Evaluation kits.

Pin Descriptions

VCC Digital supply voltage.

GND Ground.

Port B (PB5..PB0) Port B is a 6-bit bi-directional I/O port with internal pull-up resistors (selected for each

bit). The Port B output buffers have symmetrical drive characteristics with both high sink

and source capability. As inputs, Port B pins that are externally pulled low will source

current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset

condition becomes active, even if the clock is not running.

Port B also serves the functions of various special features of the ATtiny13 as listed on

page 51.

RESET Reset input. A low level on this pin for longer than the minimum pulse length will gener-

ate a reset, even if the clock is not running. The minimum pulse length is given in Table

12 on page 31. Shorter pulses are not guaranteed to generate a reset.Note: 1.

Data Retention Reliability Qualification results show that the projected data retention failure rate is much

less than 1 PPM over 20 years at 85°C or 100 years at 25!C.

About Code

Examples

This documentation contains simple code examples that briefly show how to use various

parts of the device. These code examples assume that the part specific header file is

included before compilation. Be aware that not all C compiler vendors include bit defini-

tions in the header files and interrupt handling in C is compiler dependent. Please

confirm with the C compiler documentation for more details.

Descriptions of the pins shown in the previous

diagram with comments

Page 51: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Example: ATtiny13

120 ATtiny132535H–AVR–10/07

Electrical Characteristics

Absolute Maximum Ratings*

DC Characteristics

Operating Temperature.................................. -55!C to +125!C *NOTICE: Stresses beyond those listed under “Absolute

Maximum Ratings” may cause permanent dam-

age to the device. This is a stress rating only and

functional operation of the device at these or

other conditions beyond those indicated in the

operational sections of this specification is not

implied. Exposure to absolute maximum rating

conditions for extended periods may affect

device reliability.

Storage Temperature ..................................... -65°C to +150°C

Voltage on any Pin except RESET

with respect to Ground ................................-0.5V to VCC+0.5V

Voltage on RESET with respect to Ground......-0.5V to +13.0V

Maximum Operating Voltage ............................................ 6.0V

DC Current per I/O Pin ............................................... 40.0 mA

DC Current VCC and GND Pins................................ 200.0 mA

TA = -40!C to 85!C, VCC = 1.8V to 5.5V (unless otherwise noted)(1)

Symbol Parameter Condition Min. Typ. Max. Units

VILInput Low Voltage except

RESET pin

VCC = 1.8V - 2.4V

VCC = 2.4V - 5.5V-0.5

0.2VCC

0.3VCC

V

VIHInput High-voltage except

RESET pin

VCC = 1.8V - 2.4V

VCC = 2.4V - 5.5V

0.7VCC(3)

0.6VCC(3) VCC +0.5 V

VIL1

Input Low-voltage

CLKI pinVCC = 1.8V - 5.5 -0.5 0.1VCC V

VIH1

Input High-voltage

CLKI pin

VCC = 1.8V - 2.4V

VCC = 2.4V - 5.5V

0.8VCC(3)

0.7VCC(3) VCC +0.5 V

VIL2

Input Low-voltage

RESET pinVCC = 1.8V - 5.5 -0.5 0.2VCC V

VIH2

Input High-voltage

RESET pinVCC = 1.8V - 5.5 0.9VCC

(3) VCC +0.5 V

VIL3

Input Low-voltage

RESET pin

VCC = 1.8V - 2.4V

VCC = 2.4V - 5.5V-0.5 0.2VCC V

VIH3

Input High-voltage

RESET pin

VCC = 1.8V - 2.4V

VCC = 2.4V - 5.5V

0.7VCC(3)

0.6VCC(3) VCC +0.5 V

VOLOutput Low Voltage(4)

(PB1 and PB0)

IOL = 20 mA, VCC = 5V

IOL = 10 mA, VCC = 3V

0.7

0.5

V

V

VOL1Output Low Voltage(4)

(PB5, PB4, PB3 and PB2)

IOL = 10 mA, VCC = 5V

IOL = 5 mA, VCC = 3V

0.7

0.5

V

V

VOL2

Output Low Voltage(4)

(PB5, Reset used as I/O)

IOL =TBD mA, VCC =

TBDV

IOL =TBD mA, VCC =

TBDV

V

V

VOHOutput High-voltage(5)

( PB1 and PB0)

IOH = -20 mA, VCC = 5V

IOH = -10 mA, VCC = 3V

4.2

2.5

V

V

Descriptions of the what maximum ratings for device are. Running at these or beyond will

damage the device

Page 52: Arduino Lecture 2 - Electronic, LEDs, Communications and Datasheets

Example: ATtiny13

121

ATtiny13

2535H–AVR–10/07

Notes: 1. All DC Characteristics contained in this data sheet are based on simulation and characterization of other AVR microcontrol-

lers manufactured in the same process technology. These values are representing design targets, and will be updated after

characterization of actual silicon.

2. “Max” means the highest value where the pin is guaranteed to be read as low.

3. “Min” means the lowest value where the pin is guaranteed to be read as high.

4. Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V for PB5, PB1:0, 10 mA

at VCC = 5V, 5 mA at VCC = 3V for PB4:2) under steady state conditions (non-transient), the following must be observed:

1] The sum of all IOL, for all ports, should not exceed 60 mA.

If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater

than the listed test condition.

5. Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V for PB5, PB1:0, 10

mA at VCC = 5V, 5 mA at VCC = 3V for PB4:2) under steady state conditions (non-transient), the following must be observed:

1] The sum of all IOH, for all ports, should not exceed 60 mA.

If IOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current

greater than the listed test condition.

VOH1Output High-voltage(5)

(PB4, PB3 and PB2)

IOH = -10 mA, VCC = 5V

IOH = -5 mA, VCC = 3V

4.2

2.5

V

V

VOH2Output High-voltage(5)

(PB5, Reset used as I/O)

IOH = - TBD mA, VCC =

TBDV

IOH = - TBD mA, VCC =

TBDV

V

V

IILInput Leakage

Current I/O Pin

Vcc = 5.5V, pin low

(absolute value)1 µA

IIHInput Leakage

Current I/O Pin

Vcc = 5.5V, pin high

(absolute value)1 µA

RRST Reset Pull-up Resistor 30 80 k!

Rpu I/O Pin Pull-up Resistor 20 50 k!

ICC

Power Supply Current

Active 1MHz, VCC = 2V 0.35 mA

Active 4MHz, VCC = 3V 1.8 mA

Active 8MHz, VCC = 5V 6 mA

Idle 1MHz, VCC = 2V 0.08 0.2 mA

Idle 4MHz, VCC = 3V 0.41 1 mA

Idle 8MHz, VCC = 5V 1.6 3 mA

Power-down modeWDT enabled, VCC = 3V < 5 10 µA

WDT disabled, VCC = 3V < 0.5 2 µA

VACIOAnalog Comparator Input

Offset Voltage

VCC = 5V

Vin = VCC/2< 10 40 mV

IACLKAnalog Comparator Input

Leakage Current

VCC = 5V

Vin = VCC/2-50 50 nA

tACPDAnalog Comparator

Propagation Delay

VCC = 2.7V

VCC = 4.0V

750

500ns

TA = -40"C to 85"C, VCC = 1.8V to 5.5V (unless otherwise noted)(1) (Continued)

Symbol Parameter Condition Min. Typ. Max. Units

Some chips have internal resistors which you can use for inputs, here is where you can find their value