7 segment count error

Hi, I have an arduino Mega + MuX Shield 2+ LCD Display, and I want to use at least 7 common cathode and Common Anode 7-segments displays with a 220Ohm resistor . The problem happens when the 7 segments are counting, the numbers don't appear correctly, for example num. 2,4,6 turns on all segments, I think it is for the less power it has. I would like to know how can I power all 13 7-seg and the numbers appear correctly. i've connectet led to the outputs of BCD an I can see how the shield make random numbers when is displaying 2,4,6 and other numbers.

7x Common Cathode 7-seg: SC52-11HWA 6X Common Anode 7-seg: SA08-11EWA

http://postimg.org/image/q31byw2zh/ Schematic

http://textuploader.com/udfv Sketch

Hi, sketch and schematic?

PaulRB: Hi, sketch and schematic?

(I don't have enough space to put all the sketch here so click on the links on the top) I'm using MUX shield 2 pins as digital outputs to different BCD decoder. I've noticed that if i'm using the first line I/O 1 and I active any pin from the other lines, numbers will appear wrong in 7-seg, but if I only use one line the numbers will appear correctly.

Wow that is complicated!

Isolate the problem in the simplest possible circuit. Just the Arduino, one bcd decoder and one 7 seg. Same with the sketch: start with a blank sketch and add just enough to control the single display. Hopefully doing this will reveal the problem. If not, post the simple schematic and sketch.

Can I ask why your circuit is so complicated? Why the mix of common cathode and common anode? Why a bcd decoder chip for each 7 seg display, when a chip like max7219 can drive 8 digits? You could probably redesign this circuit with an Uno instead of a Mega, no mux shield, 2x max7219...

PaulRB: Wow that is complicated!

Isolate the problem in the simplest possible circuit. Just the Arduino, one bcd decoder and one 7 seg. Same with the sketch: start with a blank sketch and add just enough to control the single display. Hopefully doing this will reveal the problem. If not, post the simple schematic and sketch.

Can I ask why your circuit is so complicated? Why the mix of common cathode and common anode? Why a bcd decoder chip for each 7 seg display, when a chip like max7219 can drive 8 digits? You could probably redesign this circuit with an Uno instead of a Mega, no mux shield, 2x max7219...

that's because i want to recreate a basketball scoreboard, the common anode are the local and visitors points (3 for each) and the others common cathode are for time possession(I bought common anode becouse of yes, it was my fault ), fault counter, and period. If i use a MAX7219 i can't control the 7-segments for their specific function. and i'm using the shield becouse I need the outputs for the BCD decoders. I'll make a new sketch and post here.

Thanks for answering

I don't understand. Why not stick to all common anode or all common cathode? What function do you believe the max7219 can not support? I understand why you needed the max shield for all those bcd decoders, but you would not have needed it in the first place with max7219.

PaulRB: I don't understand. Why not stick to all common anode or all common cathode? What function do you believe the max7219 can not support? I understand why you needed the max shield for all those bcd decoders, but you would not have needed it in the first place with max7219.

With the max7219 can i put it in any pin of the arduino or it has to be in a specific pins?(I'm going to buy 2 if I can put them in any pin) Is this the co Thanks a lot. Is this the correct max7219 for common cathode?: http://www.ebay.es/itm/IC-MAXIM-MAX7219CNG-MAX7219-24-DIP-leds-arduino-raspberry-PIC-prototipos-/261827617901?pt=LH_DefaultDomain_186&hash=item3cf624646d I found it in different prices, from 1€ to 7 or 8€ And if I use 2 max7912 i'll be able to control 7-segments display separately?

That is a "fake" max7219. The more expensive ones are probably the genuine maxim chips. However, the "fake" chips seem to work great for most people most of the time. I have not had any problems with the fake ones I have used.

All max7219 are designed to work with common cathode. However they will work with common anode also. It it is a little tricky, but it can be done and there are forum members who can help you.

You can use any Arduino pins. It is faster with the dedicated spi pins, but this is only an advantage if you need a large number of max7219. For only 2x max7219 it makes no difference.

You can "daisy-chain" your 2x max7219 so that they share the same Arduino pins.

Max7219 allows you to control each segment of each display as you choose.

PaulRB: You can use any Arduino pins. It is faster with the dedicated SPI pins, but this is only an advantage if you need a large number of max7219. For only 2x max7219 it makes no difference.

The only possible reason why update speed matters for a MAX7219, would be where you are animating a "Times square" scrolling matrix display, or if some other part of the system requires critical timing. For a scoreboard, this is unbelievably irrelevant - except perhaps for the "special effects" which you can perform - numbers "sliding" in or chasing around the 7-segments - and for only a few digits this also is no problem at all.

In fact, a good reason not to use the SPI for the MAX7219 is that you may want to use it for something much more important. :grinning:

The MAX7219 is eminently capable, there are no limits to the patterns it can display. The only reason not to use it is where you require massively increased currents such as to drive 1W LEDs per segment.

In fact, a good reason not to use the SPI for the MAX7219 is that you may want to use it for something much more important.

That's the best reason To use it! Crank the SPI speed to 8 MHz, and use the minimal amount of time needed to send data to the MAX7219 so more time can be spent doing other things.

CrossRoads:
Crank the SPI speed to 8 MHz, and use the minimal amount of time needed to send data to the MAX7219 so more time can be spent doing other things.

Again, that really depends on the balance of functions in your program. A visual display represents a very slow interface really, so if something was more active than the display, it should have “first dibs” on the SPI resource, whilst if something was less active than the display it clearly has no great need for it, but neither does the display anyway. :grinning:

PaulRB: That is a "fake" max7219. The more expensive ones are probably the genuine maxim chips. However, the "fake" chips seem to work great for most people most of the time. I have not had any problems with the fake ones I have used.

All max7219 are designed to work with common cathode. However they will work with common anode also. It it is a little tricky, but it can be done and there are forum members who can help you.

You can use any Arduino pins. It is faster with the dedicated spi pins, but this is only an advantage if you need a large number of max7219. For only 2x max7219 it makes no difference.

You can "daisy-chain" your 2x max7219 so that they share the same Arduino pins.

Max7219 allows you to control each segment of each display as you choose.

Wednesday I'll post my experience with the 2 max7219 after testing them on my sketch. If i'm right, to control 2 max7219 i only ave to connect Dout of the first max to Din of the other max. but if I only want to send an instruction to the second max how can i do it? I've searched on google and forums but I haven't understood how it works.

Is correct the schematic?: |500x313 (UPDATED)

Thanks for all guys!

Knela: If i'm right, to control 2 max7219 i only ave to connect Dout of the first max to Din of the other max.

Correct. The clock and latch/load lines go to both chips in parallel.

Knela: but if I only want to send an instruction to the second max how can i do it? I've searched on google and forums but I haven't understood how it works.

There are two approaches. 1. Always update both chips each time. Its probably a good idea to keep a copy of the data to be displayed, on all your digits, in an array in your sketch. Write a function to send the entire array out to both chips. Each max chip contains two 8-bit shift registers. You send the instruction to one and the data to the other, for example the instruction might be "display the following data on digit 3" followed by the digit to be displayed. Then, before you tell the chip to accept/latch/load that data, you send another 2 bytes. As you send the second 2 bytes, first two bytes get transferred to the second chip. When all 4 bytes have been send, you then tell both chips to accept/latch/load the data. 2. There is a "null" command that you can send in the same way as above, so that if you want to update the first chip without disturbing the second, or vice-versa, you can send a null instruction. With two chips wired in series like this, you must always send 4 bytes before you tell both chips to load the data.

Knela: Is correct the schematic?:

Hmmm... hard to be sure as many things are not labelled, and the resolution is not very good. Can you get your schematic editor to label the pins with their names instead of their pin numbers?

Things to point out: 1. You should add a 0.1uF cap and a 10uF cap close to the power pins of each max chip. 2. Aren't some of your digits common-anode? If so, you have them wired to the max chips incorrectly. Your diagram would be correct if they were all common-cathode. As I said earlier, the max chip was designed for common-cathode displays, so the pins labelled "seg" should be connected to anodes and the pins labelled "dig" should be connected to cathodes. When using common-anode displays, you must still connect anodes to "seg" pins and cathodes to "dig" pins, even though this feels "wrong". 3. Not sure what is going on in the top-left of the diagram?

PaulRB: Correct.There are two approaches. 1. Always update both chips each time. Its probably a good idea to keep a copy of the data to be displayed, on all your digits, in an array in your sketch. Write a function to send the entire array out to both chips. Each max chip contains two 8-bit shift registers. You send the instruction to one and the data to the other, for example the instruction might be "display the following data on digit 3" followed by the digit to be displayed. Then, before you tell the chip to accept/latch/load that data, you send another 2 bytes. As you send the second 2 bytes, first two bytes get transferred to the second chip. When all 4 bytes have been send, you then tell both chips to accept/latch/load the data. 2. There is a "null" command that you can send in the same way as above, so that if you want to update the first chip without disturbing the second, or vice-versa, you can send a null instruction. With two chips wired in series like this, you must always send 4 bytes before you tell both chips to load the data.Hmmm... hard to be sure as many things are not labelled, and the resolution is not very good. Can you get your schematic editor to label the pins with their names instead of their pin numbers?

Things to point out: 1. You should add a 0.1uF cap and a 10uF cap close to the power pins of each max chip. 2. Aren't some of your digits common-anode? If so, you have them wired to the max chips incorrectly. Your diagram would be correct if they were all common-cathode. As I said earlier, the max chip was designed for common-cathode displays, so the pins labelled "seg" should be connected to anodes and the pins labelled "dig" should be connected to cathodes. When using common-anode displays, you must still connect anodes to "seg" pins and cathodes to "dig" pins, even though this feels "wrong". 3. Not sure what is going on in the top-left of the diagram?

1) I've found this library "LedControl", wich one do you recommend me to control max7219? 2) I've changed the common anode and now i have all displays common Cathode. 3) The 7Segment on the top-left i put there becouse I don't have enough pins of max7219, so I decided to use 4 random pins of the arduino.

