- 18.1 Energy
- 18.2 Network Connectivity
- 18.3 Sensors and Actuators
- 18.4 Resources
- 18.5 Life Cycle
- 18.6 Summary
- 18.7 For Further Reading
- 18.8 Discussion Questions
18.3 Sensors and Actuators
A sensor is a device that detects the physical characteristics of its environment and translates those characteristics into an electronic representation. A mobile device gathers environmental data either to guide its own operation (such as the altimeter in a drone), or to report that data back to a user (such as the magnetic compass in your smartphone).
A transducer senses external electronic impulses and converts them into a more usable internal form. In this section. we will use the term “sensor” to encompass transducers as well, and assume the electronic representation is digital.
A sensor hub is a coprocessor that helps integrate data from different sensors and process it. A sensor hub can help offload these jobs from a product’s main CPU, thereby saving battery consumption and improving performance.
Inside the mobile system, software will abstract some characteristics of the environment. This abstraction may map directly to a sensor, such as with measurement of temperature or pressure, or it may integrate the input of several sensors, such as pedestrians identified in a self-driving automobile controller.
An actuator is the reverse of a sensor: It takes a digital representation as input and causes some action in the environment. The lane keep assist feature in an automobile utilizes actuators, as does an audio alert from your smartphone.
The Architect’s Concerns
An architect has several concerns with respect to sensors:
How to create an accurate representation of the environment based on the sensor inputs.
How the system should respond to that representation of the environment.
Security and privacy of the sensor data and actuator commands.
Degraded operation. If sensors fail or become unreadable, the system should enter a degraded mode. For example, if GPS readings are not available in tunnels, the system can use dead reckoning techniques to estimate location.
The representation of the environment that is created and acted upon by a system is domain specific, as is the appropriate approach to degraded operation. We discussed security and privacy in detail in Chapter 8, but here we will focus on only the first concern: creating an accurate representation of the environment based on the data returned by the sensors. This is performed using the sensor stack—a confederation of devices and software drivers that help turn raw data into interpreted information about the environment.
Different platforms and domains tend to have their own sensor stacks, and sensor stacks often come with their own frameworks to help deal with the devices more easily. Over time, sensors are likely to encompass more and more functionality; in turn, the functions of a particular stack will change over time. Here, we enumerate some of the functions that must be achieved in the stack regardless of where a particular decomposition may have placed them:
Reading raw data. The lowest level of the stack is a software driver to read the raw data. The driver reads the sensor either directly or, in the case where the sensor is a portion of a sensor hub, through the hub. The driver gets a reading from the sensor periodically. The period frequency is a parameter that will influence both the processor load from reading and processing the sensor and the accuracy of the created representation.
Smoothing data. Raw data usually has a great deal of noise or variation. Voltage variations, dirt or grime on a sensor, and a myriad of other causes can make two successive readings of a sensor differ. Smoothing is a process that uses a series of measurements over time to produce an estimate that tends to be more accurate than single readings. Calculating a moving average and using a Kalman filter are two of the many techniques for smoothing data.
Converting data. Sensors can report data in many formats—from voltage readings in millivolts to altitude above sea level in feet to temperature in degrees Celsius. It is possible, however, that two different sensors measuring the same phenomenon might report their data in different formats. The converter is responsible for converting readings from whatever form is reported by the sensor into a common form meaningful to the application. As you might imagine, this function may need to deal with a wide variety of sensors.
Sensor fusion. Sensor fusion combines data from multiple sensors to build a more accurate or more complete or more dependable representation of the environment than would be possible from any individual sensor. For example, how does an automobile recognize pedestrians in its path or likely to be in its path by the time it gets there, day or night, in all kinds of weather? No single sensor can accomplish this feat. Instead, the automobile must intelligently combine inputs from sensors such as thermal imagers, radar, lidar, and cameras.