Adding Sensors to the SI430 Analog Inputs


Physical phenomena such as temperature, force, pressure, position or ambient light level are of often of on-going interest. Channel 8, combined with the SI430 interface, can be used to provide immediate access to these variables over a LAN or the Internet. Inexpensive sensors are available to detect and measure the variable of interest, and these can be easily connected to the SI430 or any A/D converter that will accept 0 to +5 Vdc. Many of these sensors change resistance with respect to some physical variable. Resistive sensors can be interfaced to the SI430 analog input by using the classic resistance voltage-divider method. Other sensors provide a high-level Vdc output suitable for direct input to the SI430. Both types will be discussed.

The SI430 serial interface has 8 analog input channels that can measure 0 to +5 Vdc with 10 bits of resolution. To detect real-world phenomona, a sensor must be connected so that a signal is received at the SI430 input that is between 0 and +5 Vdc, and reflects the output of the sensor. This project describes how to interface resistive-type sensors to the SI430 for use with Channel 8.

Resistive Sensors and Voltage Dividers

The SI430 accepts analog inputs in Vdc. Sensors that change resistance, therefore, must be connected in a circuit so that the voltage applied to the SI430 changes when the sensor resistance changes. This is easily done with just one additional component: a simple resistor.

The half-bridge circuit allows a change in resistance to create a change in voltage, as shown below.

Here is the equation for a half-bridge circuit: Vout = (+5 Vdc * R2)/(R1 + R2).

To take a simple example, for R1 = R2 = 1000 Ohms, Vout = (5 * 1000)/(1000 + 1000) = 2.5 Vdc. This makes perfect sense because if there is a 5 Vdc drop across both resistors to ground, and the resistors are of equal value, then the point at which the resistors join in the half-bridge must be halfway in potential between +5 V and 0 Vdc (Gnd).

To take another example, if R1 = 1000 Ohms and R2 = 4000 Ohms, Vout = (5 * 4000)/(1000 + 4000) = 4.0 Vdc. As before, 20% of the total voltage drop is over the 1K resistance and 80% over the 4K resistance.

So if you had a sensor that varied in resistance from 1K to 4K, you could wire it as R2 in a half-bridge circuit (where R1 is 1K) and expect that the voltage input to the SI430 would range between 2.5 and 4 Vdc, depending on the resistance of the sensor.

Interfacing a Potentiometer to Measure Position

One way of looking at a potentiometer is that it is a continuously variable voltage divider. When wired as shown below, it is its own half-bridge circuit with the wiper of the potentiometer providing an output voltage that is continuously variable between 0 and +5 vdc.

Potentiometers can come in all sorts of styles, but the most familiar is the simple volume control used on older radios and stereo equipment (See photo below). This sort of potentiometer can be used to convert rotary angle or position into a voltage output that can be sensed by the SI430. The pot typically has 270 degrees of rotation on its shaft, which can be connected to a rotating object to sense angular position.

Another style of potentiometer position sensor is a slider pot, as shown below. The wiper moves in a straight line, so this style potentiometer can be used to sense linear displacement and position.

For any type of potentiometer connected to the SI430 +5 Vdc supply, its full travel will result in a change of voltage from 0 to +5 Vdc allowing the greatest resolution for the SI430 analog inputs. One consideration when selecting a potentiometer type sensor is its nominal resistance. Because the pot is wired across the full +5 V supply, be sure that its nominal overall resistance is at least 10K so that only a few mA of current passes through each sensor connected. Remember, if you connect 8 sensors, the load on the power supply is increased 8 times over just a single sensor. But a 10K nominal resistance is usually sufficient to avoid problems.

Sensing Light Level With a Photocell

A photocell is a device that changes in resistance with ambient light level. You see these in night lights and other similar products. A typical photocell will have a resistance of 3K Ohms in bright light, and 165K Ohms, or more, in full darkness. Photocells vary quite a bit so if you have one the best thing to do is measure its actual resistance in darkness and bright light with a multimeter. A typical photocell is shown below.

Once you know its resistance change, a photocell can be wired into a half-bridge configuration using a fixed resistance, as shown below.

The value of the fixed resistance, Rfixed, must be calculated to provide the greatest possible output voltage change over the changes in resistance for the photocell. This is an iterative process, and putting the voltage divider equation into a spreadsheet and solving for various light levels and values of Rfixed will eventuially result in an optimal value.

For example, with a value of 20K Ohms for Rfixed the circuit will produce a voltage output of 4.29 Vdc when the photocell is in bright light and an output of 0.54 Vdc when the photocell is in the dark. This is a swing of 3.75 Vdc and will provide sufficient sensitivity for the SI430 to detect even small changes in ambient light levels. Once you get the circuit working, simply record the voltage readings under various lighting condtions. There is no quantitative calibration, but the readings can be surprisingly useful.

