Do I really need a current limiting resistor for charlieplexing?

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Which PIC are you using? Are you just doing a four digit display? And, are you going to skip the column driver transistors?

It's a refrigerator thermometer and alarm project.

I'm going to use a 18F14K22.


I will have 2 sets of 3 "digits" but 1 "digit" in each set will be a C or an F.

I'll need 2 pins for each display for a + and - led indicator.

One pin for a buzzer.

Three pins for buttons.

One pin for 2 one wire temperature sensors.

I think that leave me with no pins unless I want to use PGC, PGD or MCLR.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
OK I tried this out but it is not working. What is wrong?

Just kidding :)


I pretty much have the configuration above but I am only driving one display. And I hard coded the output pins for now.


My supply is 3V with a 3V pic. I have tried both 1K and 10K base resistors. I am using 2n3904 npn transistors. When I change my output pin to high the emitter voltage goes to 3V. When it is low the emitter is going to 1.5V so it never really turns off fully.

What am I doing wrong?

If I ground my emitter then I can get the segments to come on.

Also I connected the "cathode" pin direct to the cathode and I can light all segments. So do I really even need the transistor? Though they don't appear very bright when all all lite. Will experiment more tomorrow with one segment to see if there is a difference.
 
Last edited:

John P

Joined Oct 14, 2008
2,026
I suggest trying this out on a breadboard before controlling it with the processor. Just run wires to Vcc and Gnd and see if you can get the LEDs to light up/go out when you think they should. Then maybe you're ready to have the PIC run it.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
I think you should use 2n3906 for that circuit.
That is a pnp. MMClaren's schemetic shows npns.

And all of my pnps have gone temporarily missing. :)


PIC 16f54 powered. This could eliminate all these driving circuits.
All LED display pins wired directly to the PIC chip, carrier PCB smaller than the display.

But also not really easy to use.
I don't have any on hand. I have a bunch of 18f14k22s I want to use.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Wait a second I see the difference. MMClaren's displays are common anode. My displays are common cathode. My schematic is wrong.

I was scratching my head how this was going to work. That explains it.

Can I get this to work with common cathode displays?
 

MMcLaren

Joined Feb 14, 2010
861
Can I get this to work with common cathode displays?
Oops! Sorry! I always used common anode 7-segment displays when using "direct drive" because experiments many years ago showed there's less voltage drop on I/O pins when they're sinking current rather than sourcing current, which makes for slightly brighter displays.

Fear not, a common cathode Charlieplexed 7-segment matrix requires PNP transistors in emitter follower configuration in order to use the active low Charlieplex signal required for a cathode column. You'll also need to modify the software driver.

Let me see if I can find a drawing of the PNP cathode drivers for you... Wait a minute... Ok, a search turned up this drawing from many years ago. Not my best work. I hope it makes sense...



As far as software driver modifications... IIRC, you just need to invert the column select mask pattern written to PORTB. Please try the change highlighted in red in the code below;

Rich (BB code):
char disp[] = { 0,1,2,3,4,5 };  // display data, 0..9

#define r08 const rom unsigned char

r08 segdata[] = { 0b00111111,   // "0"   -|-|F|E|D|C|B|A
                  0b00000110,   // "1"   -|-|-|-|-|C|B|-
                  0b01011011,   // "2"   -|G|-|E|D|-|B|A
                  0b01001111,   // "3"   -|G|-|-|D|C|B|A
                  0b01100110,   // "4"   -|G|F|-|-|C|B|-
                  0b01101101,   // "5"   -|G|F|-|D|C|-|A
                  0b01111101,   // "6"   -|G|F|E|D|C|-|A
                  0b00000111,   // "7"   -|-|-|-|-|C|B|A
                  0b01111111,   // "8"   -|G|F|E|D|C|B|A
                  0b01101111 }; // "9"   -|G|F|-|D|C|B|A
Rich (BB code):
void interrupt()                // 1-mS TMR2 interrupts
{ static char colsel = 1;       // column select bit mask
  static char column = 0;       // column number, 0..5
  unsigned char data;           //
  pir1.TMR2IF = 0;              // clear timer 2 interrupt flag
 /*                                                                 *
  *  refresh the CC display (~166 Hz refresh rate)                  *
  *                                                                 */
  data = segdata[disp[column]]; // new digit segment data
  trisb = 0xFF;                 // blank the display
  portb = ~colsel;              // select new column (digit)
  if(data & colsel)             // if LED row = column
    data.7 = 1;                 // set the 'float' pin (RB7)
  data |= colsel;               // pick up column select bit
  trisb = ~data;                // display new column (digit)
  if(colsel.5)                  // if last column (RB5)
  { column = 0;                 // reset column number
    colsel = 1;                 // reset column select bit (RB0)
  }
  else                          // else
  { column++;                   // increment column number
    colsel <<= 1;               // shift column select bit
  }
}
 

