Go Down

Topic: common cathode/common anode confusion (Read 4030 times) previous topic - next topic

epicycloid

Sorry for the beginner question, but I am very confused about which is easiest when working with an Arduino for things like 7-segment displays... common cathode or common anode? I don't seem to be able to find much helpful information with my searches to differentiate between the two. A little additional explanation in examples like the "ShiftOut" tutorial would be really useful for beginners. That said...

Is it easiest to use common cathode or common anode devices with an Arduino? Is there some simple explanation/example somewhere to help understand why one might be easier/better than the other when using an Arduino? (e.g. required external resistors vs. internal pull-ups, or overall power requirements to drive the LED segments, or less complicated programming logic)

I am sure this is also closely related to the equally confusing (to me) notion of "sinking" or "sourcing" from Arduino pins. In trying to read data sheets for devices like TPIC6B595's and 74xx595's, it is very hard for a beginner to understand why and when to select a common cathode or common anode type of device.

I am trying to figure out how to make a cascaded 4 digit counter, using 7-segment digits, but I'm stumped with what to order/buy to get going.

Any help or hints greatly appreciated,

--Jon

Grumpy_Mike

It is much easer to use common anode, there are many more support for this.
Current sinking is where you connect the anode to +5V and the output switches the ground.

markvr

I'm struggling with the same thing.  So to ask a beginner question...

On an arduino I have 10(ish?) 5v digitial outs, and a common ground.  If I connect a common anode to 5v, how do I switch the grounds?  e.g. on a common anode RGB led I have the anode and 3 pins.  Which would connect where? The anode to 5v presumably from your post below, but I only have 1 common gnd for the other 3?

kd7eir

The other three pins would connect to the pins that you are using to control them, such as pins 2,3,4.  For instance you might connect the red cathode to pin 2, green cathode to pin 3, and the blue cathode to pin 4.  You would then use analogWrite to send PWM values to those pins to control the intensity of the colors.

CrossRoads

#4
Feb 13, 2013, 06:15 am Last Edit: Feb 13, 2013, 06:34 am by CrossRoads Reason: 1
Quote
I am trying to figure out how to make a cascaded 4 digit counter, using 7-segment digits, but I'm stumped with what to order/buy to get going.

Easiest method is non-multiplexed shift registers, 1 for each digit.
Shift out the 4 digits you want displayed.
Common anodes to +5, segments pulled low by TPIC6B595 with current limit resistors, they will support the full brightness of the display.

After that, you start looking into multiplexing.
One way is to move all the shift registers into a part like MAX7219, which can drive 8 common cathode digits.
Or perhaps you move into a 4-digit 7-segment display. MAX7219 can drive that also if the part is a common cathode display.
Or perhaps you have common anode displays, the Arduino can control PNP transistors to control the anode, while a single TPIC6B595 sinks current from all the segments wired in parallel - set up the cathodes,turn on 1 anode, repeat for the other digits.
So many ways to get there...
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

markvr

@kd7eir - don't I then have the common anode connected to 5v, and the 3 RGB pins also connected to PWM doing 0 or 5v.  There's no ground....?

Grumpy_Mike


@kd7eir - don't I then have the common anode connected to 5v, and the 3 RGB pins also connected to PWM doing 0 or 5v.  There's no ground....?

Yes when the pin goes to 0V that is grounding it and the current flows. Do not forget to put a resistor between the cathode and the arduino pin, you always need a resistor when connecting LEDs direct to an arduino pin.

markvr

@Grumpy_Mike ah thanks I hadn't realised you could ground through digital pins that were at 0v.  Presumably that reverses the PWM i.e. analogWrite(pin,0) would put the channel at full brightness, and analogWrite(pin,255) would turn it off entirely?

Also can I put just one resistor on the common anode, rather than needing 3, 1 for each RGB pin?

CrossRoads

"Presumably that reverses the PWM i.e. analogWrite(pin,0) would put the channel at full brightness, and analogWrite(pin,255) would turn it off entirely?"
Exactly. Have +5 on the anode and +5 on the cathode will keep the LED off.

You can use 1 resistor on the anode if you only have 1 LED on at a time.
Otherwise, the current gets shared (unequally) between the LEDs and your brightness level will be really unequal - and possibly only the Red LED (typically it has the lowest Vf when turned on) will turn on and the Blue/Green will not turn on at all.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

xl97

All good points.

