Digital Outputs - On Off states

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Digital Outputs - On Off states

Post 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.

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Digital Outputs - On Off states

Post 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.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Digital Outputs - On Off states

Post 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:
Last edited by LeighM on Mon Sep 21, 2020 11:40 am, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Digital Outputs - On Off states

Post 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.
Martin

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Digital Outputs - On Off states

Post 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.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Digital Outputs - On Off states

Post 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

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Digital Outputs - On Off states

Post 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.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Digital Outputs - On Off states

Post 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 8414 times
Hope that helps

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Digital Outputs - On Off states

Post by Jay Dee »

Thanks Leigh,
Good to know.

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

Post Reply