Skip to main content

Microcontrollers

Section 7.1 Resistive Sensors

Sensors that output a resistance must first be configured with another resistor in series (\(R_C\)) in order to convert the variable resistance into an analog voltage value, as shown in Figureย 7.1.1. By connecting this resistor in series with the sensor, a voltage divider is created, causing the value of \(V_{analog}\) to take on a value between 0ย V and VCC, depending on the value of the sensor resistance.
A sensor is depicted as a square with the letter R inside. One lead of the sensor is connected to VCC, the other lead is connected in series to a resistor labeled Rc. The other lead of Rc is connected to GND. The node between the sensor and Rc is connected to a signal labeled "V_analog."
Figure 7.1.1. Schematic of how to connect a sensor whose resistance value changes.
With sensors that output variable resistance values, it is important to correctly choose the value of \(R_C\) in order to obtain an appropriate output value. The relationship between output voltage, VCC, and both resistors in Figureย 7.1.1 is defined by (7.1.1).
\begin{equation} V_{analog} = \textrm{VCC} \times \left(\frac{R_C}{R_C+R_{sensor}}\right)\tag{7.1.1} \end{equation}
The output voltage will be maximum (\(V_{max}\)) when the sensor resistance is minimum (\(R_{sensor,min}\)), and it will be minimum (\(V_{min}\)) when the sensor resistance is maximum (\(R_{sensor,max}\)). A value of \(R_C\) must be chosen such that the contrast of the circuit, defined in (7.1.2), is maximized.
\begin{equation} \textrm{contrast} = V_{max} - V_{min}\tag{7.1.2} \end{equation}
The value of \(R_C\) that leads to the greatest contrast can be calculated by first determining the minimum and maximum sensor resistance values (this could be accomplished by reading the datasheet, or empirically by exposing the sensor to the minimum and maximum environmental values). Using calculus, the first derivative of contrast with respect to \(R_C\) can be calculated, set equal to zero, and solved for \(R_C\text{.}\) This is the value of \(R_C\) that leads to the most contrast and is defined in (7.1.3).
\begin{equation} R_{C,best} = \sqrt{(R_{sensor,min})(R_{sensor,max})}\tag{7.1.3} \end{equation}
After determining the best value of \(R_C\text{,}\) it is next imperative to ensure that the power rating of this resistor is sufficient. The power consumed by this resistor is defined by (7.1.4) (refer to [16.21] for a derivation of this equation.)
\begin{equation} P_{RC} = \textrm{VCC}^2 \times \left( \frac{R_C}{(R_{sensor}+R_C)^2}\right)\tag{7.1.4} \end{equation}
This power will be maximized when the sensor resistance is at a minimum value, so that value should be used to determine the maximum power consumption of the resistor \(R_C\text{.}\)
Itโ€™s also important to ensure that the power consumed by the sensor itself will be within the maximum value allowed by the datasheet specifications. The power consumed by the sensor is defined by (7.1.5). This will also be at a maximum when the sensor resistance is lowest. If this value is out of spec, it may be necessary to change the value of \(R_C\) to get it into an allowable range. (This is more important than contrast, so be sure to prioritize power consumption as needed. If the contrast becomes too small, it may be necessary to buy a sensor that is capable of handing a larger power load.)
\begin{equation} P_{sensor} = \textrm{VCC}^2 \times \left( \frac{R_{sensor}}{(R_{sensor}+R_C)^2}\right)\tag{7.1.5} \end{equation}