Sensors

From CCRMA Wiki

(Difference between revisions)
Jump to: navigation, search
(Motors/PWM)
 
(35 intermediate revisions not shown)
Line 24: Line 24:
Potentiometers (Pots) are the simplest group of continuous sensors. A potentiometer is a special resistor with a third movable contact, called a wiper. A pot has a fixed resistance from one end to the other as does a normal resistor, but the resistance between the wiper and the ends changes as the wiper is moved (one gets smaller as the other gets larger - the always add up to the fixed resistance between the fixed ends). For rotary pots, the wiper moves as the shaft turns. For linear or slide pots, the wiper moves with the slider.
Potentiometers (Pots) are the simplest group of continuous sensors. A potentiometer is a special resistor with a third movable contact, called a wiper. A pot has a fixed resistance from one end to the other as does a normal resistor, but the resistance between the wiper and the ends changes as the wiper is moved (one gets smaller as the other gets larger - the always add up to the fixed resistance between the fixed ends). For rotary pots, the wiper moves as the shaft turns. For linear or slide pots, the wiper moves with the slider.
 +
In the following circuit, the position of the potentiometer wiper adjusts the brightness of the LED. We often make assumptions to simplify circuit analysis. For example, to estimate the current I, we assume here that Vled=0.
<center>[[Image:Pot_circuits.png]]</center>
<center>[[Image:Pot_circuits.png]]</center>
-
 
-
A potentiometer is normally interfaced to a microcontroller by digitizing the voltage found across it using an ADC( Analog to digital converter ). An alternate method for determining the value of a potentiometer is to place it in an RC circuit and measure the decay time
 
Potentiometer nomenclature:
Potentiometer nomenclature:
Line 33: Line 32:
* '''turns''' - Some pots cover their range of resistance with only one turn while other can take ten or more turns. The multi-turn pots afford greater precision, but normally cost more and obviously take longer to turn!
* '''turns''' - Some pots cover their range of resistance with only one turn while other can take ten or more turns. The multi-turn pots afford greater precision, but normally cost more and obviously take longer to turn!
* '''taper''' - The "taper" of a pot refers to the curve formed by plotting the rotation (for a rotary pot) or displacement (for a slide pot) on the X-axis and resistance between the pin 1 and the wiper (R1 above) on the Y-axis. A "linear" taper would have a straight line, such that at 180 degrees rotation, the resistance is half of the total resistance. In "Logarithmic" (or "Log" or  "Audio") taper pots the resistance changes logarithmically with rotation. These pots are commonly used in analog audio mixers because humans perceve logarithmic changes in loudness roughly linearly.
* '''taper''' - The "taper" of a pot refers to the curve formed by plotting the rotation (for a rotary pot) or displacement (for a slide pot) on the X-axis and resistance between the pin 1 and the wiper (R1 above) on the Y-axis. A "linear" taper would have a straight line, such that at 180 degrees rotation, the resistance is half of the total resistance. In "Logarithmic" (or "Log" or  "Audio") taper pots the resistance changes logarithmically with rotation. These pots are commonly used in analog audio mixers because humans perceve logarithmic changes in loudness roughly linearly.
 +
 +
See the following
 +
[http://ccrma.stanford.edu/courses/250a/docs/datasheets/EWA.pdf slider data sheet] for information on an audio taper slider pot.
===Potentiometer Circuit===
===Potentiometer Circuit===
 +
A potentiometer is normally interfaced to a microcontroller by digitizing the voltage found across it using an '''[http://en.wikipedia.org/wiki/Analog-to-digital_converter ADC (Analog to digital converter]'''). For example, connect V in the following circuit to an ADC.
<center>
<center>
[[Image:Pot.png]]
[[Image:Pot.png]]
</center>
</center>
-
==Slider Potentiometer==
 
-
 
