MAX7219 Directions

Well as the days go on, I always have a project going then get bored and want to carry on with my experiance. I remember a few months ago when I was posting really idiotic comments. Ahhaa that made me chuckle just then infact. I think the most complex circuit I have made is either the OLED screen, or a binary counter which was really cool.

Recently I saw some sales at maplin for a bargraph LED arrangement, as I had some spare change I bought a couple and believe it or not it turned out to be one of the most fancyiest components I had in my box of many other types. I played around and made many codes not really understanding any think differant to what I alreadu knew...

Codes I first made:

10 Bit binary counter for 20M2
Code:
Init:
high 0,1,2,3,4,5,6,7,8,9
pause 500
low 0,1,2,3,4,5,6,7,8,9
pause 500
high 0,1,2,3,4,5,6,7,8,9
pause 500
low 0,1,2,3,4,5,6,7,8,9
pause 500
high 0,1,2,3,4,5,6,7,8,9
pause 500
low 0,1,2,3,4,5,6,7,8,9
pause 500


main:
low 0,1,2,3,4,5,6,7,8,9
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
gosub first8
gosub first9
gosub first10
stop


first1:
high 0
pause 1000
return


first2:
low 0 high 1
pause 1000
gosub first1
return

first3:
low 0,1 high 2
pause 1000
gosub first1
gosub first2
return

first4:
low 0,1,2 high 3 
pause 1000
gosub first1
gosub first2
gosub first3
return
 
first5:
low 0,1,2,3 high 4
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
return

first6:
low 0,1,2,3,4 high 5
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
return

first7:
low 0,1,2,3,4,5 high 6
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
return

first8:
low 0,1,2,3,4,5,6 high 7
pause 1000 
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
return

first9:
low 0,1,2,3,4,5,6,7 high 8
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
gosub first8
return

first10:
low 0,1,2,3,4,5,6,7,8 high 9
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
gosub first8
gosub first9
return

And A simple experimental code I made:
Code:
Main:

gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub rollacross
gosub loadlike
gosub loadlike
gosub scan
gosub scan
gosub scan
gosub scan
gosub scan
goto main



rollacross:

high 0,9
pause 100
low 0,9
high 1,8
pause 100
low 1,8
high 2,7
pause 100
low 2,7
high 3,6
pause 100
low 3,6
high 4,5
pause 100

low 4,5
high 3,6
pause 100
low 3,6
high 2,7
pause 100
low 2,7
high 1,8
pause 100
low 1,8

return



loadlike:

high 0
pause 500
high 1
pause 500
high 2
pause 500
high 3
pause 500
high 4
pause 500
high 5
pause 500
high 6
pause 500
high 7
pause 500
high 8
pause 500
high 9
pause 500
low 0,1,2,3,4,5,6,7,8,9
pause 500
return


scan:
high 0
pause 200
low 0
high 9
pause 200
low 9 
high 1
pause 200
low 1
high 8
pause 200
low 8
high 2
pause 200
low 2
high 7
pause 200
low 7
high 3
pause 200
low 3
high 6
pause 200
low 6
high 4
pause 200
low 4
high 5
pause 200
low 5
pause 700
return

Any way back to the point. Like I said I managed to get a LCD screen working which was pretty cool. But due to my liking of the bar graph I wanted to experiment with a 8 x 8 dot matrix and display a 1,2,3,4,5,6,7,8,9 counter or something small but really awesome to watch. I was originally going to connect them all the IO ports of my 20M2 but that wasn't very challenging ;).

I thought of using the MAX7219 which looks very difficult to use :/ I tried looking through many forums and it explains why it is so hard etc... (Power, expensive...) Any way, I saw some one who said that another member of the site created a post to help people like me but I cannot find it any where! Could some one give me a little help at all I have never had experience controlling a chip like this with a PIC I have never successfully been able to do it ever believe it or not :l (well apart from a 555 and a 4017 ;) ).


Thank you all, I will one day make it to the finished zone! Trust :D
 

MartinM57

Moderator
Post #5 here, puts the digit test (all 8's) on a MAX7219. You can then build up on that...
http://www.picaxeforum.co.uk/showthread.php?17637-Max7219-Cascade&p=161214&viewfull=1#post161214

