Let's Make Robots!

Common Anode (seven segment) display problem

Hello,

I am trying to figure out how 7led segment displays work, I got a few common cathodes and a few common anodes to test. Did the testing with the common cathodes, they seem to work properly. Now I wanted to try the common anodes, they worked, I changed something to my program and connection to make a dual display, and it doesn't seem to work anymore.

I checked my program hundreds of times, same for the connections, and I really can't figure out what's wrong.

The problem is that there are always 4 led's lit (d,e,f and g).

I tried to change the program to a very basic few lines, to check whether the display was working or not, but still the same results. I'll post these very few lines of code, as well as a very professional drawing of a part of the connection:

code contents (i left the heading and most of the comments to save space and useless reading):

/*

RC6 - Segment a
RC5 - Segment b
RC4 - Segment c
RC3 - Segment d
RC2 - Segment e
RC1 - Segment f
RC0 - Segment g

V1 - RA1
V2 - RA5

*/

main(){

PORTA = 0;  // reset the bits of port A

PORTC = 0;

TRISA = 0; // All of port A are outputs

PORTA = 0x2; // to check if the first display is working as it should

TRISC = 0x7F; //all of port C are inputs, meaning the anode display shouldn't be lit

}

Result: led's d,e,f and g are lit, together with the 4 LED's from the PICKit2 (because of the same connection internally, RC0 -> RC3)

I've been watching at it for a while now, but can't seem to fix it at the moment. Any ideas on what I'm doing wrong?

AttachmentSize
display.jpg61.45 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

As bdk6 points out the problem is with the leds on the pickit2 low pincount board. Even if you have 470 ohm resistors between the pins and segments they will stay lit due to a ground path through the other led and resistor. You could go up in resistor size but then the display may be too dim.
Alternatively a common cathode type display would eliminate this problem.
Removing the leds from the board would eliminate the problem also. Or start breadboarding your chip and circuit. You can put a header in the breadboard for the programmer and leave the lpc board in the drawer.

What bdk6 said is correct indeed! There's a current flowing through the display, from the V (RA1 pin) to RC3 to led and ground, so it doesn't matter, the status of the RC3, input or output.

I'll try attaching them to other pins.

I've heard that common anode's are better for the microcontroller, because of the 200mA current limit of the µcontroller. Not sure what other opinions on this are, but so far I prefer using them ^^

quote: "Removing the leds from the board would eliminate the problem also. Or start breadboarding your chip and circuit. You can put a header in the breadboard for the programmer and leave the lpc board in the drawer."

I will definitely have a go at this as soon as I find some spare time! Will save me a lot of trouble =)

Thanks for the quick replies, and happy holidays!

If the 4 LEDs on the pickit2 are connected to Vcc and the processor pin, then they are providing current to the common anode display.  I'm not familiar with the Pickit, but I suspect you have something lke this:

Vcc ---------|>| -vvvvv-------------| pic pin |-------- |>| display ---------------- GND

that will allow current to flow through BOTH LEDs on those 4 pins without the PIC even being there at all.

Try using different pins that don't have LEDs attached.

is a PIC programmer.