Attachments

Last edited:

takao21203

Joined Apr 28, 2012
3,702
That is a pnp. MMClaren's schemetic shows npns.

And all of my pnps have gone temporarily missing. :)

I don't have any on hand. I have a bunch of 18f14k22s I want to use.
For CC you need NPN. Because the base voltage needs to be higher than the collector voltage.

For CA you need PNP. Because the base voltage is negative.

Transistors aren't too good for this anyway- need so many resistors. Use digital MOSFETs- no resistor needed.

And if you insist on the 18f14k22- use one serial buffer for the Anode drive, and wire the segments to a port. If you have the anodes OFF, you can also multiplex the port for other use.

Isn't a good chip for LED displays, unless you use serial drive.
 

MMcLaren

Joined Feb 14, 2010
861
If you can't find your PNP's, would you like to try it without transistors? It would mean driving the display one segment at a time instead of one digit at a time for a much reduced duty cycle and a significant decrease in brightness. But then it's pretty amazing how much brightness you can get out of these modern displays with very low "average" current per segment. For example, here's a "direct drive" display (no transistors) lighted one segment at a time with about ~1-mA "average" current per segment (1/32nd duty cycle);



Anyway, if you think you'd like to try it just for fun, let me know and I'll see if I can whip up a driver for you.

Happy Holidays. Mike
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
But if I use transistors won't I need to have one on each segment as opposed to just the cathodes?

What does PNP transistors do for me?



These are older low cost displays. I think I paid like $ .25 each for them.
 

MMcLaren

Joined Feb 14, 2010
861
But if I use transistors won't I need to have one on each segment as opposed to just the cathodes?
I'm not sure I understand your question. Let's see. If you drive the six digit display one column/digit at a time, you would want to use NPN 'source' drivers for a common anode display or PNP 'sinking' drivers for a common cathode display. You would normally use "direct drive" for the segments.

Now if you don't have any PNP transistors for your common cathode displays, perhaps you could drive the six digit display one row (and multiple columns) at a time instead of one column/digit (and multiple rows) at a time. In that case you would use eight NPN 'source' drivers for the anode rows and use "direct drive" for the cathode columns.

What does PNP transistors do for me?
Again, I'm not sure I understand your question.

The choice of NPN or PNP transistors is dictated by the displays you're using and how you intend to drive them. The Charlieplexing rules require that you use an active low signal to turn on a cathode and an active high signal to turn on an anode, and never the twain shall meet. If you were to try and use an NPN transistor in a Charlieplexed matrix to turn on a common cathode digit, you'd find that the active high signal required to turn on the transistor, which is also fed to a row of LED anodes, would not yield the results you want. That's why we use an active-low PNP emitter-follower to turn on a cathode column, or an active-high NPN emitter-follower turn turn on an anode column (rule: active low cathode, active high anode).

These are older low cost displays. I think I paid like $ .25 each for them.
Cool. How do they look?
 
Last edited:

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
I'm not sure I understand your question. Let's see. If you drive the six digit display one column/digit at a time, you would want to use NPN 'source' drivers for a common anode display or PNP 'sinking' drivers for a common cathode display. You would normally use "direct drive" for the segments.

Now if you don't have any PNP transistors for your common cathode displays, perhaps you could drive the six digit display one row (and multiple columns) at a time instead of one column/digit (and multiple rows) at a time. In that case you would use eight NPN 'source' drivers for the anode rows and use "direct drive" for the cathode columns.



Again, I'm not sure I understand your question.

The choice of NPN or PNP transistors is dictated by the displays you're using and how you intend to drive them. The Charlieplexing rules require that you use an active low signal to turn on a cathode and an active high signal to turn on an anode, and never the twain shall meet. If you were to try and use an NPN transistor in a Charlieplexed matrix to turn on a common cathode digit, you'd find that the active high signal required to turn on the transistor, which is also fed to a row of LED anodes, would not yield the results you want. That's why we use an active-low PNP emitter-follower to turn on a cathode column, or an active-high NPN emitter-follower turn turn on an anode column (rule: active low cathode, active high anode).


