Page 1 of 1

max7219/SPI troubles.

Posted: Mon Jul 14, 2014 2:18 pm
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

Re: max7219/SPI troubles.

Posted: Mon Jul 14, 2014 2:43 pm
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.

Re: max7219/SPI troubles.

Posted: Mon Jul 14, 2014 5:18 pm
by robin223
Thanks Benj!

That's solved it.

Re: max7219/SPI troubles.

Posted: Tue Jun 07, 2016 6:21 am
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 514 times

Re: max7219/SPI troubles.

Posted: Tue Jun 07, 2016 8:28 pm
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

Re: max7219/SPI troubles.

Posted: Fri Jun 10, 2016 3:10 pm
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.

Re: max7219/SPI troubles.

Posted: Fri Jun 10, 2016 4:15 pm
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.

Re: max7219/SPI troubles.

Posted: Tue Jun 14, 2016 5:26 am
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 ;-).

Re: max7219/SPI troubles.

Posted: Mon Oct 10, 2016 12:50 pm
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

Re: max7219/SPI troubles.

Posted: Mon Oct 10, 2016 5:32 pm
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

Re: max7219/SPI troubles.

Posted: Mon Oct 10, 2016 10:28 pm
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) ??

Re: max7219/SPI troubles.

Posted: Tue Oct 11, 2016 9:56 am
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.

Re: max7219/SPI troubles.

Posted: Sun Oct 30, 2016 9:47 pm
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!