Searching \ for '[pic]: pic16F877 and RA4' 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=16F
Search entire site for: 'pic16F877 and RA4'.

Exact match. Not showing close matches.
PICList Thread
'[pic]: pic16F877 and RA4'
2003\01\23@170550 by rad0

picon face
Alright,

it's an open drain output, -what does that mean exactly, and what sorts of
things
do you do with it?

I've been scouring the Art of Electronics but I could not satisfy myself.
and btw, is this the opposite of sink, ?
I'm confused.
When you say something can sink 100mA, doesn't this mean it can
safely pass thru 100 mA?
And then open drain?


this has come about because I cannot get the LED to blink on this pin, RA4

I tried setting adcon1 to 6, and trisa to 0
but there is something else, or all my pics are damaged exactly the same
way.


thanks

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\01\23@171834 by rad0

picon face
nevermind, I found an answer by a google search.

how often does that happen...

if I understand this, this pin can never put out current(source),
but it can still be an output, if you supply the current, is this true?
or sort of the way of looking at this thing?


thanks



{Original Message removed}

2003\01\23@172850 by Jan-Erik Soderholm

face picon face
Look at figure 4-2 on page 40 in the PIC1687XA (DS39582A)
manual, and all should be perfectly clear.

If not, look also at figure 4-3 on the same page (RA5)...

(Hint, RA4 has only one transistor between the I/O pin
and ground, so the pin can only be "floating" or connected to ground,
but never connected to +5v. Drain =current *into* the I/O pin.
Source =current *out* of the I/O pin)

Also called "open-collector" in TTL speaking.

Jan-Erik Svderholm
S:t Anna Data

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\01\23@173302 by Olin Lathrop

face picon face
> it's an open drain output, -what does that mean exactly,

It can pull the voltage low but not high.  "Normal" outputs can pull in
both directions.  This means that if you set the open drain pin as an
output and write a 0 to it, it will go low like a normal output.  Writing
a 1 to it causes it to float to whatever the external circuit wants.

> this has come about because I cannot get the LED to blink on this pin,
RA4
>
> I tried setting adcon1 to 6, and trisa to 0
> but there is something else, or all my pics are damaged exactly the same
> way.

I doubt they are damaged.  To use RA4 to blink an LED, connect the LED
anode to +5V, the cathode to a 430ohm (or thereabouts) resistor, and the
other end of the resistor to the RA4 pin.  Set bit 4 of TRISA to 0 to make
it an output.  Now when you set bit 4 of PORTA to 0 the LED will go on,
and when you set bit 4 of PORTA to 1 the LED will go off.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\01\23@173512 by Olin Lathrop

face picon face
> if I understand this, this pin can never put out current(source),
> but it can still be an output, if you supply the current, is this true?

Yes.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\01\23@201324 by john chung

flavicon
face
Thanks to the guys that answer this question. Great info!

Olin Lathrop wrote:

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\01\23@212645 by Spehro Pefhany

picon face
At 04:03 PM 1/23/03 -0600, you wrote:

>this has come about because I cannot get the LED to blink on this pin, RA4
>
>I tried setting adcon1 to 6, and trisa to 0
>but there is something else, or all my pics are damaged exactly the same
>way.

Here's a good starting point for blinking an LED with RA4. When you
understand why the 4K7 is in there, you can probably write software
that allows you to leave it out. ;-)

                           Vdd
                            +
                  +---------+-----+
                  |               |
                  |              .-.
              Vdd |              | |470R
          .-------o-----.        | |
          |             |        '-'
          |             |         +--------+
          |  PIC        |    LED  |        |
          |             |         V /     .-.
          |             |         - /     | |
          |             | RA4     |       | |
          |          +--o----+    |    4K7'-'
          |          |  |    |    |        |
          |          |  |    +----+--------+
          |       ||-+  |
          |       ||<-  |
          |      -||-+  |
          |          |  |
          |          |  |
          |          |  |
          '----------|--'
                    ===
                    GND

(view in fixed-width font)


Best regards,

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

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\01\24@005154 by rad0

picon face
you've made me curious now...

is the 4.7K resistor there to prevent the pin from
'recieving' too much current when nothing is being done
on the pin?

(or maybe when the pin is floating...)

the 470 is there to take away current from the led

and I know that if you toggle the pin,
with only the LED and the 470, it will work

So, I guess, you have to maintain it in a 1 state to
keep it from taking in too much current....

I'm just guessing here

any help is appreciated, thanks




{Original Message removed}

2003\01\24@030528 by Jinx

face picon face
A LED and 470R to 5V ( 5V - R - a - k - RA4) will flash with a
simple on/off routine eg

tonlp    bcf     ra4        ;pin low, LED on
        clrf    count
        call    msdelay   ;1/4 second delay
        incfsz  count,f
        goto    $-2

        bsf     ra4            ;pin high, LED off
        call    msdelay
        incfsz  count,f
        goto    $-2
        goto    tonlp

The major difference between RA4 and other digital pins is
that it doesn't have a high-side P-channel FET. IOW, as an
output it behaves like a low-side switch, as in other applications
you'd use to control a relay for example. Not mentioned yet (I
don't think) is that V+ can be up to 12V on RA4. It's similar to
open collector TTL chips (eg 7406) that can have input pin
voltages > 5V

As an input RA4 leakage current is just 1uA, so a resistor much
higher than 4k7 could be used (with the proviso of sensitivity
to circuit noise). I normally use a hobbyist's friend - 10k - unless
the input source needs a particular value

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@043230 by hael Rigby-Jones

picon face
{Quote hidden}

The resistor is there to prevent Read-Modify-Write problems if you try to
set and clear RA4 directly using BSF and BCF instructions.  When you write a
logic '1' to pin RA4, the only thing that can actually make it move to a
logic '1' voltage is an external pull-up.  If the external pull-up has an
LED in series, then the maximum voltage the pin could be pulled up to would
be Vdd - Vf (forward voltage of LED which is typicaly around 2 volts).  From
a 5 volts supply this means the pin will be around 3 volts for a logic 1,
which is lower than the logic '1' threshold for most PIC inputs.  In actual
fact this won't cause problems if you are ONLY toggling that pin, but if you
try to change another pin on that port, the PIC will read that state of that
pin as a low and then write it back as a low, turning off the LED.  Putting
the extra resistor in ensures the when the pin is "high", the voltage on the
pin will be at Vdd.

Regards

Mike

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@081045 by Olin Lathrop

face picon face
{Quote hidden}

I don't see what purpose the 4.7Kohm resistor is serving either.

It will cause RA4 to float all the way to Vdd when off, making it easy to
see with a scope.  But, it would be better connected directly between RA4
and Vdd for that purpose, The LED would pull RA4 high enough to be easily
visible anyway, and I don't see how any software would make a difference.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@082718 by hael Rigby-Jones

picon face
{Quote hidden}

You could get bitten by the RMW issue without the extra resistor.  The
forward voltage accross the LED would bring the port voltage below a logic
'1' threshold.  RA4 has a Schmitt trigger input with a minimum input high
voltage of 0.8Vdd (for a 16F877 anyway).  0.8*5=4volts.  With a green LED
(Vf = 2volts), the level on the pin with the LED on would be Vdd-2.0 volts =
3 volts for a  5 volt supply.

If RA4 is set high (LED off) and a BCF or BSF operation performed on another
pin on PORTA, RA4 will be brought low (LED on).  The software can make a
difference by not toggling individual bits using BSF and BCF but by loading
the whole port for  a shadow register.

Connected as it is, it would use less power when the LED is on than a direct
connection to Vdd, but either connection would work.

Regards

Mike

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@112604 by rad0

picon face
alright,

I'm getting a little bit of this.  But I don't quite understand the circuit
behind this pin (RA4), but I think it's because I don't know anything
about the circuit behind the other pins either.
Is there an acronym for 'I will work on that'?

thank you jinx and sphero

and for the discussion below on the RWM stuff, I see this a little bit too,
as a programming example / consequence


thank you gentlemen

is the entire chip built just for the RA4, or is it just
nice to have one of these things?
-just kidding...

{Original Message removed}

2003\01\24@123241 by Spehro Pefhany

picon face
At 01:26 PM 1/24/03 +0000, you wrote:


>You could get bitten by the RMW issue without the extra resistor.  The
>forward voltage accross the LED would bring the port voltage below a logic
>'1' threshold.  RA4 has a Schmitt trigger input with a minimum input high
>voltage of 0.8Vdd (for a 16F877 anyway).  0.8*5=4volts.  With a green LED
>(Vf = 2volts), the level on the pin with the LED on would be Vdd-2.0 volts =
>3 volts for a  5 volt supply.
<snip>

Bingo! Precisely.
As to the value of the resistor- we'd like it to have minimal
effect on the brightness of the LED (in this case, the current difference
is around 10%, which is hardly noticeable). OTOH, we'd like not to have
to worry about leakage currents, but more importantly we need the voltage
on RA4 to be reliably pulled above the worst-case ST input voltage that
Michael mentions above between writing any "1" to the port and a possible
RMW operation on a different pin of the same port.

At 20MHz, we have 200ns between instructions. If we assume stray, output
and LED capacitance of 50pF, the time constant is 260nsec with 4700+470
ohms, so it's perhaps not low enough for pathological examples like:
       ...
        bsf     PORTA,4         ; turn LED 1 off
        bcf     PORTA,3         ; turn LED 2 on (oops LED 1 stays ON)
       ...

(you'd have to look at the Q states to see exactly how much time there is
here, but it's less than 200nsec). A NOP between would make it (sorta) right.

Needless to say, this is the kind of thing I'd not like to see in production,
esp. without specific testing,  I worry about the resistor being left out or
bad solder joint/faulty part, and the unit passing tests only to act
strange during some phases of the moon etc. Better to avoid RMW operations
entirely on port A, except possibly for RA4, and save the cost and worry
of the resistor. I've actually seen a circuit where they hung a 100K
pullup to Vdd on RA4 as a "fix", which just gives me the willies.

Best regards,

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

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@165239 by Jinx

face picon face
> I'm getting a little bit of this.  But I don't quite understand the
> circuit behind this pin (RA4), but I think it's because I don't
> know anything about the circuit behind the other pins either
> Is there an acronym for 'I will work on that'?


Er, RTFM ? ;-) Block diagrams of pins are in the manuals

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@173531 by Olin Lathrop

face picon face
>          bsf     PORTA,4         ; turn LED 1 off
>          bcf     PORTA,3         ; turn LED 2 on (oops LED 1 stays ON)
>         ...
>
> (you'd have to look at the Q states to see exactly how much time there
is
> here, but it's less than 200nsec). A NOP between would make it (sorta)
right.

I thought that outputs were written at the end of an instruction and
inputs were read at the beginning.  In that case there is 0 time between
the write and the read in this example.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@182001 by William Chops Westfield

face picon face
> I'm getting a little bit of this.  But I don't quite understand the
> circuit behind this pin (RA4), but I think it's because I don't
> know anything about the circuit behind the other pins either

You can think of the output stage of a logic gate (or a microprocessor pin)
as a set of switches.  Normally, there is one "switch" connected to V+, and
one connected to GND.  If the output produces a logic "high" state, the
switch to V+ is closed and the switch to GND is open.  For logic "low", the
switch to GND is closed and the switch to V+ is open.  The exact nature of
the "switches" determines the exact values of the output voltage and
available current in each state.  Normally, both switches are never closed
at the same time (but the fact that they'll probably be both partially on at
some point during transitions accounts for the power supply spikes and need
for bypass caps, along with other phenomena.)

Some output stages permit both switches to be turned off at the same time.
This is the 'tri-stated' output, where that gate isn't driving that output
pin/signal at all, leaving it free to be driven by other gates that might be
connected (also, pins that can be designated as inputs will typically have
their output stages tri-stated when they're set to be inputs.)

Other output stages are missing one of the switches (usually, the one to V+)
These are called "open collector" or "open drain", based on the internal
circuitry (OC if there are bipolar transistors, OD for MOS transistors.)
These outputs can only be switched to ground, or left disconnected.  There
are a couple of advantages to this:

1) Many gates like this can be connected externally, with an external
  resistor acting as a "pull up" to V+.  The external signal will go
  to ground if ANY ONE of the gates switches to GND, allowing you to
  implement buses and "wired or" configurations.  These were pretty
  common in pre-cmos days (the pdp11 unibus and qbus were "open collector"
  buses, I think.)  I gather that making a tri-state output with the
  processes used by (eg) TTL logic was a bit difficult.

2) You can take the die space that would have been used by the other switch
  of your output driver, and make the switch to ground bigger, instead, so
  that it can "sink" larger currents.

3) You can use the pin as an input at the same time, WITHOUT needing to
  disable the output state.  You set the output "high" (no swicthes on),
  and an input connected to the same pin will see HIGH or LOW depending
  on what external circuitry sends to the pin.  (On some micros, this is
  as close to bidirection IO as you get.  See the 8051 family.)

I thnk there's a couple others, but they don't come to mind at the moment.

BillW

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\24@191615 by Spehro Pefhany

picon face
At 05:33 PM 1/24/03 -0500, you wrote:
> >          bsf     PORTA,4         ; turn LED 1 off
> >          bcf     PORTA,3         ; turn LED 2 on (oops LED 1 stays ON)
> >         ...
> >
> > (you'd have to look at the Q states to see exactly how much time there
>is
> > here, but it's less than 200nsec). A NOP between would make it (sorta)
>right.
>
>I thought that outputs were written at the end of an instruction and
>inputs were read at the beginning.  In that case there is 0 time between
>the write and the read in this example.

The read is in Q2 and the write is in Q4, so there is one Fosc cycle between,
but with capacitive loading on the pin, the worst case propagation delay
from clock leading edge to output is 255ns (100ns typ), and the setup
time is 0. So, at 20MHz, worst case is -205nsec. Even one 200ns NOP won't
help us there. That's a 16F87x at 5V/25'C, presumably it degrades at higher
temperatures and at 4.5V.

Best regards,

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

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\25@142111 by Dwayne Reid

flavicon
face
At 05:33 PM 1/24/03 -0500, Olin Lathrop wrote:

>I thought that outputs were written at the end of an instruction and
>inputs were read at the beginning.  In that case there is 0 time between
>the write and the read in this example.

Nope - there is at least 1 Q period between them.  I say "at least 1"
because I have a hazy recollection that some PICs may have 2 Q periods
between reading inputs and writing outputs.  But worst case is 1 Q period.

dwayne

--
Dwayne Reid   <KILLspamdwaynerKILLspamspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

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