Cool. How do they look?
I think I understand now. PNPs to sink. That makes sense. basiclly same configuration except tie the emitter to +3V and the collector to my cathode?

I'll try to post a pic later.

Now where are those darn pnps I know I have a bag of them around here somewhere.
 

MMcLaren

Joined Feb 14, 2010
861
... basiclly same configuration except tie the emitter to +3V and the collector to my cathode?
No, that's not correct. Just make a few changes to your existing drawing; (1) use CC displays, (2) use PNP transistors, and, (3) tie collectors to ground instead of Vcc.



After comparing the CA drawing and the CC drawing you should realize you could design a general purpose board that could be used for either CA and CC displays since LED manufacturers usually use the same pinout for CC and CA displays of the same model. You would only need to stuff the board with (A) common anode displays and NPN transistors with collectors jumpered to Vcc, or, (B) common cathode displays and PNP transistors with collectors jumpered to ground. Pretty cool, huh?

Unfortunately, I'm not sure what kind of results you're going to get using 3 volts instead of 5 volts since I have always used 5 volts.

Regards, Mike
 

Attachments

Last edited:

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
No, that's not correct. Just make a few changes to your existing drawing; (1) use CC displays, (2) use PNP transistors, and, (3) tie collectors to ground instead of Vcc.



After comparing the CA drawing and the CC drawing you should realize you could design a general purpose board that could be used for either CA and CC displays since LED manufacturers usually use the same pinout for CC and CA displays of the same model. You would only need to stuff the board with (A) common anode displays and NPN transistors with collectors jumpered to Vcc, or, (B) common cathode displays and PNP transistors with collectors jumpered to ground. Pretty cool, huh?

Unfortunately, I'm not sure what kind of results you're going to get using 3 volts instead of 5 volts since I have always used 5 volts.

Regards, Mike
Yep got that figured out. And sadly it looks like these displays don't work so well at 3V.

Even with the cathode tied directly to ground the display is much more dim at 3v then it is at 5v. Add the transistor and it is too dim, especailly if I am going to multiplex.

I really wanted to use a button lithium. :(

Seems to work OK with 4.5 V

I have some 3 AAA cell holders. I might just go ahead and use them.
 

takao21203

Joined Apr 28, 2012
3,702
Are these green displays? 2 digits?

LED displays work pretty well from 2.4 volts, at least red one's.

If you can't get good brightness at 3 volts, your circuit is wrong.

Maybe you accidentially swapped collector/emitter.

I made a transistor tester. With 2 red LEDs!

For the NPN, the LED has direct connection to Vcc, and the NPN is between the cathode and ground. The base voltage is adjustable between Vcc and GND. If I ncrease it from GND to Vcc, the LED turns on.

This is how NPN is supposed to be used. Sometimes circuits also work when you swap collector/emitter.

PNP is the same but all backwards. Not electrons are transported but "holes". So you need a base voltage that is more negative than the LED anode.

Digital MOSFETs are better for low voltages. Or you can use LCX244, HC244, two bit lines in parallel. 1 IC would replace 4 transistors, and no resistors needed. An alternative if you don't want to use digital MOSFETs.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Yellow.

Like I said even without the transistors and the cathodes tied to ground, it is still pretty dim at 3V.

They are pretty old. I paid something line $.25 - $.35 each for them.

I thought yellow was supposed to have the lowest voltage drop of all the led colors. Maybe these are not so efficient.

I think I might use shift registers. I have experimented with this before and it works pretty well. Only thing I will wind up with a ton of extra pins on my pic. I might make it easy on myself and not wire all the SRs in series and just use the chip selects.
 

MMcLaren

Joined Feb 14, 2010
861
Sorry to hear about the dim displays. I should mention that the displays on that 4-digit "direct drive" board in post #31 are very bright and only cost $1.95 at Sparkfun, but, they have a multiplexed pinout so you can't Charlieplex them.

Please let us know if you'd like to discuss design ideas using shift registers or using serial-to-parallel driver ICs. I've done several designs over the years and my reduced I/O MacMux interface method is useful for small to medium size (500 LED) matrices.

If you're interested, here's a MacMux concept drawing and design (below) for a chap building a soccer scoreboard using high voltage multi-LED-per-segment common cathode displays. The Micrel MIC5891 source driver IC is especially well suited for high voltage displays with its 5v data inputs and separate 5v VCC and high voltage VBB supply inputs. This design uses six I/O pins for the interface and can drive the displays to full brightness with complete fade-to-black PWM brightness control.

Food for thought. Cheerful regards, Mike

 

Attachments

Last edited:
Top