The data sheet mainly shows how to uses them for 7 segment displays rather than 8x8 dot matrix. You will have to work out how to use them (or find a circuit elsewhere) for dot matrix...and there will be a lot of wiring to get exactly correct. They are a bit complex to get right, but once you've sussed them put they're not too bad.
 

g6ejd

Senior Member
Hi, the 7219 looks quite easy to drive, assuming you have connected it to a set of common seven-segment displays and a series of display selectors as per data sheet. All you need to do is drop one of your pins low to enable the device (CS-- Chip Select), then shiftout data to a pin (DIN), 1 bit at a time, then toggle the clock pin (CLK) to get the bit in the 7219, then repeat that 8-times for 1-byte, make that a sub-routine. The rest of it, is determining the codes for the display, so how to address sub-displays, for example #3 seven-segment unit for example, there must be a command table somewhere that tells you what to send to get to the right place, then send your data for display, all using the send-data subroutine.

That's a challenge for you!
 
Ok, Not going to lie to you all, but I am not that experienced :/ Would it just be easier to control it with a long piece of code? Then set strings or some think ? I really have no idea what to do with all these really weird commands they use and I think they even use hexadecimal in them? I am only 15 years of age and all of my work is completely done through myself. Sorry for the rudeness of this reply but is there any sort of guide or simpler version of the datasheet where 'noobs' like me will be able to understand?

Thank you all for helping me out and if any one has an idea of of a small project please let me know ;) I have loads of equipment just don't know what to make :p Thanks again!

Trevor B
 

inglewoodpete

Senior Member
Thank you all for helping me out and if any one has an idea of of a small project please let me know ;) I have loads of equipment just don't know what to make :p Thanks again!
You can control an 8x8 LED matrix with just a 20M2 and a few transistors and resistors. (Actually, the 20M2 only has 15 outputs, so you will only be able to control 7x8 LEDS)

I presume you have a breadboard. A project like this can be built by going through a series of steps or stages. Each stage produces a result so you can see your progress as you go.

The first stage would be to connect each of your port B pins via a 330ohm resistor to a "Row" input (anodes) of the matrix. The resistors will limit the current flowing through the pin and prevent damage to the PICAXE.

Next, connect just 1 port C pin via a resistor to the base of a small signal transistor (BC308/348 etc). Actually, it needs to be wired like the diagram in Manual 1 Page 69 "Interface Circuit Summary", "Digital Outputs": except that the collector of the transistor must connect to a "Column" input (cathodes) of the matrix. If you output a byte of data to the port B pins and turn on the transistor via the port C pin, it should light the LEDs which connect to a port B pin that is set high.

Having successfully coded for the hardware setup above, you can add another resistor and transistor to another column of the matrix. However, when coding for two columns, you have to make sure that you only enable 1 column transistor at a time. If you pulse each column in turn, it is called multiplexing. Do it fast enough and it looks like both columns are "on" at the same time.

Edit: Once you have the basics of multiplexing working, you can work of honing your software skills by introducing scrolling to your matrix. Then using lookup tables to store different images.

At 15 years old, you have plenty of time in the future to master chips like the MAX7219. Leave that for the time being.
 
Last edited:
Thanks for the replies, it is much appreciated. I am still waiting for the led matrix to come from hong kong (its worth the wait then paying a lot more!) Any way I have been doing a lot of research now on led multiplexing and it gets quite complicated if you try and do it with like half the pins :S So i will create a lot of separate routines to make this work! ANy way i was looking at this video on youtube where he uses two multiplexes within an 8*8 project. So he could control all the leds with just 12 IO pins. Thanks for the help again and i will keep you updated with the progress! :)
Trevor B
other picaxe forum i accidently posted not realising I still had this one, sorry for the inconvenience:http://www.picaxeforum.co.uk/showthread.php?20040-Transistor-recommendation-(quick-question)&highlight=led+matrix
 
Ok, I have had a sudden urge to use this chip. DO you think any one could share a piece of code they used? I will buy a chip in a couple of days and what ever pic would be suitable I don't mind. I really want to do this and because doing this manually is going to be a lot harder in a differant way. Thank you all

Trevor Boultwood (Or if you see another post please link me :))
 
Top