[TriEmbed] Measure voltage

Trampas Stern trampas at gmail.com
Thu Aug 17 16:37:41 CDT 2023


Yes on the Zener for protection:

[image: image.png]
Also you want to have high precision resistors, 1% are used above, as the
resistor values will affect the accuracy.  Note that resistors tolerances
can be calibrated out per unit, but higher quality resistors are cheaper
than calibration.  Also you want to have a capacitor on the ADC input to
smooth out the high frequency noise (low pass filter).  The capacitor
should be much larger than your ADC's internal sample and hold capacitance
to allow faster sampling with less error in measurement due to shorter
sampling periods.


Note that GPIO pins on microcontrollers often have Schottky diode clamps on
the pins, however ADC and analog pins may not have clamping due to the
added impedance (capacitance) of the diodes.
[image: image.png]

These internal diodes will clamp and overvoltage up to your VDD/VCC,
however most LDOs and buck converters will not clamp overvoltage. As such
when a GPIO pin is overvoltage it will increase the voltage on VCC/VDD and
then fry all chips connected to that power rail.   As a result I have
gotten into the habit of putting a 3.9V zener on the 3.3V power rail, such
that it will clamp over voltage issues.  I use a 3.9V zener as you want to
make sure the breakdown voltage is well above 3.3V such that it does not
have high leakage current with your nominal 3.3V.  Adding Zener diodes to
my power rails has saved many boards for me.  For example when you have a
solder bridge shorting out LDO, or when someone (me) accidently puts high
voltage on a pin.  I have also noticed that when the zeners fail due to
over voltage (wattage), they usually fail shorted, which is nice as if I
see power rail shorted I will check for heat on the zener and know that I
most likely have an overvoltage failure that fried the zener. The zener
needs to be replaced but it did its job in protecting all other chips on
the board.

Trampas





On Thu, Aug 17, 2023 at 5:11 PM John Vaughters <jvaughters04 at yahoo.com>
wrote:

> Stern,
>
> I just checked autofill for Stern to Steve, and I admit I have no excuse.
> `,~)
>
> Sorry I missed that.
>
> John Vaughters
>
>
>
>
>
>
> On Thursday, August 17, 2023 at 05:09:36 PM EDT, John Vaughters <
> jvaughters04 at yahoo.com> wrote:
>
>
>
>
>
>
> Steve,
>
> Excellent discussion on accuracy and precision, I enjoyed reading the
> clarifications and examples you gave. I never really broke it down like
> that before, but probably followed your methods/ideas in practice.
>
> If I missed anything in the discussion, then forgive the repeat info, but
> I would probably put a 3.3v zener on the measuring pin for protection of
> that pin in the case of accidental overvoltage. Not sure if the chip has
> protection or not, but just a thought.
>
> Thanks,
>
> John Vaughters
>
>
>
>
>
> On Thursday, August 17, 2023 at 09:44:02 AM EDT, Trampas Stern via
> TriEmbed <triembed at triembed.org> wrote:
>
>
>
>
>
> So how much resolution on the ADC do you need, and how are you going to
> test the results?  For example if you are measuring between 0-13V with a
> 12bit ADC (I will assume 12 effective bits) then you have ~3.174mV
> resolution on the measurement with a simple voltage divider.
>
> Now you can scale the voltage as you mentioned by using some op-amps
> and/or negative reference for the voltage divider.  However this adds more
> hardware to the design as such if the simple divider and bit depth of the
> ADC is good enough, it is good enough.
>
> To use an opamp you basically setup a voltage subtractor (differential
> amplifier) where the negative reference is 9V.  So basically you make the
> circuit implement the mathematical operation of X=Vin-9V, see:
> https://www.electronics-tutorials.ws/opamp/opamp_5.html
>
> For the 9V reference you can use a zener, voltage reference or linear
> regulator.  Not that here again your accuracy of measurement will be based
> on the accuracy of the voltage reference and components used in the
> differential amplifier.  For example if the voltage reference is +/-1%,
> then you could have a +/-9mV error on the voltage measurement due to
> accuracy for the voltage reference.   So here again if you had a 12
> effective bit ADC you might be more accurate with a simple voltage divider
> and measure 0-13V, than doing the differential amplifier and measuring
> 9-13V.
>
> Also note that your accuracy of the ADC is based on the accuracy of the
> ADC voltage reference as well, so make sure you account for this as well.
>
> Remember that accuracy, precision, and resolution are not the same things,
> for example:
>
>
> Many people get accuracy and precision confused and assume that precision
> defines accuracy, for example which of these is more accurate?
>
>   Basically you do not know which is more accurate unless you can measure
> the target value with more accuracy and precision then your samples, for
> example:
>
> So for example if you are trying to measure to 1mV resolution and your
> multimeter you are using as a golden reference is 10mV resolution you can
> not calibrate the system and know you can measure to 1mV.  To this end I
> have found in my professional life, rather than asking about product
> requirements, it is often better to ask "How are you going to measure if
> this product meets your requirements?"  That is if someone has their test
> and validation plans defined, then requirements are known.  Where if they
> have requirements with no test plan, then often they have not figured out
> how to measure when they are done. For engineers if you have no measure for
> doneness, then they will never be done with a project.
>
> Trampas
>
> On Wed, Aug 16, 2023 at 4:29 PM The MacDougals via TriEmbed <
> triembed at triembed.org> wrote:
> > I know how to set up a voltage divider with a couple of resistors to
> measure
> > battery voltage of ~12v on an analog pin that accepts 3.3v.
> >
> > But, I really am interested in a small segment of the range, say 9v to
> 13v.
> > How would I “zoom” in on that range?  I want to subtract/bias the vbat
> > by the 9v minimum.  So, 9v -> 0 and 13v -> 3.3.
> >
> > ---> Paul
> >
> >
> >
> > _______________________________________________
> > Triangle, NC Embedded Interest Group mailing list
> >
> > To post message: TriEmbed at triembed.org
> > List info:
> http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
> > TriEmbed web site: https://TriEmbed.org
> > To unsubscribe, click link and send a blank message: mailto:
> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
> > Searchable email archive available at
> https://www.mail-archive.com/triembed@triembed.org/
> >
> >
>
> _______________________________________________
> Triangle, NC Embedded Interest Group mailing list
>
> To post message: TriEmbed at triembed.org
> List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
> TriEmbed web site: https://TriEmbed.org
> To unsubscribe, click link and send a blank message: mailto:
> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
> Searchable email archive available at
> https://www.mail-archive.com/triembed@triembed.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20230817/9779941c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 8632 bytes
Desc: not available
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20230817/9779941c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 25360 bytes
Desc: not available
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20230817/9779941c/attachment-0001.png>


More information about the TriEmbed mailing list