Max7219 Weirdness

tobyw

Member
Hello all

I'm using a MAX7219 LED/7 segment driver with a 18X.

When I download the program to the chip, it initialises the MAX7219 fine, and everything works great.

But if I disconnect the battery, and then reconnect it, the seven segments go blank, and nothing happens. It looks like the initialisation fails.

If I place a 500 ms pause in between every initialisation command, it works fine again on programming, and it also works on diconnect / reconnect. but after doing that... the display is much dimmer!

I'm sure there is a reason, but it beats me. And none of the sample code I have seen includes delays...

Anyone have any ideas about what might be happening?

I have a 10k resistor connected between Iset and GND. Code below....




Code:
symbol dout = 2
symbol cs = 3
symbol cl = 1

symbol outreg = b1
symbol outval = b0
symbol outword = w0

symbol bitcounter = b2

symbol tths    = b3		
symbol thos    = b4		
symbol hnds    = b5		
symbol tens    = b6		
symbol ones    = b7		
symbol counter = b8		

symbol n0 = %01111110
symbol n1 = %00110000
symbol n2 = %01101101
symbol n3 = %01111001
symbol n4 = %00110011
symbol n5 = %01011011
symbol n6 = %01011111
symbol n7 = %01110000
symbol n8 = %01111111
symbol n9 = %01111011

symbol decode = 9
symbol brite = 10
symbol scan = 11
symbol display = 12

pause 500

outreg = decode
outval = 0
gosub shiftout

pause 500

outreg = brite
outval = 10
gosub shiftout

pause 500

outreg = scan
outval = 0
gosub shiftout

pause 500

outreg = display
outval = 1
gosub shiftout

pause 500

 
main:
 for counter = 0 to 9	
  		
  	lookup counter, (n0,n1,n2,n3,n4,n5,n6,n7,n8,n9), outval
	outreg = 1
	gosub shiftout
	pause 100
  next counter	
 goto main

shiftout:
 low cs
 for bitcounter = 0 to 15
 	if bit15 = 1 then
  		high dout
  	else
  		low dout
  	endif
  	high cl
  	low cl
  	outword = outword * 2
  	next bitcounter
 high cs
 low cs
 return
 

nick12ab

Senior Member
(without checking your code...)
But if I disconnect the battery, and then reconnect it, the seven segments go blank, and nothing happens. It looks like the initialisation fails.
How long do you disconnect the battery for? Do you have decoupling capacitors fitted.

Where did you buy the MAX7219s? Are you sure they are not counterfeit?
 

tobyw

Member
Do you have decoupling capacitors fitted.
Bit embarrassing but I don't know what that means... is that like the capacitor on the datasheet suggested circuit...0.1uf between GND and VCC?

Where did you buy the MAX7219s? Are you sure they are not counterfeit?
Grrrr. Ok looks like this is the problem. I got it on ebay - although from a guy in UK, so I was hoping it would be kosher. Just checked the batch of 5 - 2 seem ok...3 just fail no connecting battery.

Thanks for the heads up. The half legs match the description in that thread too...so I guess it's the supply batch of duds. They are marked MAXIM Max7219CNG and underneath it says 0928. Also..there is a thin horizontal line marked across each IC... I don't suppose that is IC manufacturer shorthand for 'dud batch' is it?? :p

First time I've ever had a problem buying electronics from ebay. I only ever buy from UK people and this is the first time I've had a batch of duds.
 

nick12ab

Senior Member
First time I've ever had a problem buying electronics from ebay. I only ever buy from UK people and this is the first time I've had a batch of duds.
What seller did you use? Remember that there are many Chinese sellers who are Chinese but they store some items in a UK warehouse so they can proudly proclain "Ship from UK" in their listings. Sometimes they don't even do that - they sometimes just use express airmail once a week to ship everybody's orders to the UK then someone here posts the items individually (this is quicker than the usual abroad purchase). In any case, the usual giveaway is that on their feedback profile it will say Registered member since xxxxxx in China etc.
 

tobyw

Member
I've just checked the listing, and interestingly the image shown definitely shows the full pins and not the half pins which the ones I received have.

I have found that if I add a 3000ms delay to the beginning of my program, then it makes 4 of the 5 chips seem reliable after a power on. However, the 5th one still doesn't always initialise properly unless I add a 5000ms delay.

So I wonder if maybe the issue is my understanding of the chip? There were no delays built into the various example code snippets I have seen online - but I guess I can see why you might need one when you have a microprocessor talking to a register which is going to clear itself when it powers up.

As it is, the things are useable - they just seem a bit dodgy, and of course, that makes me wonder how long they will actually last before developing other faults..

I'd be interested to know if other people routinely include deliberate delays when using Max7219s...
 

MartinM57

Moderator
I'd be interested to know if other people routinely include deliberate delays when using Max7219s...
Definitely not. You can send commands as fast as any PICAXE can, with no delays between them.

Genuine MAX7219 chips plus the datasheet words about Supply Bypassing and Wiring are all I've ever needed (but have long abandoned MAX7219 for AS1107 - pin compatible with a few more commands as well, but I've never needed to use them - SOIC versions ... quite cheap in quantity from UK Mouser)

