Searching \ for 'AN513' 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/index.htm?key=an513
Search entire site for: 'AN513'.

Truncated match.
PICList Thread
'AN513'
1997\05\19@130607 by Jussi VainionpŠŠ

flavicon
face
Microchip application note AN513 describes a method for ADC.
I'm not that great at analog electronics, and I don't quite understand the
schematics. It has this chip that is supposed to be voltage to current
converter 4066, but according to my data it is a quad bilateral analog
switch. How could it convert anything?

I'll try to reproduce a part of the schematic here:

    S1
1 /----\ 2
---| 13 |----+
  \----/    |
            |
4 /----\ 3  | 5  |\ 4066
---|  5 |----+----|+ \------
  \----/      +--|- /
    S2        |6 |/
              |
              |

I don't quite understand what those S1 and S2 things are.

Thanks for your assistance.

1997\05\19@184826 by Gerhard Fiedler

picon face
At 20:03 19/05/97 +0300, Jussi Vainionp wrote:
>Microchip application note AN513 describes a method for ADC.
>I'm not that great at analog electronics, and I don't quite understand the
>schematics. It has this chip that is supposed to be voltage to current
>converter 4066, but according to my data it is a quad bilateral analog
>switch. How could it convert anything?
>
>I'll try to reproduce a part of the schematic here:
>
>[...]
>
>I don't quite understand what those S1 and S2 things are.

Those S1..S4 are the 4066, as you said a quad analog switch. The numbers in
the circles should be the control inputs, and the other two the pins for
signal i/o. U1 seems to be an opamp (of your choice), _not_ the 4066
(despite the number being very close to it...).

If you want to make some experiments with this circuit, I'd be interested
in the results, and willing to help you with the analog part of it :-)

1997\05\20@004500 by tjaart

flavicon
face
Gerhard Fiedler wrote:
{Quote hidden}

Why not charge a cap and measure time-to-trip on an input? You only
need a cap and two resistors.

--
Friendly Regards

Tjaart van der Walt
spam_OUTtjaartTakeThisOuTspamwasp.co.za
_____________________________________________________________
| Another sun-deprived R&D Engineer slaving away in a dungeon |
|             WASP International  http://wasp.co.za           |
|             GSM and GPS value-added applications            |
|  Voice : +27-(0)11-622-8686   |   Fax : +27-(0)11-622-8973  |
|_____________________________________________________________|

1997\05\20@142848 by Gerhard Fiedler

picon face
At 06:39 20/05/97 +0200, Tjaart van der Walt wrote:
>Gerhard Fiedler wrote:
>>
>> At 20:03 19/05/97 +0300, Jussi Vainionp wrote:
>> >Microchip application note AN513 describes a method for ADC.
>> >I'm not that great at analog electronics, and I don't quite understand the
>> >schematics. It has this chip that is supposed to be voltage to current
>> >converter 4066, but according to my data it is a quad bilateral analog
>> >switch. How could it convert anything?
>
>Why not charge a cap and measure time-to-trip on an input? You only
>need a cap and two resistors.

I've never tried this approach, but I saw a Philips app note doing some
analysis of a similar method to measure resistance, and they came up with
around 5 bit for the most simple version (one port, one C, and one R),
about 8 bit for a version using two ports and two HC buffers, and around 14
bit using two comparators.

Since what you suggest seems to be similar, I think the results might be
similar, too. Do you have any experience with the precision and
repeatability (also over temp range) with this simple circuit?

1997\05\20@202233 by John Payson

flavicon
face
> I've never tried this approach, but I saw a Philips app note doing some
> analysis of a similar method to measure resistance, and they came up with
> around 5 bit for the most simple version (one port, one C, and one R),
> about 8 bit for a version using two ports and two HC buffers, and around 14
> bit using two comparators.
>
> Since what you suggest seems to be similar, I think the results might be
> similar, too. Do you have any experience with the precision and
> repeatability (also over temp range) with this simple circuit?

