Before we get started... Please sign the sign up sheet at If you are going to Tweet, please use...

36
Before we get started... •Please sign the sign up sheet at http://bit.ly/hicap_signup •If you are going to Tweet, please use the #hicap hashtag

Transcript of Before we get started... Please sign the sign up sheet at If you are going to Tweet, please use...

Page 1: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Before we get started...

• Please sign the sign up sheet at http://bit.ly/hicap_signup

• If you are going to Tweet, please use the #hicap hashtag

Page 2: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

HI Capacity

http://hicapacity.orgOctober 11th, 2011

Jeremy Chan

Arduino Night IV

Page 3: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Tonight

What will we do?

• Temperature Sensors• Reading Sensors• Intro to Processing• Sensor Visualization

Arduino (C/C++) rocessing (Java)

(Async Serial)

RS232/USB

Page 4: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Temperature Sensor Applications• Cooking (Hot Plate and Oven Control)• Soldering (Soldering Irons, Reflow Ovens)• Thermal Management (Servers, HVAC)• Environmental Monitoring• Thermal Safety (Motors, Boilers, Batteries)• Food Safety (Refrigeration/Freezing)• Characterization (Thermal Conductivity)

Page 5: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Temperature Sensors

Overview on:1.Thermistors2.Resistive Temperature Detectors (RTD)3. Non-Contact IR Sensor (TI TMP006)4. Thermocouples (Wide Range)5. Semiconductor Band-Gap (Easy Interface)

Page 6: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

1. Thermistors– Resistors Made of NTC or PTC materials

• NTC: Negative Temperature Coefficient, R falls as T rises• PTC: Positive Temperature Coefficient, R rises as T rises• Typical Values from 2.2kΩ to 100kΩ @ 25C• Pros/Cons: Cheap / Non-Linear (Variable Sensitivity)• Products Available for -80°C to 150°C (-110°F to 302°F)

– Non-Linear Temperature/Resistance Curves

More Info: http://www.omega.com/temperature/z/pdf/z036-040.pdf

Omega Thermistor Products

Page 7: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

0 50 100 150 200 250 300 350 400 450-100

-50

0

50

100

150

5 10 15 20 25 30

0

20

40

60

80

100

X: 27.35Y: 0

X: 0.9743Y: 100

0C to 100C27.35kΩ to 0.974kΩ

Thermistor Temperature[C] vs R[Ω]

Datasheet / Calibration Constants: a,b,c,d,…

Example: Vishay 10k NTC Thermistor Assembly Curve

Vishay Calculator: http://www.vishay.com/doc?29113Vishay Thermistor: http://www.vishay.com/docs/29092/ntcalug.pdf

R[kΩ]

Tem

per

atu

re [

°C]

Page 8: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

2. Resistive Temperature Detectors– Precision PTC Resistors Made of Platinum

• PTC: Positive Temperature Coefficient, R rises as T rises• Typical Values from 100Ω -10kΩ @ 25C• Pros/Cons: Accurate, Linear / Expensive, Low Level Signals• Products Available for -200°C to 500°C (-328°F to 932°F)

– Near Linear Temperature/Resistance Curves• ~0.00385Ω/°C (3 Standard Classes for Different Temp Ranges Available)

More Info: http://www.ussensor.com/prod_Probes_RTDs.html

US Sensor RTD Products

Page 9: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

• All excitations induce some self-heating– Less power = Less self-heating = Less error = Less signal

• Excitation can be disabled, but be aware of fluctuations in temperature due to transient self-heating

RTD Temperature[C] vs R[Ω]

Thermistor: Steinhart-Hart Equation

- Datasheet / Calibration Constants: a,b,c

RTD, R to Temperature

- Datasheet/Calibration Constants: a,b,c90 100 110 120 130 140

-0.5

0

0.5

residuals

Linear: norm of residuals = 1.7576Quadratic: norm of residuals = 0.042544

80 90 100 110 120 130 140 150-100

-50

0

50