Interfacing Thermistors to Sense Temperature

Another physical variable of interest is temperature. A thermistor is a device that changes resistance with ambient temperature. The good news is that thermistors are very sensitive to small temperature changes and they are inexpensive. The bad news is that the resistance of a thermistor is not linear with temperature. Even so, wiring a thermistor into a half-bridge with a fixed resistor is a simple way to sense small ambient temperature changes, as shown below.

Once again, a spreadsheet is a good way to determine the optimal value of Rfixed in the thermistor half-bridge. For the example thermistor curve shown above, a value of 5K Ohms for Rfixed produces 2.353 V at 0 Deg C and 4.295 Vdc at 50 deg C. A 5K fixed resistance will keep the current through the thermistor to just a few mA; thermistors can self-heat and this can cause measurement errors. In this case, with a voltage swing of 1.95 Vdc from 0 to 50 C allows the SI430 to detect temperature changes less than 0.2 deg C.

Determining the actual temperature is a more complicated issue. As can be seen from the voltage output graph (generated in a spreadsheet), the signal is not linear with temperature.

One way to determine temperature from voltage would be to fit a second or third order equation to the curve. The coefficients of the curve would be applied to the incoming voltage data. The thermistor has an accuracy of 1 deg C, so a curve could probably be devised to achieve a fit close enough to support that level of precision. A second method, perhaps more straightforward to implement, is to divide the curve into a series of segments and do a linear interpolation between the known points. In either case, Perl could do the necessary math after receiving the voltage reading from the SI430.

There are a number of other temperature sensors available, but these are generally not suitable for interface directly to the SI430. A thermocouple produces a very small voltage signal, just a few mV over hundreds of degrees, and would need amplification. Semiconductor sensors are generally built around the voltage drop across a diode, and this is typically just a few mV. RTD sensors change resistance linearly with temperature, but the resistance change is fairly small; just a couple hundred Ohms over several hundred degrees. Thermistors, with all of their complications, are probably the best combination of accuracy, sensitivity and low cost for use with the SI430.

Using Resistive Force Sensors

An inexpensive force sensor is available from CUI Stack, Inc that changes resistance with applied force. It looks like a button and has two terminals, as shown below.

This device may be wired in a half-bridge, and a value of 5K Ohms for Rfixed will produce a voltage of 0.23 Vdc with zero force and 1.67 Vdc with a force of 500 grams applied to the button. The output is highly non-linear, so a lot of computations and curve-fitting would be required to produce an actual force measurement. The device is probably not very repeatable, so any effort spent in mathmatically characterizing its output as a function of applied force might ultimately be misspent. But it can be used to sense a force limit, given a reasonable tolerance, and could be used to detect, say, an over weight condition or something similar.

By itself, the SI430 is insufficient for use with more transditional force sensors such as strain gages or load cells. These devices are highly linear and much more precise (as well as much more expensive). But the output of the typical load cell is just 10 mV over its entire range when powered by 5 Vdc and this requires amplification. Another idea to measure weight would be to make a spring scale and measure its displacement with a potentiometer as a function of weight.

Interfacing Pressure Sensors

The sensors mentioned so far, photocells, thermistors, pots and the force sensor are relatively inexpensive: from $2 to $7 each. The measurement of pressure requires a more sophisticated mechanical assembly, so even a low cost pressure sensor sells for about $50. The best type to get is one that accepts the +5 Vdc power from the SI430 and provides an output that is linearly proportional to pressure on the order of 3 or 4 Vdc at full scale. Digikey carries the Ares line of low pressure sensors that have full scale ranges of 5 In H2O up to 1 psig. These have hose barb ports and accept +5 Vdc power. They have errors of 0.25% to 1%, and provide a 0.5 V to 4.5 V output signal over their pressure range. These can be wired to the +5 Vdc supply of the SI430 and the output connected directly to one of the analog input channels. A typical Ares sensor is shown below.

There are similar pressure sensors that have low level outputs of 100 mV or so at full scale. These would not be suitable for direct connection to the SI430 without amplification. Always keep in mind that the resolution of the SI430 is 1024 counts over +5 V of signal input. When the signal is limited by the sensor to just a few millivolts, the SI430 will not have enough resolution to give a good reading.

Going Further

There are other sensors that change resistance over some physical variable, and these can be interfaced to the SI430 with the simple half-bridge circuit. Sensors that change resistance by flexing or bending are available, for example, and this might make an interesting project. You might also try designing an amplifier for low-level signals so that your SI430 can interface with strain gages and thermocouples.