Searching \ for '[PIC] Switching voltage references' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/power/priswitch.htm?key=switching
Search entire site for: 'Switching voltage references'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Switching voltage references'
2007\07\17@083926 by PicDude

flavicon
face
Hi all,

I want to read two analog inputs on a PIC 16F913, but one requires a 2.5V
absolute reference (as the input source is an absolute value), and the other
requires a Vdd/2 reference (as that input source is a ratiometric value).  I
need some way to switch between these, without corrupting the accuracy of
either.  I do have one extra PIC I/O available since I'm using internal MCLR
now.

Currently for the absolute reference, I have Vdd to a resistor to a 2.5V shunt
reference to ground, and the midpoint (where the resistor meets the shunt) is
the 2.5V point.  The ratiometric reference is just 2 equal-valued resistors,
and again the midpoint of these is the reference value.  I'll leave out any
filter caps for simplicity for now.

As a first thought, I could leave the 2-resistor arrangement (I'll call them
RH for the high side and RL for the low side), then place the shunt reference
across RL, with a switching element, such as a transistor/FET.  The extra PIC
pin would control that switch.  With the shunt in-circuit, the 2.5V reference
would override the ratiometric references (so RH, RL would be relatively
high).  But I can't see a way to do this without affecting the accuracy of
the shunt reference.

Any better ideas.  Parts count is critical, as there's very little space
available.

Thanks,
-Neil.

2007\07\17@090347 by Alan B. Pearce

face picon face
>I want to read two analog inputs on a PIC 16F913, but one
>requires a 2.5V absolute reference (as the input source is
>an absolute value), and the other requires a Vdd/2 reference
>(as that input source is a ratiometric value).  I need some
>way to switch between these, without corrupting the accuracy
>of either.

OK, using the 2.5V reference is straight forward - but I do seem to remember
that this could be pushing the limits of minimum reference voltage.

But I take it you are looking to use the full A/D range (no of bits) on the
Vdd/2 input. If using a Vdd of 5V I would be tempted to have an analogue
input on a Vdd/2 divider, measure that each cycle using 2.5V reference, and
then measure the desired input again against the 2.5V reference. The ratio
between the two is then surely what you are looking for?

2007\07\17@091149 by Spehro Pefhany

picon face
Quoting PicDude <spam_OUTpicdude2TakeThisOuTspamavn-tech.com>:

{Quote hidden}

Consider an SN74LVC1G3157 or similar. 14 cents in 1K/ 50 cents for one and
SC70 packages. Very low series impedance. 1 part

If you could live with a slightly lower reference for the ratiometric
input, you could consider a resistor in shunt that would reduce the reference
ratiometric reference to, say 2.0V, and then if the shunt reference doesn't
conduct too many uA at 2V you have a pretty good ratiometric reference, and
the accuracy of your shut reference is not affected. You'd connect the
shunt resistor to your PIC output and switch it between gnd and open or
Vdd and gnd. That's zero parts. Your ratiometric reference accuracy will
be degraded a bit by having it switched to the digital ground, but
maybe that's not a concern. 0 parts

Or, if you can live with Vdd and GND as your ratiometric reference (so
pretty much the same results, just shifted by 1 bit and 1 bit less
resolution), just switch it using ADCON0! Then you have -2 or -3 parts.

Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
.....s...KILLspamspam@spam@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com


Q


2007\07\17@133019 by Steve Smith

flavicon
face
I think its doable with just an output pin...

1.        arrange the ratio metric input to be 75% FSD or 3.75v or some value
>2.5v and ensure its got about 1mA available. (this is to ensure the
programmable zener works properly.)
2.        Arrange TL431 or equiv across the low end resistor. They are 2.5v
with the control pin high z.
3.        connect the spare pic pin to the 431 control pin (may need a
resistor) set output low and tris controls the voltage ref either 2v5 or
supply voltage over ??

Steve

{Original Message removed}

2007\07\17@225623 by PicDude