100

150

y = 2.5816*x - 257.95

y = 0.0010069*x2 + 2.3573*x - 245.8

Reference

Fit linear

Fit quadratic

R[Ω]

R[Ω]

Cu

rve

Fit

Err

or

[°C

]T

emp

erat

ure

[°C

]

Example Pt100 RTD

Page 10: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

3. Non-Contact IR Temperature– Infrared Thermopile Sensor: TMP006

• Tiny chip-scale package IR sensor (1.6mm x 1.6mm)• Pros: extremely small, non-contact measurement, serial output• Cons: extremely small, IR emissivity cal. reqd., requires well-laid PCB• TMP006 Measures for -40°C to 125°C (-40°F to 257°F)

More Info: http://www.ti.com/product/tmp006

Texas Instruments TMP006

Page 11: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

4. Thermocouples (TC)– Any two dissimilar joined metals form TC’s

• Seebeck effect voltage developed over entire length of wire• Several standard thermocouple types available• Pros/Cons: TRange / tiny signal (uV), relative temperature only• Products Available for -200°C to 1800°C (-328°F to 3272°F)

– Non-Linear Temperature/Resistance Curves• Up to 10 curve correction terms necessary for extremes

More Info: http://www.ti.com/lit/ml/slyp161/slyp161.pdf

Omega Thermistor Products

Page 12: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Approximate Type E TC Voltage Outputs

Chromel

Constantan

85C

Hot Junction Cold Junction

Vout = 25-25 * 62uV/C+-

85C

Chromel

Constantan

25C

Hot Junction Cold Junction

Vout = 85-25 * 62uV/C

85C+-

Vo= 3702uV = 0.003702V

Chromel

Constantan

25C

Hot Junction Cold Junction

Vout = -50-25 * 62uV/C

-50C+-

Vo= 0uV

Vo= -4650uV = 0.00465V

Hot Gradient

No Gradient

Cold Gradient

-

Page 13: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Type E TC Voltage vs ΔTemperature

0 10 20 30 40 50 60 70 800

500

1000

1500

X: 5.847Y: 94.31

Thermocouple Voltage [mV]

Cal

cula

ted

Tem

pera

ture

[C

]

Temeprature of (TJunction-TReference) versus Type E Thermocouple Voltage

X: 76.87Y: 1039

X: 76.87Y: 1024

X: 76.87Y: 1240Reference Omega 9th Order Curve

Approximated 62uV/C Curve

Approximated 74uV/C Curve

0 10 20 30 40 50 60 70 80-50

0

50

100

150

200

250

X: 13.79Y: -19.21

Approximation Error vs Reference Curve

Thermocouple Voltage [mV]Diff

eren

ce o

f (A

ppro

xim

atio

n-R

efer

ence

) [C

]

X: 66.57Y: 20.36

X: 76.87Y: 216.3

X: 5.863Y: 1.095

X: 76.4Y: 15.69+/- 20.5C Approx

0-1024C

+/- 1.1C Approx, 0-94C

Page 14: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

http://en.wikipedia.org/wiki/Thermocouples

Ice Bath Cold Junction Compensation

• Provides absolute temperature measurement vs 0C• Impractical for many applications to have an ice bath

Page 15: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Software Cold Junction Compensation

More Info: http://www.maxim-ic.com/app-notes/index.mvp/id/4026

1. Measure (TC Voltage) and (Cold Junction Temperature)2. Use (Cold Jct. Temperature) to calculate (Compensation Voltage) - Use TC curve to calculate cold junction voltage3. Add (Compensation Voltage) and (TC Voltage)4. Use TC Curve to calculate temperature at remote TC junction

RemoteThermocouple

Local TempSensor

Analog to Digital Converter

Cold Jct T/V Known

1

1

Page 16: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Integrated Thermocouple Interface

More Info: http://www.adafruit.com/products/269Example Code: http://www.ladyada.net/learn/sensors/thermocouple.html

