max7219/SPI troubles.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

robin223
Posts: 6
Joined: Thu Jul 10, 2014 10:41 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

max7219/SPI troubles.

Postby robin223 » Mon Jul 14, 2014 2:18 pm

Hi there, I'm recently purchased a copy of Flowcode6 and I'm just finding my feet with it. Apologies for the newbie question.

I'm trying to communicate with an spi dual 7 segment dispay which uses the MAX7219 chip but with little success.

https://www.tindie.com/products/rajbex/spi7segdisp856-kit-eight-digit-serial-spi-seven-segment-led-display-yellow/

I'm pretty confident the connections to the device are correct. I have posted up my test file, I suspect I may be reading the tables wrong on the 7219 datasheet.
If anyone has the time to take a look, I'd be very grateful.

Thanks
Robin
Attachments
max7219test.fcfx
(5.31 KiB) Downloaded 343 times

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: max7219/SPI troubles.

Postby Benj » Mon Jul 14, 2014 2:43 pm

Hi Robin,

Looks like your on the right track.

If you want to use binary values then instead of writing this.

11111110

you need to add 0b to the start or the value will be processed as a decimal number and truncated to 8-bits.

0b11111110

You might also need small delays after the init and every time you raise the CS pin to complete your command. The main loop already has this and it might not be required.
These users thanked the author Benj for the post:
robin223 (Mon Jul 14, 2014 3:24 pm)
Rating: 5.26%
 

robin223
Posts: 6
Joined: Thu Jul 10, 2014 10:41 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: max7219/SPI troubles.

Postby robin223 » Mon Jul 14, 2014 5:18 pm

Thanks Benj!

That's solved it.
These users thanked the author robin223 for the post:
Benj (Tue Jul 15, 2014 10:33 am)
Rating: 5.26%
 

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: max7219/SPI troubles.

Postby rradojko » Tue Jun 07, 2016 6:21 am

Continuing the theme.

I use Arduino Nano and 8 X 7-seg. display with MAX7219.
Connecting the Arduino Nano, and 8 X 7-seg. display the picture.
I enclose a program written in Flowcode_6

I wonder why the program does not work?
What am I doing wrong?

Does anyone have a working program for the MAX7219 and 8 X 7-seg. displey? Just for test.

max7219test.fcfx
(5.67 KiB) Downloaded 238 times
Attachments
Max7219_prikljucitev_na_Arduino_NANO.jpg
(216.36 KiB) Downloaded 3307 times

User avatar
STibor
Posts: 262
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 114 times
Been thanked: 112 times
Contact:

Re: max7219/SPI troubles.

Postby STibor » Tue Jun 07, 2016 8:28 pm

Hi!

Code: Select all

initialize
    Chip_Select := 1;
    SPI_Init;
     
    Chip_Select := 0;
    SPI_Send_Char=0x0b;
    SPI_Send_Char=0x07;
    Chip_Select := 1;
     
    Chip_Select := 0;
    SPI_Send_Char=0x09;
    SPI_Send_Char=0xff;
    Chip_Select := 1;
     
    Chip_Select := 0;
    SPI_Send_Char=0x0c;
    SPI_Send_Char=0x01;
    Chip_Select := 1;
     
    Chip_Select := 0;
    SPI_Send_Char=0x0f;
    SPI_Send_Char=0x00;
    Chip_Select := 1;
     
    Chip_Select := 0;
    SPI_Send_Char=0x0a;
    SPI_Send_Char=0x0f;
    Chip_Select := 1;
     
    //numbers
     
    Chip_Select := 0;
    SPI_Send_Char=0x01;//digit
    SPI_Send_Char=0x01;//(number)
    Chip_Select := 1;
     
    Chip_Select := 0;
    SPI_Send_Char=0x02;//digit
    SPI_Send_Char=0x02;//(number)
    Chip_Select := 1;
    ...and so on
    Chip_Select := 0;
    SPI_Send_Char=0x08;//digit
    SPI_Send_Char=0x02;//(number)
    Chip_Select := 1;
    ..-end
These users thanked the author STibor for the post (total 2):
rradojko (Fri Jun 10, 2016 2:54 pm) • George_B (Mon Oct 10, 2016 12:38 pm)
Rating: 10.53%
 

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: max7219/SPI troubles.

Postby rradojko » Fri Jun 10, 2016 3:10 pm