If you have a comparator (either external or 16C62X) you can measure a
slowly-changing analog voltage with decent accuracy (if you measure 16
bits, you'll get about 12 good ones) using the following method:

Feed one input signal into one comparator input.

Feed a PIC output, through a large resistor, into the other comparator
input.  Also place a nice big cap between this input and ground (see below
for info on values).

Run the output of the comparator into another PIC port pin.

Then run the following code at the fastest continuous rate you can
manage (e.g. toss in a timer tick routine or somesuch.  Note that this
code assumes the PIC's RC is fed into the inverting input of the
comparator.  If this is not so, reverse the BTFSx instruction as marked.

TimerL: ds      1       ; 16-bit timer counts number of subsamples
TimerH: ds      1
CountL: ds      1       ; 16-bit counter: how many high comparator reads
CountH: ds      1
ReadL:  ds      1       ; 16-bit last read value
ReadH:  ds      1

...

CallMe:
       btfsc   INPUT   ; Change to BTFSS if OUTPUT feeds non-invert input
        goto   InputHi
InputLo:
       bcf     OUTPUT
       incfsz  CountL
        goto   DoTimer
       incfsz  CountH  ; Should never skip, but INCFSZ doesn't hit flags
       goto    DoTimer

InputHi:
       bsf     OUTPUT

DoTimer:
       decfsz  TimerL
        goto   Done
       decfsz  TimerH
        goto   Done
       movf    CountL,w        ; ***
       movwf   ReadL           ; ***
       movf    CountH,w        ; ***
       movwf   ReadH           ; ***
       clrf    CountL          ; *** [sets Z flag]
       clrf    CountH          ; *** [sets Z flag]
Done:
       ...

Note that except in the instructions marked with asterisks, neither W nor
PSW is altered in any way.  If the above code is used in an ISR, and W
and PSW are "live", the asterisked instructions may be replaced with:

       movwf   WSave
       swapf   CountL
       swapf   CountL,w
       movwf   ReadL
       swapf   CountH
       swapf   CountH,w
       movwf   ReadH
       movlw   0
       movwf   CountL
       movwf   CountH
       swapf   WSave
       swapf   WSave,w

This will save one instruction versus the normal save/restore sequence and
also saves a register.

Anyway, the way this ADC works is that the processor will, in essence, be
outputting a PWM wave with whatever duty cycle is required to make the
capacitor voltage match the input.  To see why this measurement technique
works, imagine that both the input and the capacitor are at 3/4 VDD.  Any
time the PIC outputs a high, the current into the capacitor will be 1/4
VDD/R.  Any time the PIC outputs a low, the current from the cap will be
3/4 VDD/R.  Since the average current into and out of the cap must match
for the cap to stay at the same voltage, the PIC's output must be on 3
times as much as it is off (i.e. on 3/4 of the time).

Choosing the R and C for this circuit is an art/science for which the best
values will depend upon the application.  If the R and C are too small,
then the non-linear change in capacitor voltage during the cycle will
throw off the measurement accuracy a little bit.  If R and C are too
large, the device will take a long time to get to the proper voltage.  I
have not yet modeled RC's to find the optimum value, but I think an RC
time constant of about 256-1000 subsample times is probably pretty good.

Note that when I've used a windowed 16C622's internal comparator along
with a rather large R, the circuit was a bit sensitive to light.  I don't
know whether a smaller R (balanced with a larger C) would help this.  It
is definitely something to bear in mind, however.

1997\05\21@011108 by tjaart

flavicon
face
Gerhard Fiedler wrote:
>
> >Why not charge a cap and measure time-to-trip on an input? You only
> >need a cap and two resistors.
>
> I've never tried this approach, but I saw a Philips app note doing some
> analysis of a similar method to measure resistance, and they came up with
> around 5 bit for the most simple version (one port, one C, and one R),
> about 8 bit for a version using two ports and two HC buffers, and around 14
> bit using two comparators.
>
> Since what you suggest seems to be similar, I think the results might be
> similar, too. Do you have any experience with the precision and
> repeatability (also over temp range) with this simple circuit?

Your resolution depends on the time you have for charging the cap. If
you use
a 16 bit counter, that will be you resolution. On the repeatability
side, you
can improve it by using one of the output as a reference to calibrate
your
reading.

I've tried it once, and it worked so well that decided to never use a
PIC
with the A/D onboard again if I can help it.

There is (of course) a catch. In time critical software you'd have a
hard
time to fit it into your timing constraints. If you go the whole hog and
imlement a 16 bit AD with calibration, you'll need some 16 bit maths
too.

--
Friendly Regards

Tjaart van der Walt
.....tjaartKILLspamspam@spam@wasp.co.za
_____________________________________________________________
| Another sun-deprived R&D Engineer slaving away in a dungeon |
|             WASP International  http://wasp.co.za           |
|             GSM and GPS value-added applications            |
|  Voice : +27-(0)11-622-8686   |   Fax : +27-(0)11-622-8973  |
|_____________________________________________________________|

1997\05\21@034249 by Keith Dowsett

flavicon
face
At 18:22 20/05/97 -0400, you wrote:
{Quote hidden}

I would add one refinement. Use another pin to switch between a known
current source (precision resistor to Vcc) and the signal. This allows
calibration and makes the results less sensitive to temperature and gate
threshold voltage.

Keith.
==========================================================
Keith Dowsett         "Variables won't; constants aren't."

E-mail: kdowsettspamKILLspamrpms.ac.uk
  WWW: http://kd.rpms.ac.uk/index.htm

1997\05\21@041947 by STEENKAMP [M.ING E&E]

flavicon
picon face
> Gerhard Fiedler wrote:
> >
> > At 20:03 19/05/97 +0300, Jussi Vainionp wrote:
> > >Microchip application note AN513 describes a method for ADC.
[SNIP]

>
> Why not charge a cap and measure time-to-trip on an input? You only
> need a cap and two resistors.

You would want the cap to charge with a constant current proportional to
the voltage you want to digitize.  This will give you a linear voltage
charge curve across the cap.  Else you will get the normal exponential
RC curve.  One can of course try compensating for this in software, but it
would be complicated.
So you would need a voltage to current converter as well.  This can
easily be done by an OPAMP.
If I'm not mistaken this kind if conversion is called a single slope
integrator, or something like that.  It can be quite accurate, but is
slow.

Regards
Niki

1997\05\21@054838 by Scott Stephens

picon face
At 08:03 PM 5/19/97 +0300, you wrote:
>Microchip application note AN513 describes a method for ADC.
>I'm not that great at analog electronics, and I don't quite understand the
>schematics. It has this chip that is supposed to be voltage to current
>converter 4066, but according to my data it is a quad bilateral analog
>switch. How could it convert anything?

It uses an op-amp they don't specify. You can use a 741 or LF353, et.
But by then, you may be better off with a seperate A/D. I've also found that
they linearity of quad bilateral switches (analog mosfet muxes too) vary
greatly, and as critical in this application. An ugly can of worms, for sure.

1997\05\21@055708 by Scott Stephens

picon face
An additional problem I found with PIC output ports is crosstalk between
port pins, on the order of a few millivolts. So an adjacent pin switching
could show up in an A/D reading. Now I know everyone will tell me to bypass
and filter my power supply. I did that. I haven't seen a spec from Microchip
an pin-to-pin crosstalk, cuz they prabably never planned on ports being used
in an analog fashion.

1997\05\21@123329 by Gerhard Fiedler

picon face
At 07:06 21/05/97 +0200, Tjaart van der Walt wrote:
>There is (of course) a catch. In time critical software you'd have a
>hard
>time to fit it into your timing constraints. If you go the whole hog and
>imlement a 16 bit AD with calibration, you'll need some 16 bit maths
>too.

How complex is your analog circuit to get 16 bit precision (not resolution)
out of it? I thought you'd need at least an opamp (for the const charging
current), a comparator (might be the built-in of some of the PICs), and a
good temp compensated reference. And probably a way to do calibration runs
once in a while, i.e. some analog switches.

Easier to get this precision seems to be comparing a PWM output to the
input, but then this is still slower. For slowly changing input signals it
might be useable though; you can track the input, speeding the process
quite a bit up.

1997\05\21@125411 by Harold Hallikainen

picon face
       On  using RC timing as an A/D...  It seems that if you're using
an RC circuit instead of a current source driving a capacitor (as is done
in dual slope A/D converters), you have to deal with linearizing since
the time to charge a capacitor to a ceratin threshold is not linear with
the applied voltage.
       Looking at AN513, I see that it's a single slope A/D.  I like
dual slope A/Ds since they "self calibrate" by using the reference input
for the "de-integrate" phase.  Here, it appears that they are suggesting
an occasional single slope A/D conversion of a reference input, then
doing some math.  The dual slope A/D takes care of the math for you.   In
addition, the circuit in AN513 is relying upon an input port changing
state at some stable voltage.  How stable is the threshold, especially
with temperature and power supply variations?  Ideally, we'd add a
comparator to drive the input port.   Most dual slope A/Ds also have an
autozero phase.  For example, the MC14433 puts a sample of the total
offset voltage (due to the integrator op amp and the comparators) in a
capacitor.  That capacitor is then placed in series with the input during
the unknown integrate phase, canceling out the offset.  I did a project
with the MC14433 about 20 or 25 years ago.  It worked extremely well.
with zero input, the thing ALWAYS read 0.  Reversing polarity of the
input ALWAYS resulted in an exact reversal of the reading (positive to
negative, or back).  The MC14433 is a 3.5 digit A/D with a multiplexed
BCD output.
       One tricky thing on using an A/D to measure an absolute voltage
(instead of a voltage ratio) is the stability of the reference.  When I
first did the 14433 project, I just used a zener reference and a carbon
film resistor voltage divider.  I could put my finger on any of those
parts and watch the digits roll by.  Not very good!  I ended up using an
LM399H reference (6.95 volts with 0.5 ppm/C tempco) and a couple metal
film 5 ppm/C resistors.  I always wished National or someone would make
an LM399H (which gets its stability by including a temperature stable
oven on the chip) with a voltage divider on it.  Having the voltage
divider at a constant temperature would sure help!
       Another interesting dual slope A/D is the Maxim MAX134CPL.  This
is a digital multimeter on a chip.  The bus interface is a bit slow, so
some tricks have to be used to hang it on a processor bus.  It's
something like 4.5 digits.  It uses "residual multiplication" dual slope
A/D conversion.  It's the only time I've seen that technique, and it's
pretty clever.  In a normal dual slope A/D, to get more resolution, you
typically use a longer conversion time or a faster clock.  The unknown
voltage is integrated for a fixed time.  The reference is "de-integrated"
for a variable time until the integrator voltage gets back down to zero.
The time it takes to get back to zero is the A/D conversion.  There is
always some overshoot on the de-integrate phase, since the integrator
output does not pass through zero on exactly a clock change.  In residual
multiplication, they then integrate this "residual" integrator output and
multiply it by a scaling factor.  It was pretty clever.  It gives a
higher conversion rate than normally possible for that resolution using
dual slope.  The 134 does not include a zero capacitor.  It does have a
zero phase, but outputs a result that must then be subtracted from other
conversions.  This is the trick of moving hardware to software... saved a
capacitor!
       Another interesting dual slope A/D is the ICL7135.        It's
similar to the MC14433 but 4.5 digitsl.  It also has a multiplexed BCD
output, but in my project I didn't use that.  Instead I used the busy
line, the polarity line, and the clock line.  ANDing the busy and the
clock results in a burst of clock pulses.  The number of pulses in the
burst varies with the analog input voltage.  The A/D section in this
project operated on a floating power supply and was then opto coupled
down to the processor section.  The busyANDclock was then dumped into the
counter on a 6522A.  20,001 was subtracted from the resulting count, and
there was the A/D conversion in hundreds of microvolts.
       Summarizing...  If all you need is 8 bits of A/D, why not use a
chip with it on it?  It then takes NO external parts and works well.  If
more resolution is used, there are several single chip solutions that
don't require you to put a bunch of op amps and switches together.  Why
not take advantage of the expertise that went into the design of the A/D
chips that are out there?


Harold

1997\05\21@140219 by Tony Matthews

flavicon
face
N STEENKAMP [M.ING E&E] wrote:
{Quote hidden}

I recently used this configuration a single opamp and two port pins.one
port pin discharged the cap via a mosfet the other was an input pin. I
found that there is a minimum charge time for the cap so you cannot get
a clean 0 to 255 count. If you introduce a delay after releasing the
shunt and before counting it helps but is counter productive. If you
count to fast you rollover the counter and etc.. I would personally
suggest using the dual slope method as it allows for some of the
problems without reducing utility.However if you can restrict your
requirements to something less than the full 8 bit resolution the
repeatability and drift are negligible and the components are certainly
cheap enough. Tony M.

1997\05\22@010831 by tjaart

flavicon
face
Gerhard Fiedler wrote:
>
> How complex is your analog circuit to get 16 bit precision (not resolution)
> out of it? I thought you'd need at least an opamp (for the const charging
> current), a comparator (might be the built-in of some of the PICs), and a
> good temp compensated reference. And probably a way to do calibration runs
> once in a while, i.e. some analog switches.