Adafruit Breakout Board for MAX6675 Type K ThermocoupleRange: 0 to 1024C, Resolution: 0.25°C

SPI Serial Interface

Many other ‘simple’ thermocouple interface products available

Page 17: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

5. Semiconductor Band-Gap– Band-Gap Reference Based Sensor

• Precision current forced through diode– Diode forward voltage based on temperature– Voltage measured, amplified– Multiple output options: Alarm Logic, Analog, Serial

• Pros/Cons: Small, Cheap, Easy / T Range, Remote Fragility• Products Available for -55°C to 150°C (-67°F to 302°F)

– Linear Temperature Curves w/ Error Bounds

Microchip Tech.MCP9701ATO-92 Package

Microchip Tech.TC1047ASOT23 Package

Maxim Integrated ProductsMAX6626SOT23-6 Package

Example SOT-23-6

Page 18: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

MCP9701AOutput: 0.4V + 19.5mV/CRange: -40C to 125CAccuracy: +/- 2C (0-70C)Supply: 3.1-5.5V @ 6uA

TC1047AOutput: 0.4V + 10.0mV/CRange: -40C to 125CAccuracy: +/- 0.5C (0-70C)Supply: 2.3-5.5V @ 60uA

Tonight’s Sensors

Page 19: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

ADC High Level Concept

Analog Domain Digital Domain

SoftwareVin = count*(5/1023)Vin = 2.498V

ADC

5V

0V

2.498V 511

VREF+

VREF-

1023

0

A02.498V

Input Voltage Compare

1

23

Output Count

4

Page 20: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

How are we going to read the sensors?

Page 21: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

ArduinoStep 0: Installation / Orientation

Step 1: Connecting MCP9701AStep 2: Reading Analog to Serial

(Code)Step 3: Converting Analog to Voltage

and Temperature (Code)

If we have timeStep 4 Extra: Formatting Standard

String (Code)

ProcessingStep 0: Installation / Orientation

Step 1: Drawing BoxesStep 2: Serial Input and Events

(String Example)Step 3: Parsing Serial StringsStep 4: Real-Time Bar GraphStep 5: Real-Time ChartStep 6: Logging CSV Files

If we have timeStep 7 Extra: User Input, Events,

and ScreenshotsStep 8 Extra: Exporting Applications

Let The Hands-On Activities Begin!

Page 22: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

• 1. Software Installation• 2. Essential Hardware Features for Tonight• 3. Examples Library Run-Thru• 4. Disconnect Arduino for Wiring Step

Arduino Orientation

Page 23: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

MCP9701A TC1047A

Step 1: Sensor Wiring

Red = 5VBlue = GNDWhite = Vout -> Analog A0

Red = 5VBlack = GNDBlue = Vout -> Analog A0

Page 24: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Step 2 CodeReading the Analog to Digital Converter

void setup() // Setup Serial Port, 9600bps // Implied: 8-N-1: 8 Bit Transfers, No Parity, 1 Stop Bit Serial.begin(9600);

void loop() // Read Analog Channel 0 int analogValue = analogRead(0); // Print Line via Serial Port Serial.println(analogValue);

Initialize Variables and Peripherals

Main Loop

Page 25: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Step 3 CodeCalculating Voltage and Temperature

void loop() // Read Analog Channel 0 int analogValue = analogRead(0); // Calculating Voltage, VREF=5V,0V; float voltage = analogValue * 5 / 1023.0;

// Calculating Degrees C = (Volts-0.400) / 19.5mV float deg_C = (voltage - 0.400) / 0.0195;

// Calculating Fahrenheit = 9/5 C + 32 // Note: A common mistake is to use 9/5. 9/5 = 1 (Integer Math) // Use 9.0/5.0 to ensure floating point math ( = 1.8) float deg_F = (9.0/5.0)*deg_C + 32;

