Embedded systems are using sensors with increasing frequency. While industrial products have always used them for manufacturing control systems, consumer devices are starting to employ them more often, as well. Sensors are being integrated into consumer products to create better user experiences — ranging from adding accelerometers in mobile phones to adding water vapor sensors in microwaves.
System designers, who previously worked only in the digital domain, are now finding themselves having to interface with analog sensors. A sensor's analog signal needs to be digitized to be used by the system, and the signal path goes through several stages: amplification, filtering and digitization (see Figure 1, below). Once the signal has been digitized, the user can pass it to a control system on the microcontroller or can massage the data and pass it to a host processor via a communication protocol. The sensor data can be utilized as required.
Each stage usually involves a component which must have passives around it to perform properly for the given application.
Every sensor has a different output signal and range. The output signal can be voltage-, current-, resistive-, capacitive- or frequency-based, but few standards exist, and they are only used in specific industrial systems. Even similar sensors from the same manufacturer can have different outputs, and these differences can create problems for systems designers. A designer must select a sensor that meets the requirements for the system, but if the requirements change during the design, a sensor change may also be in order. In addition, a new sensor with a slightly different output would necessitate altering the amplification and filtering stages. Since a majority of sensors output a low-level current or voltage-based signal, this article will assume this type of sensor is being used and that any current-based signal has been adapted into a voltage via a simple resistive network. Note:This article simplifies some concepts and the component selection process for efficiency sake.
The output of a sensor can be as small as several millivolts or as large as several volts. In order for the signal to be properly digitized, it needs to be large enough for the analog-to-digital converter (ADC) to effectively read the signal. In most cases, the sensor signal will need to be amplified. For example, a typical type-K thermocouple outputs 41 µV/°C, which needs to be greatly amplified if the user would like to read 1C granularity. Thus, designers must take ADC resolution into account to ensure that signal is amplified enough to obtain the desired granularity.
The selection of an amplifier is based mainly on the type needed — instrumentation amplifier, differential amplifier, OpAmp or Programmable Gain Array, as well as the amount of gain. The gain of an amplifier is set by a resistive network around the amplifier with feedback. The maximum gain for standard amplifiers is ideally limitless. The gain for a PGA is usually set by a digital signal to the device which alters an internal resistive network. The maximum possible gain for a PGA is more limited than a tradition amplifier, somewhere in the order of 0.5x to several 1,000x, but, in most cases, this range is more than acceptable.
With amplifiers, another key specification needs to be taken into account — offset voltage (VOS). VOS is the amount of voltage a signal that is passed through the amplifier will be altered. For example, if a 500-mV signal is input into an amplifier with unity gain (1x) and a VOS of 10 mV, the resulting output would be 510 mV. If the output range of the sensor is 0-900mV, and the system does not need a very granular reading of the sensor, this offset may be negligible. If the range of the sensor is 450-550 mV, this offset is probably unacceptable. When selecting an amplifier, the smaller the VOS, the more costly it is. Since all amplifiers have an offset, what matters is whether the system can tolerate it. The VOS can also be reduced or eliminated using correlated double sampling.
In all systems, some noise will be imparted on the sensor's signal. Noise arises from a number of sources, including board layout, radios, thermal noise and even the sensor itself. Not only does signal noise cause inaccurate and unstable readings by the ADC, the level of noise has been increased through the amplification stage, which exaggerates the error in the signal. Signal noise can be qualified as low frequency, high frequency or a specific known frequency. Most often, high-frequency noise is the issue that needs to be dealt with.
Noise can be filtered via several methods, including passive analog filters, filter ICs and digital filtering. The most common method, passive filtering, involves creating a passive network of resistors, capacitors and inductors. The issue with passive filters is they need to be designed and are not easily altered. As filter design can be as cumbersome as the order of filter needed — a first-order Chebyshev filter will take much less effort to design compared to an eighth-order Bessel filter — designers should determine the order of the filter needed before selecting the method of filtering to be employed.
Filtering ICs, which allows the designer to digitally program the type of filter needed, exist. These ICs use different types of analog circuitry internally to create the filter and may have offset voltages associated with them. They also allow designers to move the filter process until after quantification with the ADC. Digital filter design can be complex, but many tools exist that allow for the easy design of high-order filters. Digital filtering can be an ideal means of removing noise; however, it often requires a healthy number of CPU cycles which also increase power consumption.
In order to use the sensor's filtered signal, it is necessary to quantify the analog signal into the digital domain using an ADC. Selection of an ADC mainly concerns the system's requirements for sampling speed and resolution. The sampling speed required is related to the sensor's bandwidth or how often the system needs to be updated. Resolution is dependent on the granularity needed to react to the sensor's information.
The system's usage model defines this speed and resolution requirement. For example, a generic gyroscope measures 360 degrees of rotation at 0.67 mV per degree, resulting in an output range of 241 mV. A hobby helicopter might need information from the gyroscope at a granularity of 1 degree, but with a high throughput of 10Ksps to keep the helicopter upright. This requirement would necessitate a 10-bit ADC which would provide 0.35°/bit (note that the signal will still have noise on it and ±1 bit is considered acceptable). Conversely, a digital camera with image stabilization might require a granularity of 0.02 degrees but with a lower throughput of 5Ksps in order to adjust the image sensor as a camera shakes. This requirement would necessitate a 16-bit ADC which would provide 0.005°/bit.
The accuracy of an ADC is rated in terms of integral non-linearity (INL), differential non-linearity (DNL), offset error, gain error and signal-to-noise ratio (SNR). When these terms are combined they offer an understanding of the ADC's total error. Figure 2, page S10, shows each of the errors individually and then combined. For a majority of applications, looking into these ADC specifications is not needed, but a thorough engineer should have an understanding of these values for the ADC being used.
When selecting an ADC, the user has the choice of using an external ADC or a microcontroller with an integrated ADC. External ADCs tend to be higher performance, both in speed and resolution, as well as accuracy specifications. But the majority of sensor application requirements are well-aligned with integrated microcontroller ADCs.
Another option, configurable ADCs, are comprised of programmable logic blocks available within a microcontroller. Integrated digital and analog programmable blocks allow for the dynamic definition of configurable peripherals optimized for a particular sensor application, including: counters, PWMs, UART, SPI, amplifiers, filters, ADCs and DACs. Developers can also implement the amplification and filtering stages, integrating the entire analog signal chain onto a single device (see Figure 3, above).
Configurable ADCs can result in much cleaner designs compared to using passive components. In addition, given that these blocks can also be dynamically reconfigured, developers have the option of reusing these system resources for other functions.
Sensors continue to penetrate a wide range of markets, bringing more control and greater flexibility to developers. Sensors increase reliability through management of the environment (i.e., temperature monitoring), improved performance through feedback mechanisms and enables new types of user interfaces, just to name a few applications. For many of these designs, the integrated ADCs on microcontrollers provide sufficient granularity and accuracy. Developers not familiar with analog design may encounter pitfalls along the analog signal chain between the sensor and the MCU.
Implementing the multiple stages of the analog signal path can appear convoluted, especially to engineers accustomed to designing primarily in the digital domain. However, by breaking down the analog signal path into the various amplification, filtering and ADC stages, digital developers can more easily and accurately capture sensor data for a wide variety of industrial and consumer applications. In addition, readily available ICs, configurable ADCs and filter design tools can greatly simplify sensor design.