A little measurement interface for the NXT (and pbLua ;-)
- 17bit resolution A/D interface (MCP3421)
- excellent accuracy (if calibrated)
- galvanic isolation
- fully NXT powered
- fully pbLua powered (what else? ;-)
- 4 interfaces per NXT (or more if you manage to persuade Microchip selling you MCP3421s with addr. >0...)
- horrible efficiency regarding power supply (due to stinky, little off the shelf DC/DC converter)
After having a lot of fun (and time saved) with Messoefchen, I needed
a more flexible way of measuring voltages and currents at once.
Messoefchen, the predecessor (or cheap alternative) to Messofen, was great for measuring non-isolated regulators.
But only if you can manage to chain it into the in- and output grounds. Usually, this can only be done with stand-alone,
In a real layout, you won't be able to cut ground planes...
With its galvanic isolation, Messofen is able to perform high-side current measurements (*1*), while another unit can
measure a voltage with respect to ground of the circuit...
Although Messofen comes with two hardware presets (MCP3421 gain=1)
it's adjustable via "hardware plugs" (external resistors) and "software" (MCP3421 contains a 1..8 gain stage).
Additionally, the pbLua part provides some flexible routines for calibration and customizations.
- 0 -43.00 Vdc @ 17bit for direct voltage measurements
- 0 - 2.24 Vdc @ 17bit for shunt current measurements (or NiMH/NiCd measurements ;-)
(*1*) A NOTE ON SAFETY: Never ever must this device be connected to AC mains,
any equipment containing mains power supply or a voltage >42DC!
...and a little test-layout
- DC/DC converter (5V/5V):
- inductors L1 and L2: Murata, Chip Coil LQH3N, 10µ
- cinch/RCA, model "CBP-5", like this
- German readers: Gibts auch alles bei Dätwyler, äh - Reichelt ;-)
One important remark first:
Messofen's main (and only) purpose is measuring static (aka.: slow changing, AC and ripple free) DC values. All measurands are
captured as average values.
As presented here, the cut-off frequencies are ~30Hz for the high range (1M2||60k,100n) and ~310Hz for the low range (5k6||60k,100n).
For lower frequencies (recommended!), C13 should be increased. But take care: Much higher values may increase Messofen's influence on the DUT!
This circuit was built around a MCP3421, a tiny (SOT23-6)
delta-sigma 18 bit, I2C A/D converter with internal 0.05% 2.048V reference.
And it's inexpensive too...
Depending on the selected sampling rate, the MCP can operate in 12, 14, 16 or 18 bit mode (240SPS..3.75SPS), it contains an internal gain
amplifier (1x, 2x, 4x, 8x), continuous as well as one-shot conversion modes and a lot more...
Initially, the circuit contained a much better analog frontend, with a much higher input impedance, offset and
temperature compensation, but this was discarded in favor of a "simple" (...) software calibration.
Although this wastes some time (not that dramatic, you need to write, or at least change, custom code
for usage anyway), it keeps the circuit "simple" (well ;-) and no special or selected components are required.
As mentioned before, the circuit contains a galvanic isolation which...
- 1) ... makes high-side (current) measurements possible
- 2) ... reduces annoying (ground) loop effects
- 3) ... introduces my new IthreeC I2C-isolator ;-)
The RCA jack isn't he best solution, but at least, it's comman and cheap.
NOTE: Beware of high-side measurements and metal RCA jacks!
And once again:
(*1*) A SECOND NOTE ON SAFETY: Never ever must this device be connected to AC mains,
any equipment containing mains power supply or a voltage >42DC!
Minimal Functional Description
The noisy voltage supply, coming directly from the NXT (upper right), is pre-filtered by some R/C combinations (+UB#2: C1-3, R3), and fed to a
"cheap" off-the-shelf DC/DC converter (5V:5V). Beside that, the same voltage is used to power the primary side (NXT) of the photocouplers.
The output of the DC/DC converter is loaded by R18, a 470E resistor (~10mA), to maintain stability (though this wastes a lot of power
and R18's value should be increased, depending on the chosen converter...).
After a bunch of R/L/C filter elements (C6-10, L2, R2), which clean up the noisy output of the converter, +UB powers the secondary
side of the photocouplers as well as a low power linear regulator (R1, Seiko S817).
R1's (which actually should be labeled "REGx", *damn*) output voltage (3.3V) is filtered by C4-5, L1 and powers the MCP3421 and it's
SCL/SDA pull-up resistors (R7, R17).
The incoming SCL line (NXT) does not need a bidirectional isolation. It is just fed to Q3 (BC807-40), configured as an emitter-follower,
which enables higher currents for PC3's LED.
The required bidirectional isolation for the SDA line is described here.
Only difference: All 3 TLP102s are powered by +5V, but their outputs are connected to 3.3V components. Although the (TLPs) output voltage
won't rise above ~3.5V, this causes some funny waveforms (whose screenshots may (someday) make it up to here...).
For the ease of it, the MCP is configured for single ended inputs (VIN- grounded), which limits the VIN+ input range to 0..2048mV
(though this is not the complete story - read on ;-) with a resolution of 17 bits (18 bits would require -2048mV..2048mV range).
Two preconfigured divider ratios, selectable by a jumper, extend the voltage range to ~2.24V (low range, R5, R11||R12) or
~43V (high range, R4, R11||R12). To avoid instant MCP damages, if the input voltage is accidentally reversed or high voltages are
applied to the low-range setting, a Zener diode (D2, 4V7) limits the MCP input voltage to acceptable values.
Note: Although "4V7" seem to be a too large value to protect a 3V3 powered component, keep in mind that Zener diodes (<5V) do _not_
have steep edges. Lower Zener values will have an impact on the integral linearity (towards 2048mV), whereas higher values do not have
a protective function.
The selectable gain of the MCP3421 (1x, 2x, 4x, 8x), in conjunction with the two preconfigured ranges, make Messofen an universal
measurement interface. While the high range offers ~330uV resolution up to ~43V (gain=1), the lowest range has a 280mV full-scale
value (gain=8) with a theoretic resolution of ~2uV per digit (theoretically! remember this ;-), perfectly suited for low current shunt
What about the precision?
If you make use of the software calibration feature (highly recommended!), you don't even need to select R4, R5, R11 and R12 (the input
resistor divider components) or care about the input offset voltage of the MCP3421. The latter is specified with a maximum value
of 40uV (typ.15uV; 5V operation; -40°C..85°C), but I guess you know how this value is measured: With both inputs grounded or at least tied
to the same potential...
But we have at least a 60k resistor, directly connected to the VIN+ pin. The input bias current, no matter what direction it takes through
the 60k resistor(s), will create a much higher offset (~700-900uV, unconnected input).
Because of the changing input impedances, just imagine...
the input offset voltage will change dramatically. In the low range's short circuit condition, the effective resistance is ~4k7 (5k6 || 60k),
which is a value about 13 times smaller than the open loop 60k resistance. This results in ~5-10 digits offset for the low range and ~40-80
digits for the high-range (18 bit; gain=1). A gain setting of "8" will operate as a multiplicative factor of "8", making things even more worse...
- 1) ... a short circuit condition in the low range (5k6 selected)
- 2) ... or an unconnected input,
Because this can not (easily) be compensated in hardware (for all settings and without additional components),
we let the software perform a calibration (see next chapter) and tune Messofen to be a really fine
precision measurement interface.
Notice: It is highly recommended to label different PCBs and write down their calibration values, preferably
in the code.
Although this is not explicitly stated in the MCP's datasheet, it turned out that the A/D converter indeed is able to measure below ground,
even in single ended mode! D2 will of course limit the range to a few hundred millivolts, but this is perfect for...
I must admit, I did not expect this and worried about negative offsets, but this is really working fine!
- 1) ... calibrating negative offsets
- 2) ... measuring bidirectional currents (via shunt); especially useful with high gain settings
A pbLua example is available in the download section...
to be documented (or whatever...)
Some Useless Pics
Messofen PCB under test...
do not forget to label them (calibration!)
- schematic (PDF)
- placement (PDF)
- layout, eagle (BRD)
DOWNLOAD: pblab-messofen_V13-hard.zip update 4/2010 (V1.2)
DOWNLOAD: pblab-messofen-soft.zip example pbLua usage 09/2010 (V0.6)
ASkr 12/2008 initial wirewrapped version (V0.1)
ASkr 02/2009 update to V0.2
ASkr 03/2010 reincarnation as V1.0
ASkr 04/2010 corrected some typos (new schematic V1.2)
ASkr 09/2010 fixed one more typo (new schematic V1.3); updated "example usage" source code