I haven’t made any electronics projects for a while now but I was working on some circuits at work that used a TL431 shunt regulator. This chip can be used to provide a 2.5V voltage reference and also 5V with the addition of two 10K resistors between the Ref pin and supply voltage and another to ground. A 470 ohm resistor on the input to the circuit limits current so not to damage anything. I looked at using one to improve the accuracy of one of my previous projects, an AA rechargeable battery tester.
I had made two testers based on completely different designs, the second uses the 1.1V internal reference to calculate the supply voltage which is used as a reference. The former simply uses a 10K resistor attached to the 3.3V out to the vref pin so it is nowhere near as accurate as the second tester I built. The second tester can also test up to 3 batteries at once.
Going back to the first tester I will use one of the TL431 chips to provide a 2.5V reference and hopefully that will improve accuracy as the 3.3V supply is provided by the CH340 on this clone and is far from ‘3.3V’. I don’t expect the accuracy to improve by much but it’s gonna be better than using a supply voltage as a reference as these can vary especially with cheap voltage regulators found on the Arduino clones. As the tester will only be measuring 1.5V max, 2.5V reference is enough. Unless of course you wanted to modify it to test lithium cells in which case you would need to configure the TL431 to provide a 5V reference instead.
The TL431, while undoubtedly very versatile, isn’t really a precision voltage reference device.
Even the internal bandgap reference present in the AVRs has better temperature stability, and is far less power-hungry (the TL431 requires around 1mA of current through its cathode pin just to maintain regulation!).
Also the parts count goes up with any voltage setting other than the default 2.5V because of the resistors; they also degrade the already less-than-stellar accuracy, and further increase the scatter of reference voltages in a mass-production context.
There are also of course many interesting circuits which exploit the fact that it’s basically a very specific kind of op-amp, with one input permanently hooked up to the internal 2.5V reference.
Many useful things can be done with that – far beyond its expected application as a simple shunt voltage regulator.
For a 5V reference application, there are many alternative 2-terminal devices available (thus requiring no extra resistors) which are also far less power-hungry: minimum currents in the 10-100uA range.
In any case, a 5V reference voltage isn’t really feasible when the device in question is powered from anything less than about 6V (eg. USB ports, single lithium cells, etc.).
In those cases, it’s best to use the AVR’s integrated bandgap reference, and scale the ADC inputs down instead (via high-value resistive dividers + bypass caps).
In fact, there is very rarely any good reason to NOT use the AVR’s integrated reference. It’s more than good enough for all but the most highly demanding applications – and for those, a TL431 won’t cut the mustard either.
To be fair I built the circuit and found that the AVR measuring voltage compared to a recently calibrated Fluke DVM was out by only 12mv (measured at the ADC input) so that isn’t bad going at all. However you are right, there are precision reference chips available and that is what I would prefer but I had a couple of TL431’s in my parts box so I put them to use.
The TL431 has three versions; standard, ‘A’ and ‘B’ suffixes. These have 2%, 1% and 0.5% accuracy respectively. I used the ‘A’ suffix part.
The 1.1V reference I have used in one of my projects but for the new tester I’m building scaling would make it a bit more complex and 100% accuracy isn’t really required in my application. With the existing AA tester there was a voltage drop along the wires going to the battery holder and the holder itself so this also contributes to inaccuracy. There was about 0.4V drop due to cheap holders being used but this could be compensated for in the code.
The tester I’m building will test 24V lithium batteries and that would have to have the input voltages divided down to a range the AVR can handle. This will loose a bit of precision but that can’t be helped unless I use an external ADC chip with more resolution. Again voltage drop will be a problem but I will help combat that by using good quality connectors and thicker cable rated at twice the current it will be carrying.
> Again voltage drop will be a problem
When dealing with very heavy currents, the best way is to use Kelvin connections for the voltage measurement – this avoids BOTH the voltage drops caused by the cable resistance AND the contact resistance of the connectors utilized.
However most battery clip-type connectors aren’t made to allow that, so the next best alternative is to use a pseudo-Kelvin connection, by running separate measurement wires right up to the alligator clips. At least takes the cable resistance out of the equation.
Of course when doing that with an AVR’s ADC, you have to either keep the AVR ground and the power ground separate (connected together ONLY at the Kelvin “-” terminal) or use some sort of instrumentation amplifier arrangement that allows for a differential input measurement.
It appears that the TL431 suffix only affects the *initial* voltage accuracy, not the temperature stability – at least, not according to the datasheet figures.
Makes sense, really – obviously they’d be binning them by nominal voltage at 25C, not by the tempco anyway, since it isn’t a “precision”-type reference.
Input scaling is hardly “more complex”… really all it takes is just 1 extra resistor per ACD input – as there should *always* be a series resistor on each ADC input in any case, to help protect it from ESD as well as things like being accidentally set as an output in the code (and thus burning out the pin if it has a low-resistance path to the ground).
No GPIO pin should ever have a low resistance path to the ground – EVER; it’s one of the most basic tenets of good design practices.
When I get that code written I’ll let you have a look at it especially if I’m having problems. Thanks 🙂