Knela: 1) I've found this library "LedControl", wich one do you recommend me to control max7219?

Yes, you can use this library. Or not. I learned to use max7219 using an mcu that was not Arduino and there were no libraries possible. So I learned to use max7219 without libraries, and I know that it is not so difficult.

Knela: 2) I've changed the common anode and now i have all displays common Cathode.

Have you purchased new displays, or had you not yet purchased the common anode displays, only planned to?

Knela: 3) The 7Segment on the top-left i put there becouse I don't have enough pins of max7219, so I decided to use 4 random pins of the arduino.

OK, but it will be difficult to match the brightness of this digit to the other digits.

PaulRB:
Yes, you can use this library. Or not. I learned to use max7219 using an mcu that was not Arduino and there were no libraries possible. So I learned to use max7219 without libraries, and I know that it is not so difficult.Have you purchased new displays, or had you not yet purchased the common anode displays, only planned to?OK, but it will be difficult to match the brightness of this digit to the other digits.

I’ve bought 6 common cathode 7s replacing the common anode 7s.
One question, is more easier programming the max7219 individually or with daisy-chain.
I’m newer on arduino programming.

No, I do not think daisy-chaining the chips makes programming more difficult. For your project I do not think using the ledControl library makes programming significantly more easy.

Have you thought about power supply? Driving 17 displays on full brightness will need more current than the usb cable from a pc can supply. The 16 displays connected to the max chips could draw up to 640mA, plus current for the 17th display, the lcd(s) and thd Arduino. I think you will need a 1A supply. It would be more efficient to get a 1A 5V switch-mode supply, compared to a 7 to 12V supply connected to the Arduino's barrel connector. That would waste half the power as heat in the Arduino's regulator.

Knela: One question, is more easier programming the max7219 individually or with daisy-chain.

No.

Much easier to daisy-chain - the code is much simpler - just as PaulRB explained in answer #12.

I also see no reason to use libraries - or as I said, the SPI - there is just no need for speed with these displays.

I note you are not driving the decimal points. In that case, you can use a common anode display for the 17th (and 18th if you like) display with its anode connected to the decimal point line, and its segment cathodes connected to each of the digit cathodes.

How's that? :grinning:

Paul__B: you can use a common anode display for the 17th (and 18th if you like) display with its anode connected to the decimal point line, and its segment cathodes connected to each of the digit cathodes.

How's that? :grinning:

Clever! Makes the sketch a little more complicated, but we can help you with that. Saves a whole other chip, and solves the brightness matching problem.