Martin Fisher great component Max7219_v2 a question Solved.
-
- Posts: 26
- http://meble-kuchenne.info.pl
- Joined: Sun Sep 22, 2024 9:13 pm
- Has thanked: 5 times
- Been thanked: 4 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
Hi Martin connected via SPI to Max7219 from the Atmega328P microcontroller, I can not display information on this LED display. Perhaps someone has a working code as a sample so that I can understand what I'm doing wrong?
- Attachments
-
- ALC_D.fcfx
- (8.5 KiB) Downloaded 7 times
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
Okay - just tested and got running on an Arduino Uno (it's the same MCU)
So - a couple of points. Displays are numbered from 0 - if just one, it's address (in PrintStr) is 0)
Second - and most importantly - the initial state of the display is 'Off' after the initialise - so you need to call SetIntensity and Shutdown(false) to enable it - the rather odd syntax was based on an Arduino library - and also because the you might not want 'random' brights at startup?
Your code also prints the same string repeatedly in a loop - this is not necessary (but won't do any harm either) - as the display 'remembers' it's current state.
Here I connect VIn to 5v, Gnd to gnd, Clk to d13, din to d11 and cs to d10 (or the equivalent pins on the ATMega MCU)
Note - one oddity, if you have multiple displays (and I actually have a strip of 4 on a 4 x 4 grid) - then you must set number of devices correctly - else displays along the chain display slightly corrupted 'echoes'. You might need to set swapX, swapY. This just displays the digits 0..9 on a single display.
My display will work at Fosc/4 - but not Fosc/2. It's occasionally possible to 'lock' the MAX7219 - get corrupted pixels (I've found running at too fast a clock will do this) - a power cycle (and a lower clock rate) should fix it. The maximum clock rate seems to be slightly dependent on the length and quality of the jumpers you use too.
Martin
So - a couple of points. Displays are numbered from 0 - if just one, it's address (in PrintStr) is 0)
Second - and most importantly - the initial state of the display is 'Off' after the initialise - so you need to call SetIntensity and Shutdown(false) to enable it - the rather odd syntax was based on an Arduino library - and also because the you might not want 'random' brights at startup?
Your code also prints the same string repeatedly in a loop - this is not necessary (but won't do any harm either) - as the display 'remembers' it's current state.
Here I connect VIn to 5v, Gnd to gnd, Clk to d13, din to d11 and cs to d10 (or the equivalent pins on the ATMega MCU)
Note - one oddity, if you have multiple displays (and I actually have a strip of 4 on a 4 x 4 grid) - then you must set number of devices correctly - else displays along the chain display slightly corrupted 'echoes'. You might need to set swapX, swapY. This just displays the digits 0..9 on a single display.
My display will work at Fosc/4 - but not Fosc/2. It's occasionally possible to 'lock' the MAX7219 - get corrupted pixels (I've found running at too fast a clock will do this) - a power cycle (and a lower clock rate) should fix it. The maximum clock rate seems to be slightly dependent on the length and quality of the jumpers you use too.
Martin
- Attachments
-
- max7219_demo.fcfx
- (9.7 KiB) Downloaded 14 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
Hi Martin ! Thank you for your help, everything works great! One last question: is there any possibility to add Ukrainian letters to the character encoding? Perhaps there is some table where you can change or add the encoding of your characters or letters, is this encoding table available?
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
Hi Viktor,
The character set is just 8 bytes per character. If you can design the characters, then it would be easy to either add to the existing set or replace characters. As it stands - it has ASCII characters from space (32) to 128.
Martin
The character set is just 8 bytes per character. If you can design the characters, then it would be easy to either add to the existing set or replace characters. As it stands - it has ASCII characters from space (32) to 128.
Martin
Re: Martin Fisher great component Max7219_v2 a question Solved.
I can create these symbols with a calculator, but can I add these codes to a macro? Is there any way to do it myself?
- Attachments
-
- ascii_code.png (136.55 KiB) Viewed 1101 times
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
No, not as it stands - all the characters are copied from the lookup table (which is in flash memory). How many characters do you need to add / replace? I can post the source to the component - all the characters are mapped in a lookup table where positions 0..7 correspond to ' ' (ASCII 32) - so need to know how the new characters map to the ascii character set too?
Martin
Martin
Re: Martin Fisher great component Max7219_v2 a question Solved.
Martin how to display information on the LED display without the pause function? That is, when the application is running and collects data and sends it to other devices and performs other functions, is it possible to display information on this ice in the form of, for example, an interrupt once every 500 milliseconds, enter the macro, clear the display, move it to any side by 1 pixel and exit the macro without pausing. And so the tape will move once every 500 milliseconds. Is there such an algorithm inherent here? Sorry, maybe I haven't figured it out yet.
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
Hi Viktor,
Maybe... If the spi uses interrupts then it might not work. It's not something I've tried..
You could try setting a timer interrupt and displaying a character and see if it locks up? If that works then scrolls etc should also work - and it would give a nice smooth scroll...
Martin
Maybe... If the spi uses interrupts then it might not work. It's not something I've tried..
You could try setting a timer interrupt and displaying a character and see if it locks up? If that works then scrolls etc should also work - and it would give a nice smooth scroll...
Martin
Re: Martin Fisher great component Max7219_v2 a question Solved.
Hi Martin,
Could you help me to understand the algorithm of the macro itself, how to apply all the functions of this macro, how they work? Only in the DisplayStr function on interrupt the symbol is highlighted, but I don't know how to shift the information in this mode. I tried to do it using Scroll, but it doesn't work, the symbol moves by 1 pixel and returns to the new position. There is nothing in the help file for this macro. Sorry for my intrusiveness, but I'm just a beginner in programming and may not understand everything. I would also like to see the character encoding table, if possible, so that I can try to add Ukrainian letters.
Viktor
Could you help me to understand the algorithm of the macro itself, how to apply all the functions of this macro, how they work? Only in the DisplayStr function on interrupt the symbol is highlighted, but I don't know how to shift the information in this mode. I tried to do it using Scroll, but it doesn't work, the symbol moves by 1 pixel and returns to the new position. There is nothing in the help file for this macro. Sorry for my intrusiveness, but I'm just a beginner in programming and may not understand everything. I would also like to see the character encoding table, if possible, so that I can try to add Ukrainian letters.
Viktor
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: Martin Fisher great component Max7219_v2 a question Solved.
Hi Viktor,
The character set is ascii 8bit (see https://en.m.wikipedia.org/wiki/ascii -) I offset this by 32 so it's a table of 768 bytes for 96 characters (96x8).
A string in flowcode is an array of bytes - so each character can be 0..255 so in theory it would be possible to support 256 characters - which would require 2024 bytes storage.
Can you post what you've tried this far?
Martin
The character set is ascii 8bit (see https://en.m.wikipedia.org/wiki/ascii -) I offset this by 32 so it's a table of 768 bytes for 96 characters (96x8).
A string in flowcode is an array of bytes - so each character can be 0..255 so in theory it would be possible to support 256 characters - which would require 2024 bytes storage.
Can you post what you've tried this far?
Martin