-
[http://ccrma.stanford.edu/courses/250a/docs/datasheets/EWA.pdf Slider Data Sheet]
 
-
 
-
==Reflective Optical Sensor==
 
-
 
-
<center>[[Image:Optical.png]]</center>
 
-
The reflective optical sensor consists of an infrared LED and a phototransistor that passes an amount of current proportional to the reflected light received. We use two kinds at CCRMA, the Fairchild [http://ccrma.stanford.edu/courses/250a/docs/datasheets/QRB1114.pd QRB1114] has the letter "E" (Emitter) to label the LED, and the label "S" (Sensor) for the phototransistor. The Optek [http://ccrma.stanford.edu/courses/250a/docs/datasheets/OPB703.pdf OPB704] uses the symbols for an LED and a transistor to label the two sides. One leg of the sensor is connected to +5V, which supplies current, and the voltage drop across the 10k resistor that we measure is proportional to the amount of current.
 
-
 
-
There is a continuous voltage response for objects over a short range of proximity to the sensor. The response is not linear. Linearity can be approximated by the log of the log of the signal.
 
-
 
-
==Quadrature Encoders==
 
-
 
-
 
-
<center>[[Image:Quadrature.png]]</center>
 
-
 
-
 
-
The above diagram demonstrates two signals in a quadrature relationship. The most common sensor we use that has this kind of signal is a rotary encoder or shaft encoder. Rotary encoders are normally optical (expensive) or mechanical (cheap). A mechanical encoder works simply by connecting the Phase A and Phase B pins (pins 1 and 3 in the diagram below) to a common pin (pin 2), according to a quadrature pattern. Wired up as in the diagram, pins 1 and 3 will go to ground when when connected to pin 2, and will be high when they are not. Mechanical contacts inside the encoder create the quadrature signals as above. An optical encoder may function similarly using LEDs and phototransistors as in the IR sensor above, with alternating dark/light patterns applied in quadrature.
 
-
 
-
Note that Phase A leads Phase B by 90 degrees when looking from left to right. Looking from right to left the opposite is true. We use quadrature encoders with the external interrupt on a microcontroller. By connecting the Phase A pin to an interrupt, we can generate an interrupt SIGNAL (function call) every time it transitions from low to high. In the interrupt, we can check the state of the Phase B pin. If B is low when A goes high, then we have moved to the right. If B is high when A goes high, then we know we have moved to the left. Shaft encoders are rated with a number of counts or ticks per complete rotation. Note that if we attach both Phase B and Phase A to external interrupts, we can double the resolution.
 
-
 
-
<center>[[Image:Encoder_filter.png]]</center>
 
-
 
-
This filter circuit helps to stabilize the output of the shaft encoder and reduces noise by introducing pull-up resistors and low pass filters with cut-off frequency of ~ 1.6kHz on each of the two output pins.
 
-
 
-
 
-
===Features===
 
-
 
-
Shaft encoders normally turn infinitely. If we know the number of counts, we can keep track of the absolute position of the shaft. By measuring the time between ticks (or between some number of ticks), we can calculate velocity. Also, using an IR reflective object sensor and some custom printed paper, for example, you can build your own quadrature encoder. There is NO A/D conversion involved in using a shaft encoder!  Shaft encoders are commonly used in automation and robotics conjunction with motors to achieve accurate positioning. They are also ubiquitous on volume knobs in stereo equipment.
 
==Bend Sensor==
==Bend Sensor==
Line 91: Line 65:
<center>[[Image:FSR_resistance_function.gif|Conductance as a function of force for a typical force sensing resistor]]</center>
<center>[[Image:FSR_resistance_function.gif|Conductance as a function of force for a typical force sensing resistor]]</center>
 +
 +
* [http://ccrma.stanford.edu/courses/250a/docs/datasheets/fsrguide.pdf FSR Integration Guide]
===FSR Circuit===
===FSR Circuit===
Line 102: Line 78:
===Photo Resistor Circuit===
===Photo Resistor Circuit===
 +
A photoresistor is a resistor whose resistance changes depending on the amount of light shining onto the surface.
<center>
<center>
[[Image:Photo.png]]
[[Image:Photo.png]]
</center>
</center>
 +
 +
 +
==Piezoelectric Sensors==
 +
 +
* Notes below are from the lecture notes of the former [http://ccrma.stanford.edu/CCRMA/Courses/252/sensors/node7.html CCRMA Music 252 Course]
 +
 +
The Piezoelectric effect is an effect in which energy is converted between mechanical and electrical forms. It was discovered in the 1880's by the Curie brothers. Specifically, when a pressure (piezo means pressure in Greek) is applied to a polarized crystal, the resulting mechanical deformation results in an electrical charge. Piezoelectric microphones serve as a good example of this phenomenon. Microphones turn an acoustical pressure into a voltage. Alternatively, when an electrical charge is applied to a polarized crystal, the crystal undergoes a mechanical deformation which can in turn create an acoustical pressure. An example of this can be seen in piezoelectric speakers. (These are the cause of those annoying system beeps that are all too common in today's computers).
 +
 +
 +
<center>[[Image:Electret.gif|Internal Structure of an electret]]</center>
 +
 +
Electrets are solids which have a permanent electrical polarization. (These are basically the electrical analogs of magnets, which exhibit a permanent magnetic polarization). The figure above shows a diagram of the internal structure of a electret. In general, the alignment of the internal electric dipoles would result in a charge which would be observable on the surface of the solid. In practice, this small charge is quickly dissipated by free charges from the surrounding atmosphere which are attracted by the surface charges. Electrets are commonly used in microphones.
 +
 +
Permanent polarization as in the case of the electrets is also observed in crystals. In these structures, each cell of the crystal has an electric dipole, and the cells are oriented such that the electric dipoles are aligned. Again, this results in excess surface charge which attracts free charges from the surrounding atmosphere making the crystal electrically neutral. If a sufficient force is applied to the piezoelectric crystal, a deformation will take place. This deformation disrupts the orientation of the electrical dipoles and creates a situation in which the charge is not completely canceled. This results in a temporary excess of surface charge, which subsequently is manifested as a voltage which is developed across the crystal.
 +
 +
<center>[[Image:Piezo.gif|A sensor based on the piezoelectric effect]]</center>
 +
 +
In order to utilize this physical principle to make a sensor to measure force, we must be able to measure the surface charge on the crystal. The figure above shows a common method of using a piezoelectric crystal to make a force sensor. Two metal plates are used to sandwich the crystal making a capacitor. As mentioned previously, an external force cause a deformation of the crystal results in a charge ''q'' which is a function of the applied force. In its operating region, ''q'' is proportional to the applied force ''f''.
 +
 +
There has been some confusion on the world wide web about the correct equivalent circuit model for a piezo sensor, so we provide it here. The piezo is modeled as a capacitor with capacitance ''C'' in parallel with a current source. Since the current flow is equal to the derivative of the charge, we label the current source as ''dq/dt''. Finally, a resistor ''R<sub>leak</sub>'' is placed in parallel with the other two elements.
 +
<center>[[Image:Piezo_circuit.png|Piezo sensor equivalent circuit model]]</center>
 +
 +
Typically, the voltage ''V'' across the piezo terminals is measured. The transfer function of output voltage as a function of the charge is ''V(s)/q(s) = sR<sub>leak</sub>/(1+sR<sub>leak</sub>C)''. The resistor ''R<sub>leak</sub>'' results in a high-pass behavior. This explains why piezos can sound high-passed (or "quacky" in the case of piezo guitar pickups). To minimize the effects of the high pass filter, a voltage follower circuit can be placed in between the piezo and the input to the ADC.
 +
 +
The following image shows a piezo pickup for electric guitar. The piezo is embedded inside a GHOST piezo saddle from ''[http://www.graphtech.com/ Graph Tech]'', allowing the pickup to be easily installed at the bridge.
 +
<center>[[Image:Piezo_saddle.jpg|GHOST piezo saddle]]</center>
 +
Similarly, acoustic guitar pickup sensors often consist of a simple piezo strip sandwiched inside the bridge.
 +
 +
Alternatively, if one were to apply a voltage to the plates of the system described above, the resultant electric field would cause the internal electric dipoles to re-align which would cause a deformation of the material. An example of this is the fact that piezoelectric transducers find use both as speakers (voltage to mechanical) and microphones (mechanical to electrical).
 +
 +
===Simple Sensing Circuit===
 +
 +
This circuit is simple. The diodes ensure that the piezo (drawn in as a capacitor '''C<sub>piezo</sub>''') does not produce voltages too far out of the range acceptable to the analog-to-digital converter (ADC), which is 0V to 5V for the ATMega644. These are a good idea because some of the piezo discs in the MAXLAB can easily produce tens of volts. '''R''' is an additional resistor added to reduce the voltage range. '''R''' depends heavily on the particular application, but you might start by trying '''R'''=470kOhms.
 +
 +
<center>[[Image:piezo_simple.jpg]]</center>
 +
 +
One disadvantage is that the ADC cannot measure negative voltages produced by the piezo. The user can change the sign of the voltage produced by the piezo by changing the direction in which the piezo is flexed.
 +
 +
 +
 +
===Better Sensing Circuit===
 +
 +
The circuit must be modified so that the ADC can respond to the user flexing the piezo in both directions. In order to do so, we simply put the piezo in series with a 2.5V voltage source. Now if the piezo is not being flexed, the ADC will read 2.5V. Flexing the piezo in one direction will cause the voltage to increase, while flexing the piezo in the other direction will cause the voltage to decrease.
 +
 +
<center>[[Image:piezo_better.jpg]]</center>
 +
 +
 +
We can implement the voltage source using a pair of resistors and an [http://en.wikipedia.org/wiki/Operational_amplifier operational amplifier] as shown below:
 +
 +
<center>[[Image:piezo_better_2.jpg]]</center>
 +
 +
==Electrodynamic Sensor==
 +
 +
A simple electrodynamic sensor can be constructed out of a permanent magnet and a coil of wire.
 +
 +
<center>[[Image:velocity_simple.jpg]]</center>
 +
 +
Usually either the coil or the magnet is fixed in place. Since the induced voltage '''V''' is proportional to the change in the magnetic field '''B''', the sensor measures the velocity of the coil or magnet (whichever one is moving). '''N''' is the number of turns of wire in the coil, and '''A''' is the area circumscribed by the coil.
==Hall Effect Sensor==
==Hall Effect Sensor==
-
A linear Hall Effect Sensor is an IC that outputs a continuous voltage that varies with the strength of a magnetic field applied to the sensor. We use the [http://ccrma.stanford.edu/courses/250a/docs/datasheets/SS49E.pdf Honeywell SS49E]. This Hall Effect Sensor only requires 3 connections, V_in, Ground and V_out, where V_out varies between Ground and V_in at some given slope specified in mV/Gauss. A Hall switch may have a binary state output that changes when the magnetic field strength crosses some specified threshold.  
+
A linear Hall Effect Sensor is an IC that outputs a continuous voltage that varies with the strength of a magnetic field applied to the sensor. We use the [http://ccrma.stanford.edu/courses/250a/docs/datasheets/SS49E.pdf Honeywell SS49E]. This Hall Effect Sensor only requires 3 connections, V_in, Ground and V_out, where V_out varies between Ground and V_in at some given slope specified in mV/Gauss. A Hall switch may have a binary state output that changes when the magnetic field strength crosses some specified threshold.
 +
 
 +
 
 +
==Reflective Optical Sensor==
 +
 
 +
<center>[[Image:Optical.png]]</center>
 +
 
 +
The reflective optical sensor consists of an infrared LED and a phototransistor that passes an amount of current proportional to the reflected light received. We use two kinds at CCRMA, the Fairchild [http://ccrma.stanford.edu/courses/250a/docs/datasheets/QRB1114.pdf QRB1114] has the letter "E" (Emitter) to label the LED, and the label "S" (Sensor) for the phototransistor. The Optek [http://ccrma.stanford.edu/courses/250a/docs/datasheets/OPB703.pdf OPB704] uses the symbols for an LED and a transistor to label the two sides. One leg of the sensor is connected to +5V, which supplies current, and the voltage drop across the 10k resistor that we measure is proportional to the amount of current.
 +
 
 +
There is a continuous voltage response for objects over a short range of proximity to the sensor. The response is not linear. Linearity can be approximated by the log of the log of the signal.
 +
 
 +
==Quadrature Encoders==
 +
 
 +
 
 +
<center>[[Image:Quadrature.png]]</center>
 +
 
 +
 
 +
The above diagram demonstrates two signals in a quadrature relationship. The most common sensor we use that has this kind of signal is a rotary encoder or shaft encoder. Rotary encoders are normally optical (expensive) or mechanical (cheap). A mechanical encoder works simply by connecting the Phase A and Phase B pins (pins 1 and 3 in the diagram below) to a common pin (pin 2), according to a quadrature pattern. Wired up as in the diagram, pins 1 and 3 will go to ground when when connected to pin 2, and will be high when they are not. Mechanical contacts inside the encoder create the quadrature signals as above. An optical encoder may function similarly using LEDs and phototransistors as in the IR sensor above, with alternating dark/light patterns applied in quadrature.
 +
 
 +
Note that Phase A leads Phase B by 90 degrees when looking from left to right. Looking from right to left the opposite is true. We use quadrature encoders with the external interrupt on a microcontroller. By connecting the Phase A pin to an interrupt, we can generate an interrupt SIGNAL (function call) every time it transitions from low to high. In the interrupt, we can check the state of the Phase B pin. If B is low when A goes high, then we have moved to the right. If B is high when A goes high, then we know we have moved to the left. Shaft encoders are rated with a number of counts or ticks per complete rotation. Note that if we attach both Phase B and Phase A to external interrupts, we can double the resolution.
 +
 
 +
<center>[[Image:Encoder_filter.png]]</center>
 +
 
 +
This filter circuit helps to stabilize the output of the shaft encoder and reduces noise by introducing pull-up resistors and low pass filters with cut-off frequency of ~ 1.6kHz on each of the two output pins.
 +
 
 +
 
 +
===Features===
 +
 
 +
Shaft encoders normally turn infinitely. If we know the number of counts, we can keep track of the absolute position of the shaft. By measuring the time between ticks (or between some number of ticks), we can calculate velocity. Also, using an IR reflective object sensor and some custom printed paper, for example, you can build your own quadrature encoder. There is NO A/D conversion involved in using a shaft encoder!  Shaft encoders are commonly used in automation and robotics conjunction with motors to achieve accurate positioning. They are also ubiquitous on volume knobs in stereo equipment.
 +
 
==Accelerometers==
==Accelerometers==
Line 146: Line 210:
The ADXL50 measures the difference between the two capacitors which is given by:
The ADXL50 measures the difference between the two capacitors which is given by:
-
 
+
<center>
-
<math>\Delta C = C_A - C_B = Cx_0 \left[ \frac{1}{x_0+x} - \frac{1}{x_0-x} \right] = \frac{-2x}{x^2 - {x_0}^2}</math>
+
[[Image:eqn1.png]]
-
 
+
</center>
For small values of displacement ''x'', the above expression reduces to:
For small values of displacement ''x'', the above expression reduces to:
-
 
+
<center>
-
<math>\Delta C \approx \frac{-2}{{x_0}^2}</math>
+
[[Image:eqn2.png]]
-
 
+
</center>
-
 
+
Hence the difference in capacitance is proportional to ''x'', but only for small values of displacement. The ADXL50 uses a negative feedback control loop to make sure that the movement of the mass is kept small so that the above expression remains correct. The figure below shows a block diagram of the entire system.
Hence the difference in capacitance is proportional to ''x'', but only for small values of displacement. The ADXL50 uses a negative feedback control loop to make sure that the movement of the mass is kept small so that the above expression remains correct. The figure below shows a block diagram of the entire system.
Line 159: Line 222:
-
==Piezoelectric Sensors==
 
-
* Notes below are from the lecture notes of the former [http://ccrma.stanford.edu/CCRMA/Courses/252/sensors/node7.html CCRMA Music 252 Course]
+
==No Sensors Are Perfect==
-
The Piezoelectric effect is an effect in which energy is converted between mechanical and electrical forms. It was discovered in the 1880's by the Curie brothers. Specifically, when a pressure (piezo means pressure in Greek) is applied to a polarized crystal, the resulting mechanical deformation results in an electrical charge. Piezoelectric microphones serve as a good example of this phenomenon. Microphones turn an acoustical pressure into a voltage. Alternatively, when an electrical charge is applied to a polarized crystal, the crystal undergoes a mechanical deformation which can in turn create an acoustical pressure. An example of this can be seen in piezoelectric speakers. (These are the cause of those annoying system beeps that are all too common in today's computers).
+
All continuous sensors are subject to:
 +
* noise
 +
* non-linearity
 +
* imperfect calibration (for instance gain differences)
 +
When designing a sensor, reducing the noise typically results in more serious non-linearity and vice versa. The correct sensor to use depends on the application!
-
<center>[[Image:Electret.gif|Internal Structure of an electret]]</center>
+
==Textile-Based Sensors==
 +
Sensors can also be constructed out of special kinds of fabrics.  These fabrics are often used for embedding sensors in textile products.  See ''[http://cnmat.berkeley.edu/system/files/attachments/Nime2008FiberSensingfinal.pdf this paper]'' for more ideas.
-
Electrets are solids which have a permanent electrical polarization. (These are basically the electrical analogs of magnets, which exhibit a permanent magnetic polarization). The figure above shows a diagram of the internal structure of a electret. In general, the alignment of the internal electric dipoles would result in a charge which would be observable on the surface of the solid. In practice, this small charge is quickly dissipated by free charges from the surrounding atmosphere which are attracted by the surface charges. Electrets are commonly used in microphones.
+
==Multiplexer==
-
Permanent polarization as in the case of the electrets is also observed in crystals. In these structures, each cell of the crystal has an electric dipole, and the cells are oriented such that the electric dipoles are aligned. Again, this results in excess surface charge which attracts free charges from the surrounding atmosphere making the crystal electrically neutral. If a sufficient force is applied to the piezoelectric crystal, a deformation will take place. This deformation disrupts the orientation of the electrical dipoles and creates a situation in which the charge is not completely canceled. This results in a temporary excess of surface charge, which subsequently is manifested as a voltage which is developed across the crystal.
+
A multiplexer is not a sensor, but an IC that can be used to connect a single pin ("common") to a number of addressable analog (or digital) signals. We use the 8-channel [http://ccrma.stanford.edu/courses/250a/docs/datasheets/MM74HC4051.pdf 74HC4051] multiplexer.  
-
<center>[[Image:Piezo.gif|A sensor based on the piezoelectric effect]]</center>
 
-
In order to utilize this physical principle to make a sensor to measure force, we must be able to measure the surface charge on the crystal. The figure above shows a common method of using a piezoelectric crystal to make a force sensor. Two metal plates are used to sandwich the crystal making a capacitor. As mentioned previously, an external force cause a deformation of the crystal results in a charge which is a function of the applied force. In its operating region, a greater force will result in more surface charge. This charge results in a voltage ''V=Q<sub>f</sub>/C'', where ''Q<sub>f</sub>'' is the charge resulting from a force ''f'', and ''C'' is the capacitance of the device.
 
-
 
-
In the manner described above, piezoelectric crystals act as transducers which turn force, or mechanical stress into electrical charge which in turn can be converted into a voltage. Alternatively, if one was to apply a voltage to the plates of the system described above, the resultant electric field would cause the internal electric dipoles to re-align which would cause a deformation of the material. An example of this is the fact that piezoelectric transducers find use both as speakers (voltage to mechanical) and microphones (mechanical to electrical).
 
-
 
-
==Multiplexer==
 
-
 
-
A multiplexer is not a sensor, but an IC that can be used to connect a single pin ("common") to a number of addressable analog (or digital) signals. We use the 8-channel [http://ccrma.stanford.edu/courses/250a/docs/datasheets/MM74HC4051.pdf 74HC4051] multiplexer.
 
[[Category:PID]][[Category:PID_2007]]
[[Category:PID]][[Category:PID_2007]]

Current revision as of 13:32, 17 October 2008

This is a brief overview with some practical circuits of some of the sensors we use in Physical Interaction Design for Music at CCRMA. For a great music sensor reference, see SensorWiki.org.

Contents

PushButtons and Switches

Switches are the simplest group of discrete sensors. They act as a valve, opening or closing the flow of electrons through a branch of your circuit.

Image:Button_led.png

Switches can be interfaced directly to a microcontroller's digital input requiring only a pull-up resistor.

Switch nomenclature:

  • SPDT - Single Pole, Double Throw. Has three contacts, signal of interest would normally go in the middle and is connected to one of the two other contact depending on the switch position.
  • DPDT - Double Pole, Double Throw. Has the same structure as the SPST but with a second set of contact so two signal can be switched together.
  • Normally Open - The contacts are connected only while the button is actuated. aka. Momentary Contact
  • Normally Closed - The contacts are connected except while the button is actuated.
  • Toggle - Toggles between closed and open with each actuation

There are many other types of switches, mechanical, electrical (transistors, photo-transistors ...), and combinations of the two (solenoids ...).


Potentiometers

Potentiometers (Pots) are the simplest group of continuous sensors. A potentiometer is a special resistor with a third movable contact, called a wiper. A pot has a fixed resistance from one end to the other as does a normal resistor, but the resistance between the wiper and the ends changes as the wiper is moved (one gets smaller as the other gets larger - the always add up to the fixed resistance between the fixed ends). For rotary pots, the wiper moves as the shaft turns. For linear or slide pots, the wiper moves with the slider.

In the following circuit, the position of the potentiometer wiper adjusts the brightness of the LED. We often make assumptions to simplify circuit analysis. For example, to estimate the current I, we assume here that Vled=0.

Image:Pot_circuits.png

Potentiometer nomenclature:

  • trim pot - A small potentiometer often used for calibrating a circuit. It usually requires a screw driver to turn and is intended to be set and left alone.
  • turns - Some pots cover their range of resistance with only one turn while other can take ten or more turns. The multi-turn pots afford greater precision, but normally cost more and obviously take longer to turn!
  • taper - The "taper" of a pot refers to the curve formed by plotting the rotation (for a rotary pot) or displacement (for a slide pot) on the X-axis and resistance between the pin 1 and the wiper (R1 above) on the Y-axis. A "linear" taper would have a straight line, such that at 180 degrees rotation, the resistance is half of the total resistance. In "Logarithmic" (or "Log" or "Audio") taper pots the resistance changes logarithmically with rotation. These pots are commonly used in analog audio mixers because humans perceve logarithmic changes in loudness roughly linearly.

See the following slider data sheet for information on an audio taper slider pot.

Potentiometer Circuit

A potentiometer is normally interfaced to a microcontroller by digitizing the voltage found across it using an ADC (Analog to digital converter). For example, connect V in the following circuit to an ADC.

Image:Pot.png


Bend Sensor

Image:Bend_sensor.png

The bend or flex sensor (Jameco #150551) has a nominal resistance of 10k ohms. It goes to about 70k ohms when maximally bent. A voltage divider with a resistor R2 of 47k ohms gives a range of 4.12 Volts to 2 Volts.


Force Sensing Resistors


Diagram of a typical force sensing resistor

As their name implies, force sensing resistors use the electrical property of resistance to measure the force (or pressure) applied to a sensor. A force sensing resistor is made up of two parts. The first is a resistive material applied to a film. The second is a set of digitating contacts applied to another film. Figure 5 shows this configuration. The resistive material serves to make an electrical path between the two sets of conductors on the other film. When a force is applied to this sensor, a better connection is made between the contacts, hence the conductivity is increased. Over a wide range of forces, it turns out that the conductivity (the inverse of resistance) is approximately a linear function of force . The figure below shows the resistance of the sensor as a function of force. It is important to note the three regions of operation of the sensor. The first is the abrupt transition which occurs somewhere in the vicinity of 10 grams of force. In this region the resistance changes very rapidly. This behavior is useful when one is designing switches using FSRs. Above this region, the force is approximately proportional to 1/R until a saturation region is reached. When forces reach this magnitude, additional forces do not decrease the resistance substantially.

Resistance as a function of force for a typical force sensing resistor

The figure below shows a plot of conductance versus force for a typical FSR sensor. Notice that the x-axis is now a linear axis, and that above the break-point, conductance is approximately linear with force. It is important to make note of the fact that FSRs are not appropriate for accurate measurements of force due to the fact that parts might exhibit as much as 15% to 25% variation between each other.

Conductance as a function of force for a typical force sensing resistor

FSR Circuit

Image:FSR.png

Photo Resistor

Photo Resistor Circuit

A photoresistor is a resistor whose resistance changes depending on the amount of light shining onto the surface.

Image:Photo.png


Piezoelectric Sensors

The Piezoelectric effect is an effect in which energy is converted between mechanical and electrical forms. It was discovered in the 1880's by the Curie brothers. Specifically, when a pressure (piezo means pressure in Greek) is applied to a polarized crystal, the resulting mechanical deformation results in an electrical charge. Piezoelectric microphones serve as a good example of this phenomenon. Microphones turn an acoustical pressure into a voltage. Alternatively, when an electrical charge is applied to a polarized crystal, the crystal undergoes a mechanical deformation which can in turn create an acoustical pressure. An example of this can be seen in piezoelectric speakers. (These are the cause of those annoying system beeps that are all too common in today's computers).


Internal Structure of an electret

Electrets are solids which have a permanent electrical polarization. (These are basically the electrical analogs of magnets, which exhibit a permanent magnetic polarization). The figure above shows a diagram of the internal structure of a electret. In general, the alignment of the internal electric dipoles would result in a charge which would be observable on the surface of the solid. In practice, this small charge is quickly dissipated by free charges from the surrounding atmosphere which are attracted by the surface charges. Electrets are commonly used in microphones.

Permanent polarization as in the case of the electrets is also observed in crystals. In these structures, each cell of the crystal has an electric dipole, and the cells are oriented such that the electric dipoles are aligned. Again, this results in excess surface charge which attracts free charges from the surrounding atmosphere making the crystal electrically neutral. If a sufficient force is applied to the piezoelectric crystal, a deformation will take place. This deformation disrupts the orientation of the electrical dipoles and creates a situation in which the charge is not completely canceled. This results in a temporary excess of surface charge, which subsequently is manifested as a voltage which is developed across the crystal.

A sensor based on the piezoelectric effect

In order to utilize this physical principle to make a sensor to measure force, we must be able to measure the surface charge on the crystal. The figure above shows a common method of using a piezoelectric crystal to make a force sensor. Two metal plates are used to sandwich the crystal making a capacitor. As mentioned previously, an external force cause a deformation of the crystal results in a charge q which is a function of the applied force. In its operating region, q is proportional to the applied force f.

There has been some confusion on the world wide web about the correct equivalent circuit model for a piezo sensor, so we provide it here. The piezo is modeled as a capacitor with capacitance C in parallel with a current source. Since the current flow is equal to the derivative of the charge, we label the current source as dq/dt. Finally, a resistor Rleak is placed in parallel with the other two elements.

Piezo sensor equivalent circuit model

Typically, the voltage V across the piezo terminals is measured. The transfer function of output voltage as a function of the charge is V(s)/q(s) = sRleak/(1+sRleakC). The resistor Rleak results in a high-pass behavior. This explains why piezos can sound high-passed (or "quacky" in the case of piezo guitar pickups). To minimize the effects of the high pass filter, a voltage follower circuit can be placed in between the piezo and the input to the ADC.

The following image shows a piezo pickup for electric guitar. The piezo is embedded inside a GHOST piezo saddle from Graph Tech, allowing the pickup to be easily installed at the bridge.

GHOST piezo saddle

Similarly, acoustic guitar pickup sensors often consist of a simple piezo strip sandwiched inside the bridge.

Alternatively, if one were to apply a voltage to the plates of the system described above, the resultant electric field would cause the internal electric dipoles to re-align which would cause a deformation of the material. An example of this is the fact that piezoelectric transducers find use both as speakers (voltage to mechanical) and microphones (mechanical to electrical).

Simple Sensing Circuit

This circuit is simple. The diodes ensure that the piezo (drawn in as a capacitor Cpiezo) does not produce voltages too far out of the range acceptable to the analog-to-digital converter (ADC), which is 0V to 5V for the ATMega644. These are a good idea because some of the piezo discs in the MAXLAB can easily produce tens of volts. R is an additional resistor added to reduce the voltage range. R depends heavily on the particular application, but you might start by trying R=470kOhms.

Image:piezo_simple.jpg

One disadvantage is that the ADC cannot measure negative voltages produced by the piezo. The user can change the sign of the voltage produced by the piezo by changing the direction in which the piezo is flexed.


Better Sensing Circuit

The circuit must be modified so that the ADC can respond to the user flexing the piezo in both directions. In order to do so, we simply put the piezo in series with a 2.5V voltage source. Now if the piezo is not being flexed, the ADC will read 2.5V. Flexing the piezo in one direction will cause the voltage to increase, while flexing the piezo in the other direction will cause the voltage to decrease.

Image:piezo_better.jpg


We can implement the voltage source using a pair of resistors and an operational amplifier as shown below:

Image:piezo_better_2.jpg

Electrodynamic Sensor

A simple electrodynamic sensor can be constructed out of a permanent magnet and a coil of wire.

Image:velocity_simple.jpg

Usually either the coil or the magnet is fixed in place. Since the induced voltage V is proportional to the change in the magnetic field B, the sensor measures the velocity of the coil or magnet (whichever one is moving). N is the number of turns of wire in the coil, and A is the area circumscribed by the coil.

Hall Effect Sensor

A linear Hall Effect Sensor is an IC that outputs a continuous voltage that varies with the strength of a magnetic field applied to the sensor. We use the Honeywell SS49E. This Hall Effect Sensor only requires 3 connections, V_in, Ground and V_out, where V_out varies between Ground and V_in at some given slope specified in mV/Gauss. A Hall switch may have a binary state output that changes when the magnetic field strength crosses some specified threshold.


Reflective Optical Sensor

Image:Optical.png

The reflective optical sensor consists of an infrared LED and a phototransistor that passes an amount of current proportional to the reflected light received. We use two kinds at CCRMA, the Fairchild QRB1114 has the letter "E" (Emitter) to label the LED, and the label "S" (Sensor) for the phototransistor. The Optek OPB704 uses the symbols for an LED and a transistor to label the two sides. One leg of the sensor is connected to +5V, which supplies current, and the voltage drop across the 10k resistor that we measure is proportional to the amount of current.

There is a continuous voltage response for objects over a short range of proximity to the sensor. The response is not linear. Linearity can be approximated by the log of the log of the signal.

Quadrature Encoders

Image:Quadrature.png


The above diagram demonstrates two signals in a quadrature relationship. The most common sensor we use that has this kind of signal is a rotary encoder or shaft encoder. Rotary encoders are normally optical (expensive) or mechanical (cheap). A mechanical encoder works simply by connecting the Phase A and Phase B pins (pins 1 and 3 in the diagram below) to a common pin (pin 2), according to a quadrature pattern. Wired up as in the diagram, pins 1 and 3 will go to ground when when connected to pin 2, and will be high when they are not. Mechanical contacts inside the encoder create the quadrature signals as above. An optical encoder may function similarly using LEDs and phototransistors as in the IR sensor above, with alternating dark/light patterns applied in quadrature.

Note that Phase A leads Phase B by 90 degrees when looking from left to right. Looking from right to left the opposite is true. We use quadrature encoders with the external interrupt on a microcontroller. By connecting the Phase A pin to an interrupt, we can generate an interrupt SIGNAL (function call) every time it transitions from low to high. In the interrupt, we can check the state of the Phase B pin. If B is low when A goes high, then we have moved to the right. If B is high when A goes high, then we know we have moved to the left. Shaft encoders are rated with a number of counts or ticks per complete rotation. Note that if we attach both Phase B and Phase A to external interrupts, we can double the resolution.

Image:Encoder_filter.png

This filter circuit helps to stabilize the output of the shaft encoder and reduces noise by introducing pull-up resistors and low pass filters with cut-off frequency of ~ 1.6kHz on each of the two output pins.


Features

Shaft encoders normally turn infinitely. If we know the number of counts, we can keep track of the absolute position of the shaft. By measuring the time between ticks (or between some number of ticks), we can calculate velocity. Also, using an IR reflective object sensor and some custom printed paper, for example, you can build your own quadrature encoder. There is NO A/D conversion involved in using a shaft encoder! Shaft encoders are commonly used in automation and robotics conjunction with motors to achieve accurate positioning. They are also ubiquitous on volume knobs in stereo equipment.


Accelerometers

Image:Accelerometer_mass_spring.gif

The basic physical principle behind many accelerometers is that of a simple mass spring system. Springs (within their linear region) are governed by a physical principle known as Hooke's law. Hooke's law states that a spring will exhibit a restoring force which is proportional to the amount it has been stretched or compressed. Specifically, F=kx, where k is the constant of proportionality between displacement (x) and force (F). The other important physical principle is that of Newton's second law of motion which states that a force operating on a mass which is accelerated will exhibit a force with a magnitude F=ma. The above figure shows a mass connected to a spring. If this system undergoes an acceleration, then by Newton's law, there will be a resultant force equal to ma. This force causes the mass to either compress or expand the spring under the constraint that F=ma=kx. Hence an acceleration a will cause the mass to be displaced by x=ma/k or alternatively, if we observe a displacement of x, we know that the mass has undergone an acceleration of a=kx/m. In this way we have turned the problem of measuring acceleration into one of measuring the displacement of a mass connected to a spring. Note that this system only responds to accelerations along the length of the spring. This is said to be a single axis accelerometer. In order to measure multiple axes of acceleration, this system needs to be duplicated along each of the required axes.

Mass Spring System Used in ADXL50


The Analog Devices ADXL50 is a micro-machined stand-alone accelerometer which consists of a mass spring system as well as a system to measure displacement and the appropriate signal conditioning circuitry (which is the topic of the next section). The mass spring system used in this device is depicted in Figure 9. The mass is a bar of silicon, and the spring system is implemented by the 4 tethers which attach to each corner of the mass. It responds to accelerations that occur in line with the length of the mass. When an acceleration occurs, the mass moves with respect to the anchored ends of the tethers. Roughly speaking, the amount of acceleration is proportional to the amount of displacement of the mass. This is not quite true in this case since the spring system is not an ideal spring as presented earlier. This fact is compensated for by some sophisticated signal conditioning circuitry present in the device.


A simple capacitor


The next problem which needs to be solved is that of measuring the displacement of the bar. The principle upon which this is based is that of the electrical property of capacitance. Capacitors are electrical components which store charge. A simple capacitors is formed by placing two metal plates in parallel with each other as shown in Figure 10. The amount of capacitance that a device such as this would exhibit is exhibit is given by C=k/x0 , where k is a property of the material between the two plates. Using this, if one knew k and could measure capacitance, they would be able to determine x0, the spacing between the plates.

The dual Capacitor system used to measure displacement in the Analog Devices ADXL50 accelerometer

The ADXL50 takes this technique one step further and uses two capacitors configured as in the above figure. If the device is at rest, and the spacing between each of the plates is x0, then each of the capacitors exhibits a capacitance of C=k/x0. If the middle plate is moved by a distance x, then this results in:

<math>C_A = \frac{k}{x_0 + x}</math> <math>C_B = \frac{k}{x_0 - x}</math>


This can then be written as:

<math>C_A = {C}\frac{x_0}{x_0 + x}</math> <math>C_B = {C}\frac{x_0}{x_0 - x}</math>


The ADXL50 measures the difference between the two capacitors which is given by:

Image:eqn1.png

For small values of displacement x, the above expression reduces to:

Image:eqn2.png

Hence the difference in capacitance is proportional to x, but only for small values of displacement. The ADXL50 uses a negative feedback control loop to make sure that the movement of the mass is kept small so that the above expression remains correct. The figure below shows a block diagram of the entire system.

Accelerometer Block Diagram


No Sensors Are Perfect

All continuous sensors are subject to:

  • noise
  • non-linearity
  • imperfect calibration (for instance gain differences)

When designing a sensor, reducing the noise typically results in more serious non-linearity and vice versa. The correct sensor to use depends on the application!

Textile-Based Sensors

Sensors can also be constructed out of special kinds of fabrics. These fabrics are often used for embedding sensors in textile products. See this paper for more ideas.

Multiplexer

A multiplexer is not a sensor, but an IC that can be used to connect a single pin ("common") to a number of addressable analog (or digital) signals. We use the 8-channel 74HC4051 multiplexer.

Personal tools