## Quantizer: Slice Up & Measure 20V on an Arduino

Play Video

Have you tried measuring a voltage signal beyond 5V with an Arduino or any other electronics? If you have, then I’m sure you’re well aware of popping noises and magic smoke going everywhere! One example of an electronic device that uses 5V is the Arduino Uno which means it is unable to measure anything above 5V (or under 0V) with its 10-bit analog-to-digital convert (ADC).

What’s a solution to this problem then? The most common method to measure large voltage swings above 5V with the Arduino is using a voltage divider. However, using a voltage divider means you no longer measure the full-scale of the original signal and you effectively lose information while also increasing the quantization noise. For example, the Arduino Uno has a 10-bit ADC that can read voltages from 0 to 5V which means each ADC step size is approximately 5mV. If we measured the entire 20V with the same 10-bit Arduino Uno step size (i.e., approximately 5mV), there would be total of 4096 steps (whereas the 5V would have 1024 steps). If we reduced the 20V to 5V using a voltage divider, we would lose total of 3072 steps! That’s 3/4 of ADC steps lost!

So, how do we keep the same number of steps for measuring the full 20V signal without using a voltage divider? I present you, the Quantizer! The Quantizer takes a large signal and slices it up into multiple smaller signals that ranges from 0 to 5V that our Arduino can handle, as shown in the below figure where we use an 18V input signal as an example. This way, the Arduino can measure the multiple sliced up signals and add them together digitally to reconstruct the full 20V signal.

The concept behind the Quantizer involves two main requirements. First, the voltage going into the Arduino ADCs must be limited to 0 to 5V using a limiter block. Second, voltage offsets are needed (specifically, 5V offsets) to allow different sections of the 18V signal to be measured. Pretty neat concept, right? Also, links are provided down below where the idea for the Quantizer came from. Now, theory is nice and all but how does one actually implement the Quantizer with circuit components? One implementation design is to use differential rail-to-rail op-amp circuit where it achieves the two requirements we mentioned previously. The rail-to-rail feature allows us to control the minimum and maximum output voltage of the op-amp going into the Arduino ADCs (i.e., first requirement of the Quantizer). The differential op-amp configuration can be used to set the desired voltage offset as shown in the below figure with different resistor values to meet our second requirement of the Quantizer. Below provides the equations used to design the circuit implementation for the Quantizer. The first equation provides the general equation that characterizes the input to output voltage signals and the second equation provides the equation used for setting the desired voltage offset values. We see that the ratio between R1 and R2 resistors set how much voltage offset is provided to the input signal. This is why the ratio of these two resistors increases as we go up vertically in the Quantizer circuit to create larger offset voltages for higher input voltage slices. This post wouldn’t be complete without some simulation results so below figure provides the circuit implemented on LTspice. Since the op-amp chosen for this concept demo wasn’t available on LTspice, a similar rail-to-rail component was chosen with the same ratio resistor values as shown in the previous figure.   There are few but important issues that the Quantizer has including but not limited to offset and attenuation issues as well as ADC that may be muxing too fast. The details are provided in the video (very first image link on this post) so please check out the details if you’re interested. 🙂