max7219/SPI troubles.

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

Moderator: Benj

Post Reply
robin223
Posts: 9
Joined: Thu Jul 10, 2014 10:41 pm
Contact:

max7219/SPI troubles.

Post by robin223 »

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/ ... ay-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 372 times

User avatar
Benj
Matrix Staff
Posts: 14850
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: max7219/SPI troubles.

Post by Benj »

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.

robin223
Posts: 9
Joined: Thu Jul 10, 2014 10:41 pm
Contact:

Re: max7219/SPI troubles.

Post by robin223 »

Thanks Benj!

That's solved it.

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: max7219/SPI troubles.

Post by rradojko »

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 271 times
Attachments
Max7219_prikljucitev_na_Arduino_NANO.jpg
(216.36 KiB) Downloaded 3307 times

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: max7219/SPI troubles.

Post by STibor »

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

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: max7219/SPI troubles.

Post by rradojko »

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 271 times

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Contact:

Re: max7219/SPI troubles.

Post by STibor »

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

Hello!

Thanks!

No Arduino, with Pic18F6622 made.
I use Arduino development, final PIC microcontroller-based circuit.
Controller pcb:https://fbcdn-sphotos-a-a.akamaihd.net/ ... b1542b1ec7

Power PCB bottom side (on little Nch. dual FETs): https://fbcdn-sphotos-c-a.akamaihd.net/ ... 65f4754e6e

Power PCB top side(Nch power FETs for PWM):https://fbcdn-sphotos-c-a.akamaihd.net/ ... 054ef0751a

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.
Last edited by STibor on Tue Nov 01, 2016 11:17 am, edited 1 time in total.

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: max7219/SPI troubles.

Post by rradojko »

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 ;-).

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Contact:

Re: max7219/SPI troubles.

Post by George_B »

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: 14850
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: max7219/SPI troubles.

Post by Benj »

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

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Contact:

Re: max7219/SPI troubles.

Post by George_B »

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: 14850
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: max7219/SPI troubles.

Post by Benj »

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.

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Contact:

Re: max7219/SPI troubles.

Post by George_B »

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!

Post Reply