To minimize power-supply ripple due to the peak digit
driver currents, connect a 10μF electrolytic and a 0.1μF
ceramic capacitor between V+ and GND as close to
the device as possible. The MAX7219/MAX7221 should
be placed in close proximity to the LED display, and
connections should be kept as short as possible to
minimize the effects of wiring inductance and electromagnetic
interference. Also, both GND pins must be
connected to ground.
 

tobyw

Member
You can send commands as fast as any PICAXE can, with no delays between them.

Once the chip is 'warmed up' I don't need delays in between any commands, it just seems to need a few seconds after power on to reset itself before the microprocessor starts firing new commands at it. So I now just have a single 3000ms wait at the start of the picaxe code and then after that all commands are firing one after the other with no wait. Assuming nothing else goes wrong with it, I can kind of live with having to tell the picaxe to wait a bit before it starts talking to the driver. It's not ideal, but at worst, it means there are a few seconds delay before the display comes on. Considering it saves me about 9 quid a chip, I can't really complain!

That AS1107 seems worth a look - thanks for the info. I have a ceramic 1000pf capacitor between the power supply at the moment but I will add the electrolytic one and see if it makes much difference, though I doubt it will. I'm a total newbie at this, but it feels like maybe these dodgy chips are slow to 'wake up' - but I don't know why that would be in electronics terms.
 

MartinM57

Moderator
1000pF = 1nF = 0.001uF, so 100x too small compared with the data sheet. 100nF (0.1uf) is a pretty standard value for a noise reducing decoupling capacitor - you should get a bag of them :)

The data sheet 10uF is a local "power reservoir" capacitor - MAX7219/AS1107 etc take quite a lot of current (most of it going on its way to the LEDs) and the current draw changes almost instantaneously as the LED segments change. The 10uF (or larger, but not too large) helps to stop the "local power supply" i.e. the supply right at the MAX7219 power pins, from sagging too much as the current draw changes.

I use 100nF ceramic and 22uF tantalum surface mount capacitors with the AS1107 and have had no trouble at all

All bets are off with "dodgy" chips - mine wouldn't start up from cold but if I turned the power off then straight on again, they usually (but not always) would. It doesn't look good in the user manual though..."if the displays don't show anything when you switch the unit on, just turn it off and on again"
 

Pongo

Senior Member
I have several of those slightly different package 7219's in use without any problems so YMMV.

I second the requirement to put at least a 10uf right at the 7219 power pins to avoid its current spikes affecting the processor (and it's a bit worrying that the power source is a battery). Also (admittedly with the BS2 not picaxe so it may not be applicable here) I found that pulldown resistors are needed on the clock, CS and data lines to ensure reliable operation. IIRC 10K is suggested but I have used lower values.
 

westaust55

Moderator
Inclusion of the pull-up resistor on the CS pin is a good practice.

When the PICAXE chips first power up all pins are inputs (the microchip PIC default)
For earlier PiCAXE chips it still took a finite time for the firmware to establish the pins as outputs.
For the newer M2 and X2 parts first there is the time for the firmware to setup and then the users program must make the pin an output.

During this startup time the pins wired to the MAX7219 "CS" and "CLK" pins are floating and if CS appears low then garbage data can be clocked into the MAX7219 if the CLk pin (also floating) swings up and down.

Note to self: must get back to my partially written MAX7219 intro.
 

westaust55

Moderator
Inclusion of the pull-up resistor on the CS pin is a good practice.

When the PICAXE chips first power up all pins are inputs (the microchip PIC default)
For earlier PiCAXE chips it still took a finite time for the firmware to establish the pins as outputs.
For the newer M2 and X2 parts first there is the time for the firmware to setup and then the users program must make the pin an output.

During this startup time the pins wired to the MAX7219 "CS" and "CLK" pins are floating and if CS appears low then garbage data can be clocked into the MAX7219 if the CLk pin (also floating) swings up and down.

Note to self: must get back to my partially written MAX7219 intro.
 

kwass

New Member
I'd be interested to know if other people routinely include deliberate delays when using Max7219s...
I recently purchased a few 8-digit LED display's with an on-board Max7219 chip from a seller in China on ebay. I too found that the chip worked as specified but requires a 3000ms warmup period before it can be used. My program is entirely different form yours using a Parallax SX chip yet the results are the same. I can only conclude that the Max7219 is also a poor clone of the real thing.

However there's are some nice upsides compared to the genuine chip: The shutdown mode current draw is less than 1uA, virtually zero -- much better than the advertised 150ua advertised on the spec sheet. It works just fine down to 2.7 volts (or less). It's much less expensive.

My guess as to why this chip has a long warm up time is that the internal oscillator it uses to sequence the LED outputs has an extremely long start up time. Heating this chip to near 100 degrees C reduces the start up time to under 1000ms; cooling it lengthens this time; at 20 degrees C it's about 3000ms.
 
Last edited:
Top