28x1 and max7219 interpretation.

xtech007

Senior Member
Hi all! Finally received the max7219.
Been very quiet reading lots of post regarding the interface for the max7219 and picaxe.

Trying to interface an 8x8 led matrix.

Got code ideas from different post by Mr.westaust and many others.

Questions:
On some post for example they use:
Symbol decode = $09
On other for the same max7219
Symbol decode = 0xX9
Also mr westaust on the guide uses
Symbol =9

Also, when refering to decode i do not understand.. I have the data sheet in front of me and Mr Westaust guide, but will not sink. :mad:
Can anyone explaint it in lane terms for me.
 

hippy

Ex-Staff (retired)
$09 and 0x09 are both different ways of representing the same hexadecimal number and these have the decimal value of 9 so may also be expressed as a simple decimal.

Whether to use decimal, hexadecimal or even binary will depend on the author's preference and tastes and how the value is being used or what it represents.

The choice will usually be influenced by an intent to increase clarity of what the program is doing, how it interacts with or controls external hardware.
 

xtech007

Senior Member
Thanks hippy!

Hippy, thanks for that explanation!
I have read so many charts on ascii,hex, and binary charts I got confused!

Now, on the max7219 the register for decode is used for?
This is what the manual says:
The decode-mode register sets BCD code B (0-9, E, H, L, P, and -) or no-decode operation for each digit
"Huh"
Don't understand it.
Nor decode-mode or no-code operation.

Sorry for been so slow.
 

MartinM57

Moderator
Decode mode = the MAX7219 decodes the value you send it into the segment values needed to display what you sent e.g. you send a 1 and the MAX7219 lights the top right and bottom right segments to show a '1'; there's also some helpful symbols/letters if you send 10, 11, 12, 13 or 14 if I recall

No Decode mode = the MAX7219 takes the value you send it and interprets it as which segments to light
top =1
top right = 2
bottom right = 4 etc
...so to display a '1' in no-decode mode you need to send a 6 (i.e. 2+4)

Why the two modes?
Decode mode = simple to use; send the number you want to display
No Decode mode = you control the segments, so if you want say a lower case 't' send 120
120 = 0+0+0+8+16+32+64 +0
=
seg a off
seg b off
seg c off
seg d on
seg e on
seg f on
seg g on
dp off
= lower case 't'
 

xtech007

Senior Member
thank you for joining in!

Mr Martin thanks for the reply, i read your post too!
Currently printed it, to study your code.
To see if i can make sense of it!

One question.
Did you use an 8x8 led matrix too?
 

MartinM57

Moderator
Afraid not - I use 8 (or 16 with two cascaded MAX7219's) 7 segment LEDs with a decimal point

...but eight 7 segment plus decimal point LEDs are pretty similar to an 8x8 led matrix :)
 

xtech007

Senior Member
No wonder!!!

Jajjajja!!
Downloaded the code and powered the 8x8 led matrix and all hell broke loose!

First, whole matrix light up!
Second first top four rows blanked, then,first and second row switch on and off! And to the races they go!

Afterwards figured it was for an 7segment display not an led matrix!
 

westaust55

Moderator
If you look at the tutorial I posted here:
http://www.picaxeforum.co.uk/showthread.php?23293-Getting-Started-with-the-MAX7219-Eight-Digit-7-Segment-LED-Driver
I have tried to explain the decoding and undecoded method for operation as well as how the MAX7219 register bits corrspond to the 7-seg individual segmants.

The example program I also provided first uses the decode mode on as a decimal counter from 0 to 9999.

Then I turn the decode mode off and use my own codes to send out 8 bits per digit (for a 4 digit display with 7 seg + dp per digit) as a hexadecimal counter from 0 ($0000) to 65535 ($FFFF).

For an 8x8 led matrix you need a MAX7219 per digit and whereas my code sends data for 4 digits you need set up for 8 digits to send 8 bytes of data to cover the entire 8x8 LED matrix. That means for the digits 0 to 9 you will need a 10 x 8 byte look up table to cover the range of vales. The same table can be used for all digits in you project if you have a multi-digit display (ie several 8x8 LED matrix)
With an 80 byte lookup table you then need to have a program line to calculate a pointer to the first required byte of data along the lines of
Pointer = digit_value * 8
Then read and send the 8 bytes of data starting at the Pointer location.
Your actual data values required is dependent upon how you wire up the 8x8 matrix to the MAX7219.
 
Last edited:

xtech007

Senior Member
code used.

Here is the post from Where code was aquired.
http://www.picaxeforum.co.uk/showthread.php?2651-MAX7219-help&highlight=7219
 

