Implementation of Sensors

Introduction

As we live in a world where technology evolves by every minute, lies these small magic innovations that silently observe and inform devices about the physical world. It’s ironic how such small innovations work with huge amounts of data, well that’s sensors for you.

IoT sensors: turning the ordinary into the extraordinary

Picture yourself at a busy intersection, waiting for the traffic lights to change green. Little do you know, sensors embedded in the pavement detect your presence and signal the light to switch, ensuring a seamless flow of vehicles and pedestrians. These everyday examples show the vial role of sensors in today’s modern world.

Now, these sensors are responsible for detecting your presence, and operating behind the scenes. But how do these sensors function? What goes into their implementation? Keep reading to find out.

Implementation of Sensors

Warning Embedded terminologies ahead ⚠️

Implementation of Sensors

System Design

At a product level, Sensors are only a part of a complete system.

In the hardware, sensors are connected to a processing unit [could be a Microcontroller or a Microprocessor]. While the physical parameter measurement is the face of the product, data processing and control is the brain of it.

Powering the sensor

The hardware should be designed to deliver optimal voltage and current supply to the sensor to ensure its proper functioning.

Power them right and sensors take care of sensing!

Interfaces to the sensor

Choosing the interface to the sensor is a system design level question. The type of sensor and the system requirements will determine the best way of communication between the sensor and other system components.

Good news is sensors come with support for various different interfaces [if not in the same package at least as component variants]

What are the common interfaces used to communicate with a sensor?

The following are a few typical interfaces used by the sensors to interact with the rest of the system:

1. Analog interface: In an analog interface, a sensor translates the measured value into an analog voltage and outputs it through an analog pin. The CPU then measures the voltage level on the analog pin using an Analog to Digital Converter [ADC] and uses formulaic conversion to calculate the sensed value.

In this kind of a design the resolution of the ADC [the smallest voltage level it can convert] can limit the accuracy of the system.

Current sensors are a good example of the use of Analog interface. These sensors typically use a RC circuit and Op-Amp to convert the current to be measured into an analog voltage. They are extensively used in electric vehicle motor controllers.

2. Serial interface: A serial interface allows the sensors to communicate the measured values to the CPU using a communication protocol. Some commonly used serial interfaces are UART, SPI, I2C and sometimes even a Singlewire interface.

This kind of interface allows two way communication with the sensor and facilitates configuration & control of the sensor operation.

Accelerometers and Gyroscope sensors used in smartphones typically use an SPI or I2C interface.

3. Pulse-based interface: Such interfaces send out a square wave pulse. There are two ways in which a Pulse can be used to communicate the sensed value.

The number of EDGEs in the pulse train can be used to communicate a COUNT. HALL sensors used in motors for example communicate the no of rotations of the motor as a count of edges.

The WIDTH of the pulse can be used to communicate a SCALAR value. Ultrasonic sensors for example use the pulse width to communicate the distance of an object

The interfaces listed above are what we engineers call on-board interfaces. They are intended to be used to make connections on printed circuit boards and cannot be run for long distance. If you wish to distance the sensor and the processing unit then use transceivers to convert on-board interfaces to long distance ones. RS485, CAN, Ethernet etc. are common examples for long distance interfaces.

Ultimately, the choice of communication method depends on the specific needs and requirements of the system in which the sensor is being used.

Driver for the sensor

The system intelligence around using the sensor is built in software.

The role of the software is to Connect, Calibrate, Configure and Communicate with the sensor. We just explored the “Connect” in the interfaces section. Let us break down the others to understand them better.

Calibration of a sensor

Text book definition of Calibration is, comparison of measured values to a reference standard of known accuracy [or the process of comparing the measurement readings of a sensor to a reference input and adjusting the sensor’s output].

Depending on the wear and tear on the sensor in usage, calibration could be a one time or periodic activity.

1. One Time
Some sensors are calibrated during their manufacturing by the supplier. This is part of their production testing. And the calibrated values are made available in memory or documentation.

Some other sensors are calibrated upon first time power on in the target hardware. This will be done by the software and the values saved in a flash for example.

2. Periodic
Sensors can degrade or reduce in accuracy during usage. So they have to calibrated, say at every power on or periodically as a part of the system maintenance.

For example, Flow meters used to measure the volume of water flowing through them use a rotational movement to operate. This mechanical movement is subject to wear and tear which reduces the accuracy of the output. So it will do well to re-calibrate this sensor with a known volume of water periodically to ensure the system works consistently.

Monitoring the calibration results and adding correction factors to sensor values can help with problem-solving, spotting patterns, proving compliance with rules or standards and maintaining a consistent product.

Reading the Sensor Data

The processing unit uses the communication interface to read the measured physical parameter from the sensor. The logic behind reading the data is typically either triggered or polled. Confused? let me explain that in a moment.

1. Triggered

The sensor can notify/interrupt the processing unit once the measured data is ready and then the processor can read the data out through the communication interface.

2. Polled
The CPU can periodically go and read the measured data from the sensor. The periodicity is a function of the sensor latency and the the system requirement.

Processing the Sensor Data

The raw sensor data might not be highly usable directly. The sensor could pick spikes and momentary volatility in the sensed environment. So the raw data is seldom steady or smooth.

Let us refer to this volatility as Noise as is the practice in engineering.

The CPU software collects the sensor data and does some math processing on it to reduce or eliminate the noise. This could be as simple as IGNORING the spike – to setting a THRESHOLD limit or AVERAGING – to much more complicated STATISTICAL models.

Consider this practical example. The Throttle in your E-Bikes use a analog sensor. Say the user drove the vehicle over a Speed breaker and the throttle shook, the sensor will pick a spike at this point. Reacting to this spike and instantly accelerating/decelerating the E-Bike might cause an imbalance resulting in an accident. So the software will ensure the change in Throttle input is stable before reacting to it.

Control Logic

This is the last leg of the software implementation.

The whole purpose of the sensor implementation is to meet a larger product requirement. Once the sensor data is processed and available the system can ACT on it. Which could be any of the below based on the product,

  • Actuate control devices [LED/Lights/Doors etc.]
  • Communicate the value to an IOT Gateway
  • Show the value on the product display
  • Send the data to a CLOUD server
  • Send a notification to the user
  • Log the data in local memory
  • Trigger an Alarm

Installation of the Sensor

After the product design, it is also important to take care that the sensor is installed properly.

The front face of the sensor, sometimes referred to as the ANTENNA, should be mounted in the correct location and orientation to measure the desired parameters accurately. This of course can vary according to the type of sensor, the parameter being measured, and the application.

Here's a list of core features that can be built around Sensors and CLOUD connectivity

Conclusion

Each aspect we’ve uncovered is a vital thread in the tapestry of building intelligent systems. From the foundational elements of the system design to the meticulous calibration every step along the way shapes the ultimate performance and reliability of our devices.

By mastering these intricacies, we not only ensure the efficiency and effectiveness of our sensor-equipped devices but also open doors to endless possibilities for innovation and improvement.

Need a fool proof sensor implementation for your product? Take the next step now!