* you 'can' ground through an I/O when bringing it low/+0v   (bringing it HI = +5v)
* common anode PWM is reverse ( 0 = full on / 255 = off)
* put a resistor on each line/color that goes to a I/O pin..  (reds take less vF than other colors,, as mentioned..and you dont want to blow it)


(just regurgitating the common rules/stuff mentioned here already)


here is a wiring diagram to use for a visual reference:




epicycloid

Thanks CrossRoads for the pointers and ideas. As you say, so many ways to get there. But also very confusing for a beginner. I think I have read at least another 300 posts now (many, many of them with your answers in them!), and I'm starting to understand the issues a little better. I have now read a lot more about the 595's and MAX72xx's too.

In the case of multiplexing with the MAX7219, that sort of answers one of the original questions, as it only works with common cathode displays. But the other approaches like the 595's weren't so obvious with regard to CC/CA preferences or ease of use/programming.

My next dumb question is...

I am trying to match a device that has 0.3" 4 digit displays, but I haven't been able to find a similar 4 digit display in that size, and in fact the one I'm trying to match has discrete digits soldered onto its PCB. Given the way the MAX7219 works, it looks like I can just make my own 4 digit display, using discrete CC digits, and connecting them like the attached image (borrowed from Nick Gammon's page http://www.gammon.com.au/forum/?id=11516), creating my own 12-pin-equivalent part to multiplex from the MAX7219. No issues with that are there?

Thanks again for the help.



CrossRoads

Thanks, I have around here for a bit ;)

Yes. Connect all the anode segments in parallel, and keep the digit select/common cathode pins seperate per digit (your digit may have 2 pins for the common cathode, connect those together.

Here some other 4-digit displays
http://www.kingbrightusa.com/category.asp?catalog%5Fname=LED&category%5Fname=KC4%2DDigit+7%2DSegment+Thru%2DHole+Display&Page=1
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

epicycloid

Yes, I can see you've been around a while, but also your answers, no matter how dumb the questions, or how new the member, seem universally helpful and informative.

Thanks for confirming my approach.

Thanks also for the Kingbright link. I don't see any 0.3" displays on their site though. Right after I hit the last post, I continued my search for 0.3" 4-digit displays. It looks like Liteon makes one, http://media.digikey.com/pdf/Data%20Sheets/Lite-On%20PDFs/LTC-3710%20Series.pdf but it's non-stock at Digikey.

I'll have to keep poking around, or maybe just give up and use one slightly larger or slightly smaller. Or just use the single digit approach to make my own.

BTW, a comment I haven't read yet, but I'm sure has been made, is one of the features that makes the MAX7219 appealing for my application... the multiplexing handled by the chip doesn't bog down the Arduino. I need to send step signals to a stepper motor and want a pretty clean "loop", while displaying a pot setting on the 4-digit display (with an occasional analogRead and display update). Offloading the multiplexing to the MAX7219 seems like a real performance benefit of using that chip.

CrossRoads

Go thru the order steps anyway - often you can get a part anyway if you don't mind a short lead time.
It may come back with a huge min buy qty also, in which case keep looking!

Yes, MAX7219 does the multiplexing for you, just write the value to display to a register when something changes, and away you go.
I've used them to control 8 digits - but I only send data when one of the digits changes.
$1.25 at taydaelectronics.com (but parts arrive from a Colorado address - weird).
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

epicycloid

Now that I have done a lot more homework and reading, please allow me to re-ask my original question...

Is there some distinct reason to choose or prefer common cathode or common anode over one another?

Taking Grumpy_Mike's comments (since I never found a tutorial or simple example showing it) I wired up two LED's and tested the two possible configurations to better understand what's going on.

The attached schematic shows what I went back and did, mainly to educate myself... two LED's, one connected to 5V and one connected to GND, with respective resistors, and then a simple sketch to confirm that HIGH and LOW are used the reverse of each other to light the two LED's. Now I know how it works, and how the logic is inverted for the 5V connected yellow LED (LOW to turn it on). So now I understand (and confirmed with breadboard and sketch) how the two versions work.

But back to my original question, since I really don't understand sinking and sourcing, is one of these two options better/preferred for the Arduino architecture?

Also WRT Grumpy_Mike's comment about common anode availability, I'm no expert, but I see tons of both CA and CC devices out there (DigiKey, Mouser, Jameco), It's not so glaringly obvious to a beginner that one is more available than the other. Am I missing something?

Thanks again for helping me get some grasp of this.


(P.S. I used CircuitLabs to draw my schematic. What is everyone else using for schematics to post?)

Go Up