CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC output pins

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Einly



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

PIC output pins
PostPosted: Sun Dec 26, 2004 9:02 pm     Reply with quote

DEAR ALL,

I am thinking of controlling the brightness of an LED by using 3 pins of a PIC. Say I am shorting PIN C0, C1 and C2 and connect them to a LED.

1) If PIN C0, C1 and C2 are all 1s, what is the total current to the LEDs? Will it be 3 times the current if I only connect PIN C0 to the LED? Then will the LED be brighter?

2) However, if PIN C0, C1 are 1 and C2 are 0, will the supply shorted? Will it cause any problem?

3) Is my idea possible?
_________________
Einly
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sun Dec 26, 2004 9:35 pm     Reply with quote

Einly,

Your idea sounds feasible (and neat). There is a maximum current PIC can source/sink (for 18F452 it's 25/25 mA). If you short a pin with output_high to the pin with output_low, your LED will not light up, becasue the pin, which is output_low will sink all current. But you could make the pin an input, therefore high impedance, therefore it will not be sinking current. You can use output_float(PIN_XX) function for that.

e.g. : 1X brightness (assumption: you source current to the LED)
Code:

output_high(PIN_D0); 
output_float(PIN_D1);
output_float(PIN_D2);


e.g. : 2X brightness (same assumption
Code:

output_high(PIN_D0); 
output_high(PIN_D1);
output_float(PIN_D2);


Have fun,
Nick
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Dec 27, 2004 8:13 am     Reply with quote

Another way to get Ledīs brightness control is driving them with a square
wave changing itīs duty cycle. You save output PINs with minimum cost.

Humberto Very Happy
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

Do Not short the Output PINS!!!
PostPosted: Mon Dec 27, 2004 8:33 am     Reply with quote

Shorting ANY PIC pins with "totem pole" outputs will blow the PIC outputs when the pins are in opposing states!!!

This can happen even if you are careful because the PIC powers up in an indeterminate state. All it would take is a fraction of a second and the outputs are toast!

The square wave (PWM) LED drive mentioned by Humberto should do the trick for you and will provide continuously variable output..

You can also use a resistor ladder/divider combination off the three pins to create a variable voltage out if you only need a limited number of preset steps.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group