Sinking output with 18f4550

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Sinking output with 18f4550

Post by liak » Sun Oct 21, 2007 1:52 pm

Dear all, I have a problem here. I have a device that will only operate when the 5V is sink to ground. As I know the 18f4550 will only output 5v when it is high. Is there any command / alternative way to do so? Please kindly advise. Thanks in advance.

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Sun Oct 21, 2007 3:13 pm

A PIC output pin can easily sink and source up to 25ma. Note that I used the term OUTPUT and not INPUT. You can sink and source when the pin is in OUTPUT mode only. When the output is low, or 0V, your load can sink through the PIC to ground. When the output pin is high, or Vdd (5V), you can source current to a load. When sinking you must be careful to limit the current not to exceed 25ma. You don't have to be as concerned when sourcing.

Look at the datasheet under IO PORTS and you will see that there are 2 FET's in the output, one P-channel and one N-Channel. The P-Channel FET turns on when its gate is low and effectively connects the output to Vdd, creating a source voltage and current. The N-Channel FET turns on when its gate is high and connects the output pin to Vss, creating a sink path to ground. This is only when the TRIS for that pin is set to 0, as output. When the TRIS is set to 1, as input, both output FET's are off. You cannot sink or source when the pin is set as input.

The output P-Channel FET inherently limits source current, a characteristic of FET's over a broad range of source-drain voltages. I made a video demonstration with an LED using no limiting resistors without damage to the LED (this is not the case if using a different source and sinking through the PIC pin... which can sink up to 80ma and damage both the LED and PIC):

http://www.youtube.com/watch?v=TaHPKWCeYAE

Post Reply