// Print out voltage, degrees C, and degrees F Serial.print(analogValue); Serial.print (" "); Serial.print (voltage); Serial.print (" "); Serial.print (deg_C); Serial.print (" "); Serial.print (deg_F); Serial.print (" "); // Extra space for easy parsing Serial.print ("\n"); // Send Line Feed (New Line)

// Delay 66ms, slowing to rate of about 15Hz updates delay(66);

Main Loop Modification

MCP9701A Only

For TC1047, use:(voltage-0.5)/0.01;

Page 26: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Processing Visualizations

“Just Landed” 3D Visualization of Twittering Travelers

Page 27: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

• 1. Software Installation• 2. Examples Library Run-Thru• 3. Arduino Night IV Code!

Processing Orientation

Page 28: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Step 1: Drawing BoxesStep 2: Serial Input and Events (String Example)Step 3: Parsing Serial StringsStep 4: Real-Time Bar GraphStep 5: Real-Time ChartStep 6: Logging CSV Files

Processing Code

Page 29: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Questions about the Arduino?

Page 30: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Special thanks to Ian Kitajima and Oceanit!

Page 31: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Backup Slides

Page 32: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Measuring Resistive Sensors– Resistance of Thermistors & RTD’s

• Ohm’s Law! V=IR -> R=V/I (Resistance = Voltage / Current)• Provide V or I excitation to find resistance

10Ω VR = 0.5A * 10 = 5V

+

-

5V

I = 5V/10Ω = 0.5AI = V / R

V = I * R

?

?

Page 33: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

100uA

Rt=?Vout =1V

+

-

5V

Rt = 1V/100uA = 10kΩ

Vout=It*Rt

Rt=Vout/It

Software Calculations

Voltage Measurement

1 2

3

4 Convert Rt to Temperature

It

Measuring Resistive Sensors– Method 1: Excite with current, measure voltage

• Difficulty: Precision low-current source required – Limited IC’s available (100uA, 200uA are common)– Not simple to build precision low-current sources– Question: Why not a high current source?

?

Page 34: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Measuring Resistive Sensors– Method 2: Excite with voltage, measure current

• Difficulty: Precision measurements of current required– Precision Current Sense Resistor (Rs) Required

» Low Temperature Coefficient Ideal– Smaller current sense resistors are better for linearity

Rs

100Ω+/- 0.01%

+

-

5V

Rt=?

Rt = 4V/10mA = 400Ω

Software Calculations

Is

Rt=Vt/It

+

-

Vt It

It = Is

1

2

3

Vout =1VVout=It*Rt

Voltage Measurement

Is = Vout/Rs = 10mA

4Vt = 5V – 1V = 4VVt = 5V - VRs

5

6 Convert Rt to Temperature

?

?

?

Page 35: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

Measuring Resistive Sensors– Method 3: Excite with significant voltage divider

• Difficulty: Measurements of R are very non-linear– Precision Voltage Divider Resistor Required

• Allows biasing of nominal temperature voltage (e.g. 2.5V @ 25C)

Rd

10kΩ+/- 0.01%

+

-

5V

Rt=?

Rt = 2V/300uA ~= 667Ω

Software Calculations

Id

Rt=Vt/It

+

-

Vt It

It = Id

1

2

3

Vout =3VVout=It*Rt

Voltage Measurement

Is = Vout/Rd = 300uA

4Vt = 5V – 3V = 2VVt = 5V - VRs

5

6 Convert Rt to Temperature

?

?

?

Page 36: Before we get started... Please sign the sign up sheet at   If you are going to Tweet, please use the.

• All excitations induce some self-heating– Trade between error and magnitude of signal– Low enough excitations induce no noticeable error– Excitation can be pulsed on/off to minimize self-heating

» Leads to transient increase in temp, so keep pulses short» Much less predictable offsets than constant excitation

• Current running through remote measurement leads can drop voltage, resulting in measurement errors– Look for 3 wire and 4 wire configurations for more accuracy

• Look-up tables can be used to speed up calculations– Linear approximations between points on an exponential curve– Trade between accuracy and computation time

Measuring Resistive Sensors