xtech007

Senior Member
just one matrix display!

Westaust, thanks for bearing with me.
For now just want to use one matrix to display 0-9 and A-Z.
So far to my understanding;
1 no-decode in my case is a must, to drive each led on the matrix.

2. Only one Max7219 is needed to display lets say "T" in the middle of the matrix. And only 1 character at a time.
If there were more max7219 more characters would be displayed.

3. Some map or table has to be preset on memory to a character (0-9,AZ).
Exp.
EEPROM $64,(%01000000,%01000000,%01111111,%01000000,%01000000) 'T

With that said,
How would this data be sent out to the max7219?
How are the rows controlled?
 
Last edited:

westaust55

Moderator
To drive an 8x8 matrix instead of an 8-dgit 7-seg display
Initialise for: No decode and 8 digits on
For each line of LED’s you need one byte of data to control 8 LEDs
For each line you must send a digit number corresponding to the Line No followed by the data for that line
In my example PICAXE program code you will see lines like:
Register = Digit0 : Data_7219 = Units : GOSUB ShiftTo7219

This needs to be repeated 8 time with register values 1 to 8 inclusive and Data_7219 holding the data to turn on the appropriate LED’s for that line corresponding to the digit/register value.
 

xtech007

Senior Member
Better understanding!

Thanks all for the patience and guidance.

With a much better understanding will tackle the program, and soon presented to the forum.

Thank you all!
 

xtech007

Senior Member
Hi All!
Its been a Week and just now, I present to you my first working Code.
After Lots of reading and cross referencing other threads I was able to get this far!
Lots of trials and errors showed me baby steps to each line of the code and how they work.
the code is very simple just displays letter "A" clears the screen and does it again.
I also learned how to decrease or Increase the Brightness of the LED's! Here is a picture!
first letter fixed.JPG

and here is the Code:
Code:
; ********************************
; **28X2,MAx7219,8X8 LED Matrix **
; **  Controlling Registers     **
; ********************************

			'PICAXE 20X2 Pin
symbol SData = C.5
symbol CS = C.2
symbol CLK = C.3

			'Variables 
symbol maxreg = b0		' maxreg is the digit (column) to be displayed
symbol maxdata = b1		' maxdata is the LED pattern (1=on 0=off)


			'MAX7221 Registers
symbol noop = $00			'No Operation
symbol dig0 = $01			'Column 0
symbol dig1 = $02
symbol dig2 = $03
symbol dig3 = $04
symbol dig4 = $05
symbol dig5 = $06
symbol dig6 = $07
symbol dig7 = $08			'Column 7
symbol decode = $09		'Decode(Hex FF),No-decode(Hex00)
symbol intensity = $0A		'LED's 'brightness (Hex 0-F)0=Lowest,F=highest
symbol scan_limit = $0B		'How many digits (columns)to display
symbol shutdown = $0C		'Turn off MAX7219
symbol display_test = $0F	'Test Matrix

			'Max7219 Register Options

symbol display_on = $01       'Display ON
symbol display_off = $00	'Display OFF
symbol display_test_on = $01	'Turns all LED's ON for test
symbol display_test_off = $00	'Test OFF
symbol display_normal = $00	'Normal Operation 
symbol blank = $0F		'Display Blanked

			' Setup routine for the MAX7219

Setup_MAX7221:
maxReg = decode
maxData = $00
gosub SendTo_Max7219

maxReg = intensity
maxData = $01
gosub SendTo_Max7219

maxReg = scan_limit
maxData = $07
gosub SendTo_Max7219

maxReg = shutdown
maxData = display_on
gosub SendTo_Max7219
pause 30

Clear_MAX7219:		'Clears the display
maxdata = $00
for maxreg = 1 to 8
gosub SendTo_Max7219
next
pause 500



Main:               '"Displays Letter A"
maxReg = $02
maxData = $03F
gosub SendTo_Max7219
MaxReg = $03
MaxData = $044
gosub SendTo_Max7219
MaxReg =$04
MaxData = $044
gosub SendTo_Max7219
MaxReg =$05
MaxData = $044
gosub SendTo_Max7219
MaxReg =$06
MaxData = $03F
gosub SendTo_Max7219
pause 500
gosub Clear_MAX7219
pause 500
goto main


SendTo_Max7219:
LOW CS
SHIFTOUT CLK,SDATA,1,(maxreg,maxdata)
HIGH CS
RETURN
 

xtech007

Senior Member
Thinking there must be a faster way to display the letters then what I'm currently doing.
Also mapping the characters to eeprom to be displayed when needed.

any help is appreciated!
Thanks Forum!
 
Top