STibor, thanks for the information.
I tried to Flowcode 6, but does not work. Absolutely nothing. What am I doing wrong?

I enclose a program Flowcode 6.


Stibor, nice project - https://www.youtube.com/watch?v=L_2jvbifOwk
How is this done? Arduino?

Thank you.
Attachments
max7219test.fcfx
(8.35 KiB) Downloaded 242 times

User avatar
STibor
Posts: 262
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 114 times
Been thanked: 112 times
Contact:

Re: max7219/SPI troubles.

Postby STibor » Fri Jun 10, 2016 4:15 pm

Last edited by STibor on Tue Nov 01, 2016 11:17 am, edited 1 time in total.
These users thanked the author STibor for the post (total 2):
rradojko (Tue Jun 14, 2016 5:42 am) • Benj (Wed Jun 15, 2016 3:52 pm)
Rating: 10.53%
 

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: max7219/SPI troubles.

Postby rradojko » Tue Jun 14, 2016 5:26 am

STibor wrote:..............I attach an example.I only have a dot matrix display with MAX7219, I can not test.Proteus works well in the 7-segment display.


Bravissssssimo, 7-segment 8 X works fine.
Thank you very much for example.
I am very happy to help ;-).
These users thanked the author rradojko for the post:
Benj (Wed Jun 15, 2016 3:52 pm)
Rating: 5.26%
 

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: max7219/SPI troubles.

Postby George_B » Mon Oct 10, 2016 12:50 pm

Hello all !

Great topic about MAX7219. I managed to flash the leds within a few minutes after i read this!


I have a question regarding displaying a float number on a three digit 7 segment Display.

For example at the moment i send 0b11111110 to obtain the desired character and it works totally fine for any character that i want!

If i have a float variable, how can i convert for example 12.3 value to binary and send it using SPI to MAX7219?

Is there any way of doing conversion of a number including the decimal place?


Thanks in advance!
George
Last edited by George_B on Mon Oct 10, 2016 10:30 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: max7219/SPI troubles.

Postby Benj » Mon Oct 10, 2016 5:32 pm

Hi George,

I would do something like this.

First copy the float into an integer variable. This will copy the whole part of the number leaving the decimal point. Then update the float variable so it only contains the real part of the number.

Code: Select all

int = float
float = (float - int)


Then check if the number is greater than 100.

Code: Select all

int > 100


if it is then you can simply print out the three characters.

Code: Select all

char1 = int / 100
char2 = int % 100
char3 = int % 10


otherwise you need to collect the floating point based on the value.

int > 10 then decimal point is on character 2.

Code: Select all

char1 = int / 10
char2 = int % 10
char3 = float * 10


Otherwise decimal point is on character 1.

Code: Select all

char1 = int
char2 = float * 10
char3 = (float * 100) % 10


Hope this helps.

P.S. the % symbol is a modulus operator.

for example

234 % 10 = 4
234 % 100 = 34
These users thanked the author Benj for the post:
George_B (Mon Oct 10, 2016 9:57 pm)
Rating: 5.26%
 

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: max7219/SPI troubles.

Postby George_B » Mon Oct 10, 2016 10:28 pm

Hello Benj ! Thanks for your great help!

it is totally clear the way you describe the float to byte conversion.

I would like to know how to convert the number 1 for example into something like this 0b00110000 (D7D6D5D4D3D2D1D0 -> DP A B C D E F G) ??

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: max7219/SPI troubles.

Postby Benj » Tue Oct 11, 2016 9:56 am

Hello,

To switch a number 0-9 into the binary value I would use a switch icon with all cases 0-9 ticked.

Then for say the 1 branch you can use the hard coded value 0b00110000.
These users thanked the author Benj for the post:
George_B (Tue Oct 11, 2016 10:37 am)
Rating: 5.26%
 

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: max7219/SPI troubles.

Postby George_B » Sun Oct 30, 2016 9:47 pm

Hello all,

I followed Benj's suggestions. i tested the MAX 7219 and it works like a charm!

It is much more convenient to output the data as binary if you need to display characters or symbols that the BCD mode does not support.

It seems that i am not going to waste too many pins from my micro controller for those displays any more :D

I would prefer there was a similar chip for common anode led displays..

Thank you all and especially you Benj!
These users thanked the author George_B for the post:
Benj (Mon Oct 31, 2016 1:49 pm)
Rating: 5.26%