flavicon
face
On Tuesday 17 July 2007 08:06, Spehro Pefhany wrote:
> Consider an SN74LVC1G3157 or similar. 14 cents in 1K/ 50 cents for one and
> SC70 packages. Very low series impedance. 1 part

But don't these muxes have *some* resistance still (as a FET etc would)?
...I should calculate to see just how the resistance affects the measurements
though.


{Quote hidden}

Not sure if I follow you here, but you're suggesting that I leave the absolute
reference in place, but switch the ratiometric reference in and out, correct?


> Or, if you can live with Vdd and GND as your ratiometric reference (so
> pretty much the same results, just shifted by 1 bit and 1 bit less
> resolution), just switch it using ADCON0! Then you have -2 or -3 parts.

Currently, I have different configurations for a handful of different sensors.  
Some varying resistance to ground, others just ratiometric, others absolute.  
Over time, the design has been evolving towards one hardware configuration
that would simplify CEM assembly (and hence lower cost) and eliminate the
need for me to tweak by adding/removing a part here or there.  Only thing I
would have to do is change SW versions.  All this time, I'm balancing board
space (very very precious), I/O pins, cost, and accuracy.  But this
ratiometric/absolute reference thing is the final piece required to come to a
single hardware config.  With the different sensors though, some would give
me only 38% of the ADC's range, some 90+%, etc.  By switching the reference
between Vdd-Gnd, Vdd/2-Gnd, etc I can get at least 50% of the ADC's range for
all configs.

I was trying to come up with a way to have a ratiometric reference on Vref+,
then an absolute on Vref-, then switch accordingly.  But it's not working out
so far, especially since the Vref- pin is in use.

Another thought was to have Vref+ with the absolute reference, then take the
Vdd/2 reference into a different analog input, and essentially measure the
Vdd value through that.  Then I could do the math in software to compensate
the ratiometric sensor samples.  But I don't have any of the analog inputs
free.  And any pin changes would require 30+ code files to be changed and
rebuilt....ugh!

Cheers,
-Neil

{Quote hidden}

2007\07\17@230345 by PicDude

flavicon
face
On Tuesday 17 July 2007 08:03, Alan B. Pearce wrote:
> OK, using the 2.5V reference is straight forward - but I do seem to
> remember that this could be pushing the limits of minimum reference
> voltage.

Actually 2.0V range is the min required on these PIC's.


> But I take it you are looking to use the full A/D range (no of bits) on the
> Vdd/2 input. If using a Vdd of 5V I would be tempted to have an analogue
> input on a Vdd/2 divider, measure that each cycle using 2.5V reference, and
> then measure the desired input again against the 2.5V reference. The ratio
> between the two is then surely what you are looking for?

Ahhh... I just posted about that too.  Would work beautifully (with some math
in software), if only I had an extra analog input available.  Moving around
some pins is very difficult as a lot of code files that would need to be
changed, and I'll need to maintain the old code still for upgrades.  I'm
sitll evaluating/considering this still as it is a workable option.

Cheers,
-Neil.

2007\07\17@230901 by PicDude

flavicon
face
On Tuesday 17 July 2007 12:30, Steve Smith wrote:
> I think its doable with just an output pin...
>
> 1.        arrange the ratio metric input to be 75% FSD or 3.75v or some value
>
> >2.5v and ensure its got about 1mA available. (this is to ensure the
>
> programmable zener works properly.)
> 2.        Arrange TL431 or equiv across the low end resistor. They are 2.5v
> with the control pin high z.
> 3.        connect the spare pic pin to the 431 control pin (may need a
> resistor) set output low and tris controls the voltage ref either 2v5 or
> supply voltage over ??
>
> Steve


Hmmm... TL431 with a control input you say, huh?  I'll go investigate...

Cheers,
-Neil.

2007\07\18@024423 by Nicola Perotto

picon face

