360 likes | 547 Views
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. Arduino Night IV. HI Capacity http://hicapacity.org October 11th, 2011 Jeremy Chan. What will we do?. Temperature Sensors Reading Sensors
E N D
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
Arduino Night IV HI Capacityhttp://hicapacity.org October 11th, 2011 Jeremy Chan
What will we do? Temperature Sensors Reading Sensors Intro to Processing Sensor Visualization Tonight Arduino (C/C++) rocessing (Java) RS232/USB (Async Serial)
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) Temperature Sensor Applications
Overview on: Thermistors Resistive Temperature Detectors (RTD) 3. Non-Contact IR Sensor (TI TMP006) 4. Thermocouples (Wide Range) 5. Semiconductor Band-Gap (Easy Interface) Temperature Sensors
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 1. Thermistors Omega Thermistor Products More Info: http://www.omega.com/temperature/z/pdf/z036-040.pdf
Thermistor Temperature[C] vs R[Ω] Datasheet / Calibration Constants: a,b,c,d,… Example: Vishay 10k NTC Thermistor Assembly Curve 0C to 100C 27.35kΩ to 0.974kΩ Temperature [°C] R[kΩ] Vishay Calculator: http://www.vishay.com/doc?29113 Vishay Thermistor: http://www.vishay.com/docs/29092/ntcalug.pdf
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) 2. Resistive Temperature Detectors US Sensor RTD Products More Info: http://www.ussensor.com/prod_Probes_RTDs.html
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[Ω] Example Pt100 RTD Temperature [°C] R[Ω] Thermistor: Steinhart-Hart Equation - Datasheet / Calibration Constants: a,b,c Curve Fit Error [°C] RTD, R to Temperature - Datasheet/Calibration Constants: a,b,c R[Ω]
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) 3. Non-Contact IR Temperature Texas Instruments TMP006 More Info: http://www.ti.com/product/tmp006
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 4. Thermocouples (TC) Omega Thermistor Products More Info: http://www.ti.com/lit/ml/slyp161/slyp161.pdf
Approximate Type E TC Voltage Outputs Hot Gradient No Gradient Cold Gradient -
Type E TC Voltage vs ΔTemperature +/- 1.1C Approx, 0-94C +/- 20.5C Approx 0-1024C
Ice Bath Cold Junction Compensation • Provides absolute temperature measurement vs 0C • Impractical for many applications to have an ice bath http://en.wikipedia.org/wiki/Thermocouples
Software Cold Junction Compensation Remote Thermocouple Analog to Digital Converter Local Temp Sensor Cold Jct T/V Known 1. Measure (TC Voltage) and (Cold Junction Temperature) 2. Use (Cold Jct. Temperature) to calculate (Compensation Voltage) - Use TC curve to calculate cold junction voltage 3. Add (Compensation Voltage) and (TC Voltage) 4. Use TC Curve to calculate temperature at remote TC junction More Info: http://www.maxim-ic.com/app-notes/index.mvp/id/4026
Integrated Thermocouple Interface Adafruit Breakout Board for MAX6675 Type K Thermocouple Range: 0 to 1024C, Resolution: 0.25°C SPI Serial Interface Many other ‘simple’ thermocouple interface products available More Info: http://www.adafruit.com/products/269 Example Code: http://www.ladyada.net/learn/sensors/thermocouple.html
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 5. Semiconductor Band-Gap Example SOT-23-6 Microchip Tech. MCP9701A TO-92 Package Microchip Tech. TC1047A SOT23 Package Maxim Integrated Products MAX6626 SOT23-6 Package
Tonight’s Sensors MCP9701A TC1047A Output: 0.4V + 10.0mV/C Range: -40C to 125C Accuracy: +/- 0.5C (0-70C) Supply: 2.3-5.5V @ 60uA Output: 0.4V + 19.5mV/C Range: -40C to 125C Accuracy: +/- 2C (0-70C) Supply: 3.1-5.5V @ 6uA
ADC High Level Concept Analog Domain ADC Digital Domain Input Voltage Compare Output Count Software Vin = count*(5/1023) Vin = 2.498V
How are we going to read the sensors? • To read voltages, use an analog to digital converter! • Converts voltage into a numerical ‘count’ • Arduino ADC • 10 bits of counting (a.k.a. 10 bit resolution/quantization) • How many levels? 2^10 = 1024 • Highest count? 1023, because 0 takes up one of them! • Single-Ended (input is always referenced to Arduino GND) • By default: • VREF+ = 5V, VREF- = 0V (single ended) • VREF- is the voltage at the 0 count • VREF+ is the voltage at the full-scale 1023 count • All counts 0 and 1023 are essentially equal increments • 1023 counts amongst 5V is 5/1023 ~= 0.00488V/count
Let The Hands-On Activities Begin! Arduino Processing Step 0: Installation / Orientation Step 1: Drawing Boxes Step 2: Serial Input and Events (String Example) Step 3: Parsing Serial Strings Step 4: Real-Time Bar Graph Step 5: Real-Time Chart Step 6: Logging CSV Files If we have time Step 7 Extra: User Input, Events, and Screenshots Step 8 Extra: Exporting Applications Step 0: Installation / Orientation Step 1: Connecting MCP9701A Step 2: Reading Analog to Serial (Code) Step 3: Converting Analog to Voltage and Temperature (Code) If we have time Step 4 Extra: Formatting Standard String (Code)
1. Software Installation 2. Essential Hardware Features for Tonight 3. Examples Library Run-Thru 4. Disconnect Arduino for Wiring Step Arduino Orientation
Step 1: Sensor Wiring MCP9701A TC1047A • Red = 5V • Blue = GND • White = Vout -> Analog A0 • Red = 5V • Black = GND • Blue = Vout -> Analog A0
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); } Step 2 CodeReading the Analog to Digital Converter Initialize Variables and Peripherals Main Loop
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) floatdeg_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); } Step 3 CodeCalculating Voltage and Temperature Main Loop Modification MCP9701A Only For TC1047, use: (voltage-0.5)/0.01;
Processing Visualizations “Just Landed” 3D Visualization of Twittering Travelers
1. Software Installation 2. Examples Library Run-Thru 3. Arduino Night IV Code! Processing Orientation
Step 1: Drawing Boxes Step 2: Serial Input and Events (String Example) Step 3: Parsing Serial Strings Step 4: Real-Time Bar Graph Step 5: Real-Time Chart Step 6: Logging CSV Files Processing Code
Resistance of Thermistors & RTD’s Ohm’s Law! V=IR -> R=V/I (Resistance = Voltage / Current) Provide V or I excitation to find resistance 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? 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 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) Measuring Resistive Sensors ? ? ?
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