Sensors

From CCRMA Wiki
Revision as of 19:33, 24 June 2007 by Gurevich (Talk | contribs)

Jump to: navigation, search

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.

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.

Pot circuits.png

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:

  • 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.

Reflective Optical Sensor

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

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.

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.

Bend Sensor

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.