#### Follow our illustrated blog on Embedded Software Architecture

How to build a hybrid solar/wind energy harvester?

ADC, 10.0 out of 10 based on 1 rating
VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

In order to (attempt to) control things, we need to find out what is going on, we need to measure and quantize: Sensors are the senses of electronics. Without senses, we are deaf and blind. Most micro-controllers we find today, incorporate an Analog-to-Digital-Converter (ADC) peripheral. This ADC enables us to link electronic sensors, which output a voltage, to the processing and logic capabilities of software. ## Voltage range

The sensor voltage going to the ADC input pin, must be between certain thresholds usually determined by the working voltage of the controller or a so-called reference voltage which is provided to the controller. Depending on the controller, this could be 0 to 5V or 0 to 3.3V, etc… The pins can sometimes be defined as working for up to 3.3V (you can measure up to 3.3V) but ‘tolerant’ for up to 5V (still only measuring up to 3.3V).

## Resolution

This voltage is then quantified and expressed in a number of bits. The number of bits in the ADC components (combined with the accuracy of the sensor) determines the ‘resolution’ (or sensitivity, if you wish) of the measurement.

The end result is a number, and with numbers we can calculate, and we can give meaning to them. Important to note however, is that a linear change in the measured voltage, does not necessarily imply a linear change in whatever we are measuring (in other words, this depends on the kind of sensor we are using).

For example, a temperature sensor that outputs 1V at 10°C, does not necessarily give us 2V at 20°C. It could be 1.5V, and we would need to investigate the sensor manufacturers lookup table (in the data-sheet) to see that 1.5V corresponds to 20°C (beware that we don’t know whether this temperature sensor is correctly calibrated yet ;-)).

If the ADC pin of a controller can measure voltages between 0 and 3.3V, and has a resolution of 10 bits (2^10 == 1024 values can be expressed), the resolution is 0.00322V or 3.22mV per bit.

## Sampling rate

Next, we need to take into account the sampling rate at which the measurements are taken. The analog signal is continuous in time, but is quantified at (regular) intervals and converted in discrete digital values. We can take a single snapshot and request a single converted value, or we can request ADC conversions in an infinite cycle, but the latter still produces a stream of snapshots. The sampling rate (the number of samples per second) must thus be high enough to capture all relevant changes in the input signal because by just looking at the output, there is no way of knowing what the input was doing between one sampling instant and the next.1

So, to summarize, we need to make sure that

• the sensor output always remains in the safe input levels for the ADC input (pin) of the controller
• the sample rate is high enough to detect all relevant changes in the sensor signal
• we understand what we “sense” so we can correctly link the bit value to the measured entity.

## What can we measure?

There are an incredible amount of different sensors. Take a look at the sparkfun website to get an idea of the possibilities. We find sensors for acceleration, current, pressure, carbon monoxide detection, light intensity, position, temperature, force, gas, radioactivity, etc…

## Want to know more?

If you want to have some more information about how to divide, multiply or shift voltages into the right range for the ADC, take a look here.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast) About rtos.be

rtos.be is a joined initiative from Gert Boddaert and Pieter Beyens.