I received a lot of private mail explaining the exponential V vs t curve
when a cap charges. I know this, it is just that I like to get away with
the
minimum hardware when possible. Somewhere in my original mail I did
state
that you'd need some 16 bit number crunching. I beleive that, in most
cases,
the time and memory needed for this purpose may be worth it.

Assume you have 16 bit math routines in your software. The exponential
function may be broken up as a series of terms. This is scaled against
the
time measured for the known voltage (the I/O pin).

> Easier to get this precision seems to be comparing a PWM output to the
> input, but then this is still slower. For slowly changing input signals it
> might be useable though; you can track the input, speeding the process
> quite a bit up.

Good point. I don't think a few ms will make or break most applications.

--
Friendly Regards

Tjaart van der Walt
.....tjaartKILLspamspam.....wasp.co.za
_____________________________________________________________
| Another sun-deprived R&D Engineer slaving away in a dungeon |
|             WASP International  http://wasp.co.za           |
|             GSM and GPS value-added applications            |
|  Voice : +27-(0)11-622-8686   |   Fax : +27-(0)11-622-8973  |
|_____________________________________________________________|

1997\05\22@095302 by Michael Mullen

picon face
Harold Hallikainen <EraseMEharoldhallikainenspam_OUTspamTakeThisOuTJUNO.COM> wrote:
<snip>
<<       Summarizing...  If all you need is 8 bits of A/D, why not use a
chip with it on it?  It then takes NO external parts and works well.  If
more resolution is used, there are several single chip solutions that
don't require you to put a bunch of op amps and switches together.  Why
not take advantage of the expertise that went into the design of the A/D
chips that are out there?>>

Excellent technical points in the clipped part of this post.  However,  cost
raises its head in production.  When I build something with a $10 BOM, I am
not going to throw away $1.25 (difference in cost -- production quantities --
between 'c54 and 'c71) in recurring cost, when I can put in a $.05 cap and
sweat a bit over calibration issues -- once -- unless there is a very good
reason to do so.

Mike Mullen

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