Searching \ for 'pin configuration question 16c84' 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/microchip/devices.htm?key=16C
Search entire site for: 'pin configuration question 16c84'.

Truncated match.
PICList Thread
'pin configuration question 16c84'
1997\03\24@134412 by Tony Matthews

flavicon
face
Hello
I would like to simplify a four bit d/a that I'm using portb 4-7 to
emulate I have each pin connected to a diode then a resistor this in
turn draws current from the noninverting side of a voltage follower
configured opamp this in turn causes the output to swing + to compensate
and the inverting output is connected to a pot to provide the initial
offset simple right? only I figure if I change the port pins from low to
high impedance I can dispense with the diodes right? What sort of morass
am I wading into firmware wise I mean the port is allready working hard
but is configured as an output and I have no experience changing
individual pin configurations. Generally I configure b out a in and
leave it at that but...anyway.oh yeah 16c84 xt mode 100khz line powered
.R2R increases the part count (discrete's) and space is as usual at a
premium.can I toggle a configuration bit without creating artifacts on
the other pins of that or any other port?The data book explains how I
suppose but is not to clear on the downside . respects Tony M.

1997\03\24@165651 by Andrew Warren

face
flavicon
face
Tony Matthews <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> can I toggle a configuration bit without creating artifacts on the
> other pins of that or any other port?

Tony:

Yeah, you can... It's easiest if you FIRST write to the port, THEN
write to the TRIS register immediately afterward.

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
===
=== Custodian of the PICLIST Fund -- For more info, see:
=== www.geocities.com/SiliconValley/2499/fund.html

1997\03\24@183119 by Steve Hardy

flavicon
face
> From: Tony Matthews <tonyspamKILLspamMAGICNET.NET>
> Hello
> I would like to simplify a four bit d/a that I'm using portb 4-7 to
> emulate I have each pin connected to a diode then a resistor this in
> turn draws current from the noninverting side of a voltage follower
> configured opamp this in turn causes the output to swing + to compensate
> and the inverting output is connected to a pot to provide the initial
> offset simple right? only I figure if I change the port pins from low to
> high impedance I can dispense with the diodes right? What sort of morass
> am I wading into firmware wise I mean the port is allready working hard
> but is configured as an output and I have no experience changing
> individual pin configurations. Generally I configure b out a in and
> leave it at that but...anyway.oh yeah 16c84 xt mode 100khz line powered
> .R2R increases the part count (discrete's) and space is as usual at a
> premium.can I toggle a configuration bit without creating artifacts on
> the other pins of that or any other port?The data book explains how I
> suppose but is not to clear on the downside . respects Tony M.
>

You can toggle any of the TRIS bits without glitching the outputs.  If
I read your prose correctly, you are using a non-inverting
configuration of the op amp.  The trouble with this is that the gain
will vary depending on the setting of the offset pot, and the output
will be nonlinear.  This may not be a problem, but I think you would be
a lot better off using an inverting configuration.  Tie each output
through a binary weighted resistor to the inverting input, and connect
the non-inverting input to the offset trimmer.  Now if each output pin
is either LOW or HI-Z, then the output will swing positive with respect
to the voltage on the non-inverting input.

Added bonus: it is now possible for you to implement a 5-bit DAC using
only 4 port pins.  You can now change the SIGN of the output by setting
the output port pins to HIGH or HI-Z.  Effectively, you can change the
output for a total of 31 steps: 15 below 'zero' and 15 above.  Note
that the 'gain' for +ve and -ve swings may be different if the
non-inverting input is not set to half Vcc.

Now a question for you gurus: given that each of 4 outputs can be in
one of 3 possible states, one could conjecture that it is possible to
make a DAC with 3^4 = 729 possible output levels.  Is this possible in
practice?  Ignore the imperfections of the outputs - assume they are
exactly 0V or 5V or infinite impedance, and your resistors and opamp
are perfect.  Is it possible to make a linear (not just monotonic)
DAC?

Regards,
SJH
Canberra, Australia

1997\03\24@202847 by Tony Matthews

flavicon
face
>
> Tony Matthews
>
> > can I toggle a configuration bit without creating artifacts on the
> > other pins of that or any other port?
>
Andrew Warren wrote:
>
> Yeah, you can... It's easiest if you FIRST write to the port, THEN
> write to the TRIS register immediately afterward.
>
Well then can I toggle that port by successive writes to the tris reg?
Sorry but the hdw end of this deal I get in not less than two weeks but
I'd like to start writing the code while waiting on the board house.And
I have no hdw simulator.Though I suppose the first question was answer
enough. Thanks Andy
Back to the salt mines  ,Tony M.

1997\03\24@212757 by Tony Matthews

flavicon
face
> I read your prose correctly, you are using a non-inverting
> configuration of the op amp.  The trouble with this is that the gain
> will vary depending on the setting of the offset pot, and the output
> will be nonlinear.  This may not be a problem, but I think you would be
> a lot better off using an inverting configuration.
You are correct and my post was in error the first opamp is inverting.
prose?  Tony M.

1997\03\25@014914 by Andrew Warren

face
flavicon
face
Tony Matthews <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU> wrote:

> > > can I toggle a configuration bit without creating artifacts on
> > > the other pins of that or any other port?
> >
> Andrew Warren wrote:
> >
> > Yeah, you can... It's easiest if you FIRST write to the port, THEN
> > write to the TRIS register immediately afterward.
> >
> Well then can I toggle that port by successive writes to the tris
> reg?

   Yes, but it's safest to always write to the port EACH TIME you
   change the TRIS register.

   -Andy

=== Andrew Warren - EraseMEfastfwdspam_OUTspamTakeThisOuTix.netcom.com
=== Fast Forward Engineering - Vista, California
===
=== Custodian of the PICLIST Fund -- For more info, see:
=== www.geocities.com/SiliconValley/2499/fund.html

1997\03\25@015538 by Andrew Warren

face
flavicon
face
Steve Hardy <PICLISTspamspam_OUTMITVMA.MIT.EDU> wrote:

> given that each of 4 outputs can be in one of 3 possible states,
> one could conjecture that it is possible to make a DAC with 3^4 =
> 729 [sic] possible output levels.  Is this possible in practice?
> Ignore the imperfections of the outputs - assume they are exactly
> 0V or 5V or infinite impedance, and your resistors and opamp are
> perfect. Is it possible to make a linear (not just monotonic) DAC?

Steve:

If it IS possible, I'd really like to know how... I spent about a
month trying to replace a 256-step switched attenuator network with
an arrangement similar to the one you describe.

The best "solution" I found was one that used 12 voltage dividers
(which would have allowed 4096 possible output values in the
configuration we were using) and discarded a bunch of values in the
range... We ended up with 256 well-chosen (through exhaustive
computer simulation) steps that were SORT OF linear, but not close
enough for our application, so we gave up.

-Andy

=== Andrew Warren - @spam@fastfwdKILLspamspamix.netcom.com
=== Fast Forward Engineering - Vista, California
===
=== Custodian of the PICLIST Fund -- For more info, see:
=== www.geocities.com/SiliconValley/2499/fund.html

1997\03\25@063338 by Keith Dowsett

flavicon
face
At 13:43 24/03/97 -0500, you wrote:
>Hello
>I would like to simplify a four bit d/a that I'm using portb 4-7 to
>emulate I have each pin connected to a diode then a resistor this in
>turn draws current from the noninverting side of a voltage follower
>configured opamp this in turn causes the output to swing + to compensate
>and the inverting output is connected to a pot to provide the initial
>offset simple right? only I figure if I change the port pins from low to
>high impedance I can dispense with the diodes right? What sort of morass
>am I wading into firmware wise I mean the port is allready working hard
>but is configured as an output and I have no experience changing
>individual pin configurations. Generally I configure b out a in and
>leave it at that but...anyway.oh yeah 16c84 xt mode 100khz line powered
>.R2R increases the part count (discrete's) and space is as usual at a
>premium.can I toggle a configuration bit without creating artifacts on
>the other pins of that or any other port?The data book explains how I
>suppose but is not to clear on the downside . respects Tony M.

The biggest problem with this scheme is the usual BSF/BCF nuisance. If the
bits configured as inputs are 'low' when a BCF or BSF is issued they will be
cleared. Thus you will need to write 0xf? to the port before you change the
ADC value.

The code will probably look something like this...

Update_ADC      movf    PORTB,W         ; Assumes no pins forced high/low
               iorlw   0xF0            ; Set B7..B4
               movwf   PORTB
               swapf   Adc_value,W     ; Get new value in high bits
               bsf     STATUS,RP0      ; Go to page 1
               movwf   TRISB
               bcf     STATUS,RP0      ; Back to page 0

I've assumed that none of the port B pins are being forced high/low,
otherwise you will have to mirror the port in RAM and write that value
instead. I've also assumed that your ADC value is stored in the low nibble
of a byte with zeroes in the high nibble.

Hope this helps,

Keith.

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

E-mail: KILLspamkdowsettKILLspamspamrpms.ac.uk
  WWW: http://kd.rpms.ac.uk/index.html

1997\03\25@104422 by Tony Matthews

flavicon
face
Keith Dowsett wrote:

{Quote hidden}

It does help ...It helped me to decide to keep the diodes and use the
program space for aught else.I think the page swapping buisness was the
proverbial straw Thanks to all who replied to my post. Tony M.

1997\03\25@110102 by Keith Dowsett

flavicon
face
At 10:45 25/03/97 -0500, you wrote:


>It does help ...It helped me to decide to keep the diodes and use the
>program space for aught else.I think the page swapping buisness was the
>proverbial straw Thanks to all who replied to my post. Tony M.

If you want to avoid swapping pages you could always use the FSR register.
If you're not using it already you could just set it to point to TRISB
permanently. That way you just write to INDF all the time.

I tend to avoid swapping pages because it saves me space on the interrupt
handler. I just save the FSR register if I plan to use it during the
interrupt service routine. I guess I save several words on the interrupt
service routine at the price of 1 byte of RAM. However I would probably have
to save FSR anyway, so it's no real hardship.

Just my personal preference,

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

E-mail: spamBeGonekdowsettspamBeGonespamrpms.ac.uk
  WWW: http://kd.rpms.ac.uk/index.html

1997\03\25@222232 by Tony Matthews

flavicon
face
<snip>
gotcha I ...think 8) thanks.

1997\03\27@222835 by sdattalo

face
flavicon
face
Steve Hardy wrote:

> Now a question for you gurus: given that each of 4 outputs can be in
> one of 3 possible states, one could conjecture that it is possible to
> make a DAC with 3^4 = 729 possible output levels.  Is this possible in
                       81
> practice?  Ignore the imperfections of the outputs - assume they are
> exactly 0V or 5V or infinite impedance, and your resistors and opamp
> are perfect.  Is it possible to make a linear (not just monotonic)
> DAC?


Consider the op-amp circuit shown below:


                 +5V
                 ^
                 \    I0                   Rf
            2R0  /   --->         +------/\/\/\----+
          R0     \    R0          |   |\           |
   P0 --/\/\/\---+--/\/\/\--+-----+---|-\          |
                            |         |  \         |
                            |         |   \        |
                            |         |U1 /--------+--- Vout
               +5V          |         |  /
                ^           |    0V --|+/
                \     I1    |         |/
            2R1 /    --->   |
         R1     \   R1      |
  P1 --/\/\/\---+--/\/\/\---+
                            |
                +5V         |
                ^           |
                \           |
           2R2  /     I2    |
                \   --->    |
         R2     |    R2     |
  P2 --/\/\/\---+--/\/\/\---+
                            |
                +5V         |
                ^           |
                \           |
           2R3  /      I3   |
                \     --->  |
         R3     |    R3     |
  P3 --/\/\/\---+--/\/\/\---+

This circuit has an output voltage equal to:

Vout = - (I0 + I1 + I2 + I3)*Rf


Where Ix =

  Ix = 1*5V/(8Rx)   when Px=0V
     = 2*5V/(8Rx)   when Px=open circuit
     = 3*5V/(8Rx)   when Px=5V

Suppose we pick Rf = R3 = 3R2 = 9R1 = 27R0. Then the
output voltage is

Vout = -5/8*((1/3^3)*S0 + 1/(3^2)*S1 + (1/3^1)*S2 + 1*S3)
 Where Si = 1,2,3 for Px = 0,open,5

Here's a little table illustrating the first few values:
   P0    P1    P2    P3   Vout
---------------------------------
    0     0     0     0   -0.9259
   open   0     0     0   -0.9491
    5     0     0     0   -0.9722
    0    open   0     0   -0.9954
   open  open   0     0   -1.0185
    5    open   0     0   -1.0417

etc
    5     5     5     5   -2.7778

The annoying -0.9259V offset voltage is easily removable.
But the series is linear and monotonic, each step being
-23.15mV.

Perhaps someone else would be kind enough to check the
arithmetic...

Scott

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