So much for theory and design. Here’s a built-up version of the voltmeter:
It was built as add-on for the RF Node Watcher, here’s the side view of this sandwich:
Everything was built with through-hole parts, the LM324 and LT1413 op-amp chips (quad and dual, respectively) were mounted on the bottom, to provide easy access to all their pins from the top and allow simple experimentation & soldering. The ST232C chip was mounted in a free spot, with the 4x 0.1µF caps needed to make it generate about ±9V. Here’s the corresponding circuit:
Some resistors differ (as built, it’ll handle ±15V), but it shows the line of thought which led to it:
- U2B was built first, as buffer for the ADC input (PA3)
- R9 limits the current into the ADC pin when the op-amp’s output exceeds 3.3V
- U2A was added to create the offset reference voltage
- then the LT1413’s U1A op-amp was added with dual supplies as improved input stage
This also adds some amplification to the op-amp. It is now no
longer a voltage follower, because we’re not feeding all the output back to the V-
pin but a slightly reduced level derived from it. As a result, the op-amp needs
to generate a somewhat higher output swing to get V-
to match V+
.
As with software, once you have a working setup, you can start to optimise - either by improving the specs, or by reducing the parts count. In this case, that U2B buffer can go with little effect on the ADC performance, so we can drop the LM324 and use the 2nd LT1413 for a 3.0V reference:
Several changes are worth pointing out (and a minor tweak, R6 should be 20KΩ, not 22KΩ):
- we can switch to +5 and -5V volt as supplies, no need to generate +8V anymore
- this means the ST232C could be replaced by a smaller and cheaper TC7660S
- the input is now 10 MΩ + 1 MΩ, which are more common resistor values
- with this 11:1 divider, the input range now includes 24V, which can be useful
- the reference voltage using in this second iteration is 3.0V
- all resistors have been selected to get very close to the ADC’s full range
- no need for an LM324 anymore, leaving just the LT1413 and negative supply chips
For the -5V supply, we can use this very simple circuit, based on a TC7660S in an 8-pin DIP:
But hey, why stop there? That reference voltage in this second iteration is 3.0V - couldn’t we dimension everything so that 3.3V itself can be used as reference? Sure enough, we can:
The ±2.27V input variation that comes out of the 11:1 input voltage divider ends up as ±3.11V on the output pin of the op-amp. This happens to be exactly right for a 2:1 divider tied directly to the +3.3V supply. The result varies from 0.1V to 3.2V, a perfect match for the ADC’s input range!
So there you have it: this implements a voltmeter not unlike the portable multimeters we use to measure voltages and more with (although our circuit only has a single ±25V range), with a very decent high 11 MΩ input resistance. It’s also quite robust against over-voltage.
With 1% accurate resistor values and a little calibration check, this single op-amp circuit is all we need to make the ADC of a µC usable for a much wider voltage range. The unused op-amp in the LT1413 could then be used to build an identical second channel, for example.
These designs have only addressed “static” DC behaviour so far. There is a lot more to go into, such as how to measure A/C voltages, how to measure current, and exploring the behaviour of this front-end at various frequencies. But that will have to wait for another time…