Sensors and Actuators Pervasive Intelligent Environments Spring 2004 Copyright © 2004 Charles J. Hannon All rights Reserved. Overview Some basic definitions Some basic physics modality, sensors, actuators, and systems short review of energy and electronics Types of sensors and actuators How they communicate with computers Some examples of uses What is a Sensor? A device that captures information about the environment and converts it into a usable data signal Human example: Temperature information is captured at the posterior root of a sensory nerve and passed via an electro-chemical signal to the brain Computer Example: A LM34 chip converts the ambient temperature of its case into an analog voltage (0-5 volts) which an ADC turns into a binary signal usable by a computer What is an Actuator? A device that converts data signals into a useful modification of the environment Human example: The brain sends an electro-chemical signal down a motor pathway to a peripheral nerve causing a muscle to contract Computer Example: A processor generates a PWM signal (and a set of related logic signals) to an LMD18200 chip which converts these to a control voltage causing a DC motor to turn at a set speed in a set direction What is a Sensor/Actuator System? Sensor Peripheral Processing Peripheral Processing Actuator Fuser Sensor Peripheral Processing Actuator Fuser Sensor Peripheral Processing Central Processing Actuator Fuser Sensor Peripheral Processing Peripheral Processing Actuator So Why Do We Need Sensors and Actuators? Information about the world exists in different modalities Behind these modalities (and our ability to interact with them) is a physical system made up of space, energy and matter To function in the world, we need to i.e., how things look, feel, sound, taste … interface with available modalities of information without having to worry about the underlying physics To do this, we need to sense, fuse, interpret and react to the world as a modal system sensors and actuators use physical laws to handle the modal information interface at a level of abstraction we can handle So Why Do Computer Systems Need Sensors and Actuators? To interface with an environment on our behalf Constant and/or repetitive task Dangerous, hostile and/or remote environments e.g., keeping track of long-term relatively stable conditions so it can take quick direct action when an anomaly occurs bomb defusing, nuclear disaster area, trips to Mars, etc. To extend our abilities to sense and control An IR or UV sensor can ‘see’ things we can’t A heat sensor can provide a more accurate temp. A robot arm can lift heavy objects and position them with greater accuracy How Do Computer-Based Sensors and Actuators Work? Biological processors use complex analog electro-chemical signals, but digital computers use signals that only consist of a high and low voltage level Thus, computer-based sensor and actuator systems must convert all modalities of sensor input into a meaningful set of these two voltage levels To understand how this is done, we need to first review a little basic physics The Physics Behind Modality The driving engine of the physical universe is energy, not matter What we perceive as modalities are really just different forms of three type of energy In fact, one unifying theory of physics, called String Theory, claims that matter is just a form of energy Electromagnetic radiation Motion (or displacement) of matter Chemical bonding Very specialized computer sensors can detect other forms of energy, but we will not cover these Electromagnetic Radiation (source: http://www.lbl.gov /MicroWorlds /ALSTool/EMSpec/EMSpec2.html) We see a very small part of the EM spectrum (0.7-0.4 M) We emit IR radiation (~10 M) Computer sensors and actuators can be designed to ‘see’ and emit almost any part of the spectrum Motion Macro Displacement Heat (atomic and molecular movement) sensors can detect motion actuators can move the system or surrounding objects sensors can detect ambient or radiating body heat almost all actuators will generate waste heat even if you do not want them to Sound (compressional waves) needs a medium for transmission (I.e., cannot travel through a vacuum) computer sensors can detect and actuators can generate compressional waves over a much broader range than humans Chemical Bonding Undetectable to us, are a set of forces that hold matter together At the molecular level, these forces control the way chemicals bond Our bodies use bonding receptors to smell and taste generate chemical compounds that can carry information about our physical (and mental) state Current computer sensors/actuators are poor detectors and generators of such information Tapping Into the Energy Information Pipeline For a computer sensor or actuator to work they need to understand the language of the world: information modality based on energy transmission the language of the computer: information transmission based on discrete logic have an internal way to store and convert between these languages Since computers are electronic systems, the best way for computer sensors or actuators to do this is via electronics The Tapping Tools Electricity current, voltage, resistance and power Ohm’s law capacitance, but not inductance Electronics semiconductors (a very brief overview of theory) resistors, capacitors, diodes, and transistors integrated and discrete circuits Note: integrated circuits are normally abbreviated as ICs To get Started – A Simple Definition of a Circuit A electronic circuit is simply a set of electronic components (resistors, capacitors, ICs, etc.) connected together via wires The example on the left is a circuit that debounces a switch sensor Definition: Current How is current (I) defined? Pick any point in an electrical circuit Define a unit of charge (Q) Measure the change in charge with respect to time at this point The charge of one electron = -1.6x10-19 coulombs dQ/dt I What is the unit for I? 1 ampere = 1 coulomb / 1 second Most of the time this is just referred to as an amp Definition: Voltage At any point in a circuit, a positive charge (Q) has some level of potential energy (W) Caused by its attraction to any build-up of negative charges in the circuit Voltage (V) is defined as the normalized value of this PE Units I.e., V W/Q 1 volt = 1 joule / 1 coulomb So a voltage drop between two points in a circuit is really a relative measurement of the change in PE for a given charge Definition: Resistance Static resistance is something that blocks the flow of Direct Current (DC) A resistance between point A and point B will cause a difference in the PE between the points, and thus a voltage difference This difference is also dependent on how much current is flowing from A to B I.e., R = (V2 – V1)/I Units 1 ohm = 1 volt /1 amp Definition: Power Now that we have a definition for current and voltage, we can get a definition for power Power is the amount of work that can result from the circuit P dW/dt or more simply, P = V x I For example: lighting a light bulb If no useful work can be done, the power is lost as heat Ohm’s Law The voltage drop across a resistance is equal to the current times the resistance V = IR Using what we have already defined, this can be expressed as V = IR = P/I = (PR) –1/2 R = V/I = V2/P = P/I2 I = V/R = P/V (P/R) –1/2 P = VI = I2R = V2/R Useful Info from Ohm’s Law Resistance in series Rt = R1 + R2 Resistance in parallel Rt = 1/(1/R1 + 1/R2) = R1R2/(R1 + R2) Definition: Capacitance How is capacitance (C) defined? OK, what does that mean? C Q/V Capacitance occurs when two conducting surfaces are separated by a dielectric OK, what’s a dielectric? a substance that is a poor conductor but a good medium for an electromagnetic field What is the units for C? 1 farad = 1 coulomb / 1 volt Combining Capacitance The exact opposite of resistance Capacitance in parallel Ct = C1 + C2 Capacitance in series Ct = 1/(1/C1 + 1/C2) = C1C2/(C1 + C2) What Is a Semiconductor? A substance that has a natural property that By adjusting this natural property by adding impurities to the substance allows it to act like either a conductor or an insulator we can use two or more of these substances to control the way current flows through a circuit in very interesting ways To understand why this is important to the study of sensor and actuators we need to introduce something called Band Theory Band Theory: Some Terms Valence Band Conduction Band The base energy level of the outer-most shell of electrons The energy level necessary for the outer-most electrons to be free to conduct Fermi level The maximum energy the outer-most electrons can have at absolute zero Band Theory For a conductor For an insulator The Fermi level is within the conductive band The Fermi level is between the bands and the bands are separated by a great deal of energy For a pure semiconductor The Fermi level is halfway between the bands and the bands are separated by much less energy Thus, A Semiconductor Has An Identity Crisis You can control how it acts by controlling its temperature lower the temperature and it acts more like an insulator raise the temperature and it acts more like a conductor So is that it? No, this natural property is interesting but not terribly useful by itself However, by adding impurities to a natural semiconductor we can create either a N-type semiconductor by adding extra valance electrons to its lattice structure P-type semiconductor by adding adding holes to its lattice structure Now they really have an identity crisis !!! Semiconductors In Love (source: http://hyperphysics.phy-astr.gsu.edu/) The addition of electrons and holes pushes the Fermi level away from the center while adding a relatively unstable charge to each type of semiconductor Mating a N and P type semiconductor gives them a chance share electrons, something they are both very willing to do An Almost Fatal Embrace (source: http://hyperphysics.phy-astr.gsu.edu/) Once mated, the P part of an P-N junction is not about to give up those new electrons, so this creates a depletion region at the NP junction If you try to run a reversed bias current (N P), the only effect is to increase the depletion region However, a forward bias current (P N), will flow through the junction But What Good is a Electronic One Way Street? It turns out to be very important, because we can control when and how the depletion region does its thing This allows all sorts of useful things Components whose resistance or voltage output change based on their exposure to EM, heat, magnetic fields, etc. Components that emit EM radiation, sound, etc. Finally, The Next Level Now that we have the necessary foundation we can briefly address the use of the electronic components you will be seeing in the lab then, start designing some simple sensors and actuators and finally, use this knowledge to talk about some sensors and actuators that are a little too complex to play with in this class The Resistor A resistor provides a known resistance It has three values: Resistance, measured in ohms Tolerance, measured in +/- percent error Power dissipation, measured in watts Using Ohm’s law (V=IR), it can be used to create a desired voltage or current but a voltage drop across a resistor is converted to waste heat, so this is not always the best way to do that A Light Bulb It is a resistor encased in a vacuum in a clear or translucent container It has two values It obeys Ohm’s law (V=IR) Rated voltage (either AC or DC) Lumen (how much light it puts out at its rated voltage) but a voltage drop across a resistor is converted to both to light and to waste heat Even small light bulbs use a lot of current so never try to drive them directly off an I/O line ! The Capacitor – A bit more complex First, some relative definitions Let us assume that a capacitor already has some positive charge on one plate and some negative charge on the other, then a positive voltage difference (between the plates) is one that supports (i.e, is in the same direction) as this existing charge a negative voltage difference is one that counters (i.e, is in the opposite direction) as this existing charge OK, now we can start to talk about what it does When there is a positive voltage increase between the two plates, more charge will build up on both plates When there is an negative voltage increase, there will be a reduction in the charge built up on the plates So What Does this Change in Charge Do? First, the effect of a change in the voltage difference between the plates only lasts until enough charge has been added or subtracted to match the change During the change in charge, I.e., assuming that you do not apply more voltage than the capacitor can handle, a capacitor’s plate charge will always attempt to reach an equilibrium with new voltage difference current will appear to pass between the plates When a charge-voltage equilibrium is reached, no current will pass between the plates Capacitors in a DC Circuit When DC is first applied to a capacitor current will ‘pass’ through the capacitor for a very short time while its plates charge to match the voltage difference seen by the capacitor then, no DC will pass So, a capacitor will once charged, look like an infinite resistance to any DC trying to pass through it act like a very short term battery when the DC current in the circuit is turned off or reduced Capacitors in a AC circuit Alternating Current (AC) can pass through a capacitor How ‘well’ it passes depends on the frequency of the AC the relative charge capacity of the capacitor for the given AC voltage (measured in farads) the way the capacitor is wired to the circuit So, the impedance (or AC resistance) of a capacitor can be used to filter out AC at frequencies you do not want Capacitors - A Useful Unit Unless you are building a large AM radio station, a farad is an absurdly large unit of capacitance so, we need to find something smaller In enters our standard powers-of-ten prefixes 0.000,001F (1x 10-6) = 1F (microfarad) 0.000,000,001F (1x 10-9) = 1nF (nanofarad) 0.000,000,000,001F (1x 10-12) = 1pF (picofarad) so, 1mF = 1000nF = 1,000,000 pF capacitors are normally labeled using F or pF The Diode It is a P-N junction device that come in many varieties Diodes normally have two leads called the anode and cathode Uses DC power supplies use four power diodes in something called a full-wave bridge to convert AC to DC We will be using a Light Emitting Diode (LED) as an actuator Just as with other diodes, it works like a one way street for current, but converts almost all of its waste energy to light The reverse photo process from a LED can be used to create one type of photo-detector called a photo-diode We may discuss some other types later The Bipolar Transistor It is made up of a NP-PN or PN-NP junction (called a NPN and PNP transistor) It normally has three leads called the base, collector and emitter It is most commonly used as a current amplifier by allowing a small current flowing through the base to modulate a larger current flowing through to the collect-emitter A solid-state switch by using the base current to turn on and off the collector-emitter current In actuator circuits, it is normally used as a switch to allow a processor to safely drive a high current device The Field Effect Transistor It is made up of a P surrounded by two Ns or a N surrounded by two Ps It can have three leads called the gate, source, and drain, but often has only a source and drain A FETs is basically a solid-state resistor with most of its resistance being controlled by the amount of reverse bias applied to the gate FETs are useful for building certain types of sensors since the gate can be designed to allow its overall source-drain resistance to be controlled by a number of different types of energy Other Semiconductor Types Semiconductors can be doped with a number compounds that have quite unique properties to start with So, some sensors can be built from a single semiconductor type for example, we will be using a Cadmium Sulfide (CdS) photoresistor There is also many more ways to create junctions than the three main ones described here Integrated Circuits (ICs) ICs are basically just a bunch of semiconductors built on the same main substrate Far too many ICs could be used in sensor/actuator designs to allow any kind of comprehensive list For the lab, we will use A Javelin stamp (containing an SX48BD microcontroller) a LM34 temperature sensor For general information will will discuss A LMD18200 motor controller A UNC5804B stepper controller PCF8591 analog-to-digital converter And some general buffer and conditioner IC’s Types of Sensors – Based on Modality Simple Modality Complex Modality movement, position, and acceleration EM detectors (IR and visible light most common) temperature and pressure chemical (e.g., CO) or particle (e.g., smoke) sound activation speed and distance geographic (or absolute) positioning readers: bar code, magnetic strip, fingerprints, retina scan, etc. Meta-Sensors smart floor, computer vision, language understanding, etc. Types of Sensors – Based on Emission Examples if passive sensors position switch ambient temperature, pressure, etc. IR or visible light-level detector passive IR motion detection Examples of active sensors speed and ranging: sonar, radar, lidar, etc. motion: active IR, laser, sound, etc. Composition and/or deformation: lasers, X-Rays, radiological, etc. Remote sensing: lasers, sound waves, etc. Types of Sensors – Based on Processing (1) Dumb sensors with uncalibrated outputs calibrated analog outputs Example: a CdS photoresistor connected to a RC time circuit Example: a LM34 temperature sensor connected to a delta sigma circuit calibrated digital outputs Example: a temperature sensor circuit using a LM34 and a PCF8591 analog-to-digital converter Types of Sensors – Based on Processing (2) Smart sensors with fusion with communication Example: a temperature/light sensor circuit that can correlate temperature and light readings to send a number of different types of alerts Example: a temperature sensor circuit that contains an Ethernet controller board that can be programmed to send raw data and/or a set of alerts Intelligent sensors Example: a temperature/light sensor circuit with fusion and communication that can also reason about how to investigate and resolve it own alerts Types of Actuators – Based on Modality Simple Modality Complex Modality indicators – light, sound, vibration, etc. motion – relays/switches, motors, solenoids, etc. exotic – shape metals, Emit EM, explosives, etc. text and graphics display voice or image generation Meta-Actuators language generation holographic projections Types of Actuators – Levels of Motion At one level of abstraction, almost all motion is controlled by relays and switches At the next level, by electric motors and solenoids example: a robot arm could be moved by either a simple constant rotation AC or DC motor a stepper motor or a servo a hydraulic system using pump motors and solenoid-controlled values Some pretty rare counter examples shaped metals internal combustion rockets Types of Actuators – Levels of Everything Else The same type of reductionism can be also be applied to other actuator modalities The bottom line: for a computer system, once you figure out how to control a light bulb, you have pretty much have solved the actuator control problem This will not stop us from addressing what you need to do to control something like a DC motor but it does mean that you can learn most of the important details in dealing with actuators in your lab by learning how to control a light bulb The Javelin Stamp – Basic Interface Javelin- Some App Notes DTR (pin4) 0.1F ATN (JS pin3) 0.1F The circuit on the left should be used to condition the DTR/ATN connection Connect the +5V side of your power supply to pin 21 and the GND to pin 23. DO NOT use pin 24 There is nothing optional about connecting a reset button between GND and pin 22. It is absolutely necessary! Be careful, the Javelin is expensive ($89) and if you break it, you buy it. The Temperature Sensor +5v P9 (pin 14) LM34 1M 1M P8 (pin 13) 1F Note: make sure you connect the voltages correctly to LM34 or you are going to have a short-lived room heater. This circuit supports a poor man’s approach to ADC called delta sigma using the ADC VP object (page159) You may need to play with the resistor and capacitor values to get useful output, but be careful not to over drive P8 How The Circuits Works (1) The output of the LM34 changes +10mV/°F should be very close to 0mV at 0°F Now the trick for doing ADC without an ADC chip the SX controller of the Javelin is a CMOS device so its logic threshold voltage for a high value (i.e., when a zero becomes a one) is 2.5 volts This means that if you apply a value less than 2.5 volts to an input line, the Javelin will assume it is a zero How The Circuits Works (2) Assume that the LM34 is putting out zero volts applying a high voltage (5V) to P8 would generate a 2.5V drop across both resistors and the capacitor would be held at 2.5 volts above ground applying a low to P8 would cause the charge on the capacitor to begin bleeding off and the voltage would drop below 2.5 volts every 2.1 ms the ACD object reads the truth value of pin P9 (equal to the voltage across the capacitor) since the duty cycle of the pulse is timed to allow some bleed off before the measurement is taken, if the LM34 is putting out zero volts, and all 255 samples would be zero How The Circuits Works (3) Now, assume that the LM34 is putting out 5 volts applying a high voltage (5V) to P8 would generate no voltage drop across the resistors and the capacitor would be held at 5 volts above ground applying a low to P8 would cause the charge on the capacitor to begin bleeding off but the voltage would never drop below 2.5 volts thus, all 255 samples would be ones At this point, it should be obvious that LM34 voltage outputs between 0 and 5 volts would generate values between 0-255 Issues With the Circuit From the discussion, it should be fairly clear that a delta sigma ADC is both slow and fairly inaccurate Further, the ADC has a resolution which is about ½ that of the temperature sensor so we are losing a great deal of information Last, it does not help that the LM34D only generates a voltage range of 320-2120 mV losing more than half of the ADC’s range Is there a way to fix any of these problems? The Light Sensor +5V 1F 220 P4 (pin 9) The good news is that this circuit supports a very common approach to measuring resistance called rcTime (page 55) The bad news is that CdS photoresistors are notoriously inaccurate They have a memory which can last up for days How The Circuits Works (1) The resistance of a typical CdS is inversely proportional to the amount of light falling on its surface Built into the Javelin CPU object are all of the methods needed to support this circuit First you call a CPU.writePen method to set the pin high, and thus, charge the capacitor Then you call a CPU.delay method to ensure that it is fully charged Finally, you call a CPU.rcTime method which track how long it takes for the capacitor to bleed below 2.5 volt How The Circuits Works (2) The time it takes for the capacitor to bleed down is directly proportional to the resistance of the photoresistor, and thus, to the amount of light falling on its surface Once you characterize your photoresistor’s performance, the rcTime output can be used to keep track of how much light your sensor is seeing at any given time This light can be from an ambient source or from one of your own actuators The Light Bulb +5v c 1k b e TIP120 Note: make sure you connect The TIP120 correctly. P3 (pin 8) This circuit allows a standard light bulb to be driven by a output pin Set the pin high to turn in the light and low to turn it off The LED 470 P5 (pin 10) This circuit drives an LED off an output pin Set the pin high to turn on the LED and low to turn it off Since LEDs take so little current, no amplifier/buffer stage is needed The Piezo Speaker/Buzzer + P4 (pin 9) This circuit drives an piezo device off an output pin You will need to use the Freqout object to control this device If your device can generate different tones based on a square wave input, the Freqout object can be used to play musical alerts PCF8591 Analog-to-Digital Converter One of the many combined A/D–D/A converters Multiplexes up to four inputs and has a I2C bus But, we want to make two points here First, a SPD can always out-perform a GPD, especially if the general purpose device’s solution is software based The PCF8591 samples about 1000 times faster than our lab approach Second, all the sophistication in the world cannot overcome a basic physical limit The PCF8591 is still an 8-bit device, and thus is limited to 256 different output values Buffer and Conditioner controllers and controller modules (like the Javelin) expect to be talking to discrete components so they are designed to handle it PCs are not Never connect a sensor like the ones we are building to a PC without adding a buffer or conditioner to protect the PC from stray signals which might damage it A number of ICs exist to support such buffering The LMD18200 Motor Controller A standard DC motor develops its maximum torque when it is running its fastest This means if we want to run it slower (by reducing its the input voltage) it will generate less torque One way to get around this is to reduce speed by reducing the duty cycle of the signal, not the amplitude It’s a great idea, but hard to execute The LMD18200 is an IC designed to control the direction and speed of a DC motor using a PWM signal Now the only problem is getting your processor/ controller to generate enough PWM signals The UNC5804B Stepper Controller A stepper motor develops its maximum torque when it is not turning at all (the reverse of a standard DC motor) It does this by breaking its coil windings down into a set of phased windings Therefore, getting it to turn in the right direction for the right number of turns is not as simple as sending in a voltage, in fact it is a lot like coding in binary with the number of digits being related to the number of phases The UNC5804B is an IC designed to allow you to simply send the number of steps you want the motor to take and it handles the rest of the problems for you Meta-Sensor and Meta-Actuators With all the industrial and university research going on with things like Smart Home, the line between what is a sensor/actuator and a complex system containing sensors and actuators has begun to blur In the next few slides, I would like to address a few such meta-systems Smart Floor The idea behind the smart floor is literally brilliant On earth, most people tend to walk on the floor Using a very simple array of sensors I can not only keep track of how many people are in a room, house, street, etc. but based on know factors like shoes, gate, etc. I can track individuals, and even monitor them for health (and other) reasons What makes this something to watch is that it is truly out-of-sight and out-of-mind Computer Vision (1) A few years ago, a big problem with trying to do computer vision was that all of the good cameras were analog This has now totally changed, making it relatively easy and inexpensive to send camera data to a computer But once you get it there, what do you do with it? Computer Vision (2) Eyesight is one of our most complicated skills From a set of color blobs and simple spatial patterns we are constantly creating images and other visual elements to help us process this near chaos of data What is amazing is that in the last few years we have made as much progress as we have in computer vision But computers are a long way from handling vision at anything near the level of human ability Language Generation Language generation is one of the least demanding uses of actuators Almost any PC in the world already has more than enough hardware to generate speech It is also not that hard to generate wellformed spoken sentences The problem is that we are still years away from having a computer that has the foggiest idea what it is saying when it creates those well-formed sentences Finally, the Very Last Topic Beyond sensors and actuators Even beyond meta-sensor and meta-actuators There is one last thing that serves a similar purpose at the philosophical level of this research That is our need to connect at a social level with an all invasive smart environment Let’s briefly look at this topic See Me, Touch Me, Feel Me… In English, house and home have very different meanings Dr Cook picked the term Smart Home because she wanted to convey connection So how can we try to get this connection Language Understanding Virtual Presence Physical Point of Focus Let us look at these briefly Language Understanding (1) There are almost always at least two ways to solve an AI problem one of brute force one that has a shred of explanation behind it For the brute force approach to language understanding there is a brick-wall seven miles high Human language is not just a tool, it’s artistic medium, a security blanket, even a toy … Language Understanding (2) Professors in front of keyboard may be willing to play by a subset of the discourse and social rules But humans use language to be human All attempts to introduce a subset of language understanding within a home or work environment have and will fail because people view these as an invasion of their humanity Language Understanding (3) So is the talking home, car, etc. a lost cause? No, but until we can lose sight of the fact that we are talking to a computer, we will resent the fact that it has violated our most personal space To do this computers will not only have to understand us, they will have to emulate us. This is a very hard thing to do. Free-Standing 3-D Projections We have all seen the movies This is clearly one road to the average person’s acceptance of the necessary control implied by smart environments People are much more willing to accept constraints when they can identify (even falsely) with the entity generation those constraints Unfortunately, very little serious work appears to be happening in this research area. A Physical Point of Focus A possible substitute for a virtual presence could be a physical robot with the title of home manager This will be more of a leap of technological faith for some, but it will still allow them to focus their anxiety about a perceived loss of control at a tangible focus. I suggest that this robot be well build and able to appear to show great remorse for his wayward ways