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

Multiplexing LEDs
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Multiplexing LEDs
PostPosted: Fri Mar 06, 2009 12:02 pm     Reply with quote

Sydney wrote:
RLScott wrote:
Therefore we can conclude that the only way to multiplex these 12 diodes in the circuit shown is to select only one row and one column (one high, one low) and make every other PIC pin floating.


That statement is not true, as I expained.


Yes, I realized that in the edit I made. However your solution still does not address the issue of leaving a floating TTL input at .33Vcc or .67Vcc and drawing excessive supply current.
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 12:35 pm     Reply with quote

Quote:
However your solution still does not address the issue of leaving a floating TTL input at .33Vcc or .67Vcc and drawing excessive supply current.
Excessive is a relative property. Related to the current consumed by the LEDs itself, it may be neglectible, but would be a big problem with a battery operated PIC in sleep mode. Also, the inactive LEDs could be pulled to reverse polarity, still keeping the maximum reverse voltage of LEDs.

Because of the meaningless circle symbols representing the LEDs, I'm not clear about the nature of the two LED parallel circuit, it could be also antiparallel, driving both LEDs individually. In this case, pulling to reverse polarity wouldn't work, of course.

Necessity of current limiting has been already discussed, the maxium rating of +/-25 mA for I/O pins must be kept to avoid chip damage.
Sydney



Joined: 13 Feb 2009
Posts: 71

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 3:19 pm     Reply with quote

FvM wrote:
Because of the meaningless circle symbols representing the LEDs, I'm not clear about the nature of the two LED parallel circuit, it could be also antiparallel, driving both LEDs individually. In this case, pulling to reverse polarity wouldn't work, of course.


There is a symbol inside the circle, and yes they are inverse parallel Smile

FvM wrote:
neglectible


Good word!

Back on topic, the microchip app note shows how you can use 4 I/O to multiplex 12 leds, if you only wanted to switch one on at a time.

Being able to switch 3 on at a time, I only can see as an advantage assuming the pic will sink/source 60ma with a 1:5 or 2:5 duty cycle, I would give it a go, but I'm not sure if anyone can confirm?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Mar 06, 2009 4:22 pm     Reply with quote

Thanks for clarifying. A rather gloomy symbol.

Regarding multiplex schemes, the 25 mA pin current limit doesn't grant a higher peak current. Using the Microchip circuit, worst case duty cycle is 1:12, or 2.1 mA average current. With the original circuit and 1:4 duty cycle, you get the same average current, cause 25 mA have to supply 3 LEDs. No restrictions on simultaneous LED operation have been said, so 2.1 mA is the maximum in both cases. An 1:12 scheme could be also implemented with the present circuit of course. According to the calculation, it's not worse than switching multiple LED's simultaneously.

I don't know, what's the actual current without any resistor, but it's possibly too high. If resistors can be only connected at GP0/GP1, either the said 1:12 scheme or an 1:6 (*2) scheme would achieve constant brightness. I don't know about the application, but around 2 mA can be sufficient with blue LED.
test153



Joined: 09 Feb 2009
Posts: 28

View user's profile Send private message

PostPosted: Sat Mar 07, 2009 8:35 am     Reply with quote

So I think we can agree that driving 3 LEDs at once is not such a good idea. How about the last code I posted? I'm reposting the last code again with an minor modification to the delay part.

Code:

char command;
const long delay=1500; // How long each LED should be on - ~50Hz (1000ms/50Hz=20ms, 20ms/12leds~1.5, 1.5=1500us)

//===============================
void portReset() {
   output_float(PIN_A0);
   output_float(PIN_A1);
   output_float(PIN_A2);
   output_float(PIN_A4);
   output_float(PIN_A5);
}

void led1() {
   output_low(PIN_A0);
   output_high(PIN_A5);
}

void led2() {
   output_low(PIN_A5);
   output_high(PIN_A0);
}

void led3() {
   output_low(PIN_A1);
   output_high(PIN_A5);
}

void led4() {
   output_low(PIN_A5);
   output_high(PIN_A1);
}

//Next matrix line

void led5() {
   output_low(PIN_A0);
   output_high(PIN_A4);
}

void led6() {
   output_low(PIN_A4);
   output_high(PIN_A0);
}

void led7() {
   output_low(PIN_A1);
   output_high(PIN_A4);
}

void led8() {
   output_low(PIN_A4);
   output_high(PIN_A1);
}

//Next matrix line

void led9() {
   output_low(PIN_A0);
   output_high(PIN_A2);
}

void led10() {
   output_low(PIN_A2);
   output_high(PIN_A0);
}

void led11() {
   output_low(PIN_A1);
   output_high(PIN_A2);
}

void led12() {
   output_low(PIN_A2);
   output_high(PIN_A1);
}

void main() {
  enable_interrupts(INT_RA); // Enable interrupt
  enable_interrupts(GLOBAL); // Enable interrupt

command = 60;

while(1){
   if (command==48) { portReset(); sleep();}
   
   if (command>=49) { led1();}
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=50) { led2(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=51) { led3(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=52) { led4(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=53) { led5(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=54) { led6(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=55) { led7(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=56) { led8(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=57) { led9(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=58) { led10(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=59) { led11(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
   
   if (command>=60) { led12(); }
   delay_us(delay); // How long the LEDs should be on
   portReset();
}

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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