Long time, no see. I’ve been quite busy, and I had little time to write here. And I’ve spent the last days fighting to get one Voltmeter click to work with an Arduino Uno, as a prerequisite to the next project that will be featured on the blog.

The Voltmeter click board I’m writing about is a mikroBUS™ add-on board for measuring voltage in an external electric circuit. The board can measure DC only, and the advertised measurement range is -24 to 24V.

A very nice piece of hardware, but I have found that the accompanying code example is utterly wrong. If one looks at the code example one sees the following two lines of code:

Well, that 33.3405 value is wrong, it should be 16.67. Also, the measurement range is wrong.

To understand why we have to take an in-depth look at the schematic:

Input stage of voltmeter click board

The input voltage goes through a voltage divider made with R1, R14, R15, and R2. The voltage drop on R2 is applied to the (non-inverting) input of OP1C, while the voltage drop on R15 goes to the input of OP1B.

The voltage drop on R14 is:

$V_{R14}=V_{in}\cdot&space;\frac{R14}{R1+R14+R15+R2}=0.03\cdot&space;V_{in}$

Same goes for R15:

$V_{R15}=V_{in}\cdot&space;\frac{R14}{R1+R14+R15+R2}=0.03\cdot&space;V_{in}$

When Vin is positive we will find the following situation:

Voltmeter click with positive input

With respect to GND, the voltage applied on pin 10 of OP1C is negative, and the output of OP1C is 0V. The voltage applied to pin 5 of OP1B is positive, and the output of OP1B is Vin * 0.03. The output of OP1B and VGND are summed by OP1D, and the output voltage going to the ADC will be:

$V_{ADC}=V_{GND}+0.03\cdot&space;V_{in}$

A quick side note: VGND should have been named VBIAS, as not to be confused with GND. However, in this blog post I will keep the naming convention used in the original schematic.

When Vin is negative we will find the following situation:

Voltmeter click with negative input

With respect to GND, the voltage applied on pin 10 of OP1C is positive wrt GND, and the output of OP1C is -Vin * 0.03. OP1C acts basically as an inverter in this case, as its output is positive if the input voltage applied to the voltmeter click is negative. The voltage applied to pin 5 of OP1B is negative wrt GND, and the output of OP1B is 0. OP1D subtracts  the output of OP1C from VGND, and the output voltage going to the ADC will be:

$V_{ADC}=V_{GND}+0.03\cdot&space;V_{in}$]

We see that, regardless of the polarity of the input signal, we will have the same relation between the input voltage and the voltage that goes to the ADC:

$V_{ADC}=V_{GND}+0.03\cdot&space;V_{in}$

In theory, VGND is 1.024 V as this bias voltage is obtained by dividing the reference voltage Vref = 2.048V via R9 and R10. In practice, we can find some variations due to tolerance of R9 and R10. However, that difference is a unique characteristic of each voltmeter click board and can be measured only once.

One more thing: on a quick look at the MCP609 datasheet we find an absolute rating of Analog Inputs (VIN+, VIN–) as being VSS – 1.0V to VDD + 1.0V. In our case VSS is GND, and VSS can be 3.3V or 5V, depending on the position of the power select jumper on the voltage click.

So, one should not apply a negative voltage of more than 1V on the inputs of OP1C and OP1B. As such, we can determine the maximum voltage that can be applied to the inputs of the voltmeter click without causing permanent damage to the op-amps:

$V_{max}=\frac{1V}{0.03}=33.3V$

So, the actual measurement range of the voltmeter click is much higher than the advertised value. Nice.

## The 33.3405 scaling factor is wrong!

Again, some calculations. We start by taking a look at the ADC converter. This click board uses an MCP3201 12-bit ADC, which reports a ratiometric value. This means that the ADC assumes Vref is 4095 and anything less than Vref will be a ratio between Vref and 4095.

$\frac{ADC&space;resolution}{Reference&space;voltage}=\frac{ADC&space;reading}{ADC&space;input&space;voltage}$

As such,  we can express the input voltage (in mV) as:

$V_{ADC}=ADC_{reading}\tfrac{V_{ref}}{ADC_{resolution}}=ADC_{reading}\tfrac{2048}{4095}$

$V_{ADC}=&space;0.5001\cdot&space;ADC_{reading}$

Or we can simply approximate:

$V_{ADC}=&space;\frac{ADC_{reading}}{2}$

But at the same time we have:

$V_{ADC}=V_{GND}+0.03\cdot&space;V_{in}$

In the particular case of Vin = 0 we will find:

$V_{GND}=\frac{ADC_{offset}}{2}$

$ADC_{offset}=2\cdot&space;V_{GND}$

Then we will have:

$V_{ADC}=&space;\frac{ADC_{reading}}{2}=V_{GND}+0.03\cdot&space;V_{in}=\frac{ADC_{offset}}{2}+0.03\cdot&space;V_{in}$

However, we already know the offset corresponding to VGND, and we can replace it in the above formula:

$\frac{ADC_{reading}}{2}=0.03\cdot&space;V_{in}-\frac{ADC_{offset}}{2}$

And we can simply determine the input voltage:

$0.03\cdot&space;V_{in}=\frac{ADC_{reading}}{2}-\frac{ADC_{offset}}{2}=\frac{ADC_{reading}-ADC_{offset}}{2}$

$V_{in}=\frac{ADC_{reading}-ADC_{offset}}{0.06}=\left&space;(ADC_{reading}-ADC_{offset}\right&space;)\cdot&space;16.67$

1 2
Share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.