PicDude wrote:
> <snip>
> Ahhh... I just posted about that too.  Would work beautifully (with some math
> in software), if only I had an extra analog input available.  
>
> Moving around
> some pins is very difficult as a lot of code files that would need to be
> changed,
Are you sure? Why this?
Maybe there are something very wrong...
If you program in the right mode there is only the pin definition to
change and eventually some device initialization but never "a lot of code"


> and I'll need to maintain the old code still for upgrades.  I'm
> sitll evaluating/considering this still as it is a workable option.
>
> Cheers,
> -Neil.
>  

2007\07\18@053848 by Spehro Pefhany

picon face
At 10:56 PM 7/17/2007, you wrote:
>On Tuesday 17 July 2007 08:06, Spehro Pefhany wrote:
> > Consider an SN74LVC1G3157 or similar. 14 cents in 1K/ 50 cents for one and
> > SC70 packages. Very low series impedance. 1 part
>
>But don't these muxes have *some* resistance still (as a FET etc would)?
>...I should calculate to see just how the resistance affects the measurements
>though.

Less than 10 ohms and it's in series. It should be very, very good, but leakage
could affect the ratiometric reference a bit, so you should calculate that,
depending on what current you can afford in that net.


                                               SEL

                                  VCC            |
                                   +             |
                                   |             |
                                   |             |
                                  .-.            |
                                  | |            |
                                  | |            |
                                  '-'      .-------------.
                                 \ +-------|             |
                VCC                |       |             |
                 |                 - \     |             |   Vref
                .-.                ^       |             |-------
                | |                |       |             |
                | |                |       |             |
                '-'               ===      |             |
                 |                GND      |             |
                 --------------------------|             |
                 |                         '-------------'
                .-.
                | |
                | |
                '-'
                 |
                GND



{Quote hidden}

Forget this, I don't think it will work well enough when I look at the
numbers. Eg. LM385-2.5 with 3K/2K I see about 6mV = 0.6% error in the
ratiometric reference, and there will be error because the PIC pin has
some resistance to ground etc.

This is what I had in mind, but the '385 typically conducts about 10uA
@2V.

                                  VCC
                                   +
                                   |
                                   |
                                  .-.
                                  | | 3K
                             2K   | |
                             ___  '-'
   Float = 2.5V band-gap o -|___|- +----------  Vref
   0V = 2.0V ratiometric         \ |
                                   - \
                        LM385-2.5  ^
                                   |
                                   |
                                  ===
                                  GND

(poor performance, not recommended)

{Quote hidden}

You can't do this?


                VCC               VCC +5V
                 +                 +
                 |                 |
                 |          .-------------.
                .-.         |             |
                | |         |             |
                | |         |             |
                '-'         |             |
                 |          |             |
          2.50V  +----------| Vref+       |
                 |          |             |
               \ - \        |             |
                 ^          |             |
                 |          |             |
                 |          |             |
                ===         |             |
                GND         '-------------'

                                  VCFG0 = 0 Ratiometric 0-5V
                                  VCFG0 = 1 Absolute 0-2.5V

You can left shift the result to get the same nominal result (with one
bit poorer resolution) for the ratiometric case.


>Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
.....speffKILLspamspam.....interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com



2007\07\18@100130 by PicDude

flavicon
face
On Wednesday 18 July 2007 01:43, Nicola Perotto wrote:
> PicDude wrote:
> > Moving around
> > some pins is very difficult as a lot of code files that would need to be
> > changed,
>
> Are you sure? Why this?
> Maybe there are something very wrong...
> If you program in the right mode there is only the pin definition to
> change and eventually some device initialization but never "a lot of code"

Because of different things going on with a single port, the code stores
changes for various types of external activities in selective bits of
different registers, then those are AND-ed to mask/filter out the state of
the required pins, then later OR-ed back together before writing it to the
port in one instruction.  It is not difficult to change all the masks etc
around the code, but as I've still not found a local coder, I'd have to make
the time for this myself, and time is not my friend lately. :-)  I originally
wrote the code as you indicated, but that caused lots of odd effects such as
audible "hiccups" on a buzzer, or "ghosting" on some LED segments.

Cheers,
-Neil.

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...