Page 1 of 1

Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 10:59 am
by Jay Dee
Hi,
Can any one clarify the generl digital output behaiour of a 5V PIC, I've strugled to find clarification in the data sheet. :?
I know there are a lot of specific bahaviour for certain pins but for a general purpose I/O pin

I'm setting the pin as a digital output to drive an LED and using FC component to toggle its state.
I think the bahviour is...
Output set to OFF will the pin Sink 25mA to ground.
Output Set to ON will the pin Souce 25mA to Vcc (5v).

or is this incorrent, it will only activly drive a single polatiry and I'm just measuring a weak internal pull up / down resistor somewhere?

Is there a better component for general toggling of digital pins?
Thanks for any help...got myself confused on this simple issue.
J.

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 11:05 am
by Jay Dee
If I do have status LED's attached, does it make sense to Source 5V from the Pin, grounding the other side.
The logic of the component does then tie up with the LED hardware.

I've gotten so used to old micros prefering to sink current, this alternative of high side driving feels odd. :)
J.

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 11:23 am
by LeighM
The outputs will source or sink up to 25mA (Output high/low)
This is a maximum, the PIC does not do the limiting, you still need a resistor in series to ensure 25mA is not exceeded.
(At this current the PIC output is going to be less than 5v)

Ah, someone else who remembers fun with NMOS processors :lol:

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 11:35 am
by medelec35
Jay Dee wrote: ↑
Mon Sep 21, 2020 10:59 am
Output set to OFF will the pin Sink 25mA to ground.
Output Set to ON will the pin Souce 25mA to Vcc (5v).
These is not correct.
If output is low then can only sink from VDD
If the output is high it can only source to ground.

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 11:56 am
by Jay Dee
Thanks,
yep.. Limiting resistors all in place. :)

So your average PIC micro generally does not have a preference over Sink or Source? :?

Have I gotten my sink and source terms confused then?
I thought;
If a pin can Sink current I thought it would act like a mini ground (Vss).
If a pin can source I thought it would act like a mini 5V (Vdd).

I think my previous experiance is misleading me..I've gotten so used to an active pin being pulled hard low.
The FC LED compoent, OFF drives the pin Low (near 0v) and ON drives the pin High (5v)
J.

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 12:02 pm
by LeighM
Output Set to ON will the pin Souce 25mA to Vcc (5v).
Presumably you meant "Output Set to ON will the pin Souce 25mA FROM Vcc"
Which would be correct

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 12:16 pm
by Jay Dee
I think my frame of reference is wrong somewhere...thats the problem of not learning this stuff academically.
I'm missing something but I dont have the technical vocabulary to explain the issue clearly.
I'll have to do some more googling. J.

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 1:09 pm
by LeighM
You are correct in that the PIC does not have a preference over Sink or Source, due to CMOS design
So when configured as an output, both low (0) and high (1) are active drivers
leds.jpg
leds.jpg (8.01 KiB) Viewed 10778 times
Hope that helps

Re: Digital Outputs - On Off states

Posted: Mon Sep 21, 2020 1:49 pm
by Jay Dee
Thanks Leigh,
Good to know.

And picture is worth a thousand words! :)
J.