Menu

MAX7219

Help
2019-02-22
2019-03-03
1 2 > >> (Page 1 of 2)
  • stan cartwright

    stan cartwright - 2019-02-22

    I have 2 max7219 by 4 boards ... so each 32x8 leds.
    2 problems, 1st I can't get hardware spi to work
    and 2nd using software spi the characters are in the wrong place and bits missing.
    The code is on an arduino nano. I think the pins are correct but not sure of #define Max7219_CS.

      #chip mega328p, 16
    ;  #config MCLRE=on
      #include <Max7219_LEDMATRIX_Driver.h>
      #option Explicit
    ; ----- Constants
      'Set SPI pins for the Max7219
      #define Max7219_DI    portb.4    'pin12 miso
      #define Max7219_DO    portb.3    'pin11 mosi
      #define Max7219_SCK   portb.5    'pin13
      #define Max7219_CS    portb.2    'pin10
      'Specifics for device configuration
      #define MAX7219_X_Devices 8
    ;  #define MAX7219_LEDMatrix_HardwareSPI     ' remove and make a comment out if you want to use Software SPI for this device
    

    I'm telling it to print "ABCD1234567890" but get the display in the image.
    Any help appreciated.

          GLCDCLS
          GLCDPrint ( 0, 0, "ABCD1234567890")
          Max7219_LEDMatrix_Update
    
     

    Last edit: stan cartwright 2019-02-22
  • Anobium

    Anobium - 2019-02-23

    Two issues. One is resolved and hopefully we can resolve the other.

    We updated the library this week. https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/Max7219_LEDMATRIX_Driver.h?format=raw This will resolve the AVR Hardware SPI issue. The issue was sort of important... the initialisation on the port direction for the SPI ports on an AVR MUST come before the SPI mode is set. Learn something new all the time.

    Re the overwrite. You need to set the constnat #define MAX7219_X_Devices 8 correctly. I think you have not set? or, it needs to be larger. Essentially, you are overrunning the double buffer. I get the same here if I set the constant to an incorrect value than is less then the phyiscal number of LED modules.

     
    • Anobium

      Anobium - 2019-02-23

      And, check the wiring. The output from the microcontroller goes to the IN on the Module and then from the first modules OUT to the IN on the second module. Your picture looks a tad odd.... hence, me asking you to check

       
  • stan cartwright

    stan cartwright - 2019-02-23

    Thanks. Hardware spi now working.
    Does #define MAX7219_X_Devices 4 mean four 8x8 led units connected?
    What does MAX7219_Y_Devices mean? pset y range increases?
    I tried using a 8x32 led unit ie 4 joined-one pcb. I used
    ~~~
    #define MAX7219_X_Devices 4
    GLCDCLS
    GLCDPrint ( 0, 0, "ABCD")
    Max7219_LEDMatrix_Update
    ~~~
    but it prints wrong.
    The DIN connection goes to max7219_DO but whether DOUT goes to max7219_DI makes no difference.

     
  • stan cartwright

    stan cartwright - 2019-02-23

    Shouldn't GLCDPrint ( 0, 0, "ABCD") print "A" in the left 8x8 unit?
    GLCDPrint ( 8, 0, "ABCD") give the image.

     
  • Anobium

    Anobium - 2019-02-23

    Good news on hardware SPI.

    Something is not correct with those modules.

    Disconnect and just have one module connected. Then the defaults of shown below should work.

    #define MAX7219_X_Devices 4
    

    Where 4 is 4 MAX7219's with 4 8x8 LED Matrixes. AKA One 4 piece Module.

    I have tested here and I know the code is good, and, we have a number of users with the code operational - so, we need to look at the module.

    So, try one module. What happens? Is the last LED matrix inserted the wrong way around? Is the board defective?

     
  • stan cartwright

    stan cartwright - 2019-02-23

    My last post was one strip of four modules connected together on one pcb and #define MAX7219_X_Devices 4 and tried leaving blank and using default but same result.
    Leds only work one way and tried 2 modules.
    If the 4 modules in yours are from left to right 1,2,3,4....ie pset 0,0 top left
    mine are 4,3,2,1.
    I think different wired modules has been mentioned in the forum.

     
    • Anobium

      Anobium - 2019-02-23

      Yes, the orientation can be changed.

      Do this. remove the the gcdprint. With one module attached add line 0, 0, 63, 71 this should draw a line... post a foto. We need a method to determine the orientation.

       
  • stan cartwright

    stan cartwright - 2019-02-23

    Are the devices I have now representative of these devices? is it worth your effort.
    I want to learn how to map these..from a table maybe.

     
  • Anobium

    Anobium - 2019-02-23

    There is something odd going on. what is the single connection at the OUT for/doing

     
    • stan cartwright

      stan cartwright - 2019-02-23

      DOUT goes to DIN on another device or in using one device back to max7219_DI ......nano miso.
      using has no effect.
      I could saw the boards to make individual four 8x8 then wire in reverse order and gcb code would work...hmmmm.
      I looked at the include file and it was hard to understand first look. include glcd.h in there.

       
      • Anobium

        Anobium - 2019-02-24

        See my later post. This is NOT a table but a buffer array. It is very simple as this is the same approach as many of the buffered GLCD libraries.

         
  • stan cartwright

    stan cartwright - 2019-02-23

    error in demo ledmatrix_max7219_text_16f18855

    '; ----- Main body of program commences here.
    
      dim
    
      Do
    
          GLCDCLS
          GLCDPrint ( 0, 0, "It's")
    
     
    • Anobium

      Anobium - 2019-02-24

      Sorted. You can always edit these source files in GitHub to correct.

       
  • Anobium

    Anobium - 2019-02-24

    The library is really very similar to the other GLCD libararies. It has INIT, GLCDCLS and PSET - the essential parts of the library.

    PSET updated the array. The array is created to match the size the of the LED matrixes. Each Array byte supports 8 LED state of on or off. So, there is an array that is then processed in the SendBuffer methods. This is needed as we dont know the Matrix state so the array holds the state.

    We can easily (as I did during development) output this array to a serial terminal. If you use an ANSI terminal then you can reproduce the Matrix state on the the terminal. That was to make sure the simple maths in the array (with PSET) was correct.

    We know the Array method works as we have many user happily using this solution. And, I revalidated the solution yesterday.

    So, what could your issue be?

    1. The device under the Matrix is not a MAX7219. What are they?
    2. The device is connected differently to the two types we have come across so far. We need to figure out how these are daisy chained to adapt Max7219_LEDMatrix_SendBuffer to handle your modules.
    3. Does one Matrix work? Adapt the PCB to isolate the first Matrix. Set #define MAX7219_X_Devices 1 and then using what is the orientation? Where is the 0,0 pixel? It should be top left as it normal is when have the DIN on the left looking down. If the 0,0 pixel is elsewhere...like bottom right then this information would help understand the orientation of the Matrix.
    4. The other method. Stick them in the post to me.

    How cheap were these modules?

     

    Last edit: Anobium 2019-02-24
  • stan cartwright

    stan cartwright - 2019-02-24

    Chip is MAX7219.
    With DIN on the left pset 0,0 is bottom right. Chars are upside down.
    I'm looking at the max include and
    Sub Max7219_LEDMatrix_PSet_90( max7219_LocX as word, max7219_LocY as word, PixelCol)
    element = ( max7219_LocX + ( max7219_LocY / 8 ) + 1 )
    elementbit = max7219_LocY mod 8
    Max7219_Image_Buffer( element ) = Max7219_Image_Buffer( element ) OR FnLSL( PixelCol, elementbit )

    Sub Max7219_LEDMatrix_PSet_0( max7219_LocX as word, max7219_LocY as word, PixelCol)
    elementbit = max7219_LocX mod 8
    element = ( ( max7219_LocX / 8 ) * 8 ) + (8-max7219_LocY)
    Max7219_Image_Buffer( element ) = Max7219_Image_Buffer( element ) OR FnLSL( PixelCol, elementbit )

    I can't see where they're called. Is this the key to inverting each 8x8 ?
    Cost is £3.40 ebay china

     

    Last edit: stan cartwright 2019-02-24
  • Anobium

    Anobium - 2019-02-24

    OK. Pset 0,0 bottom right of the first matrix?

    Dont be looking at PSET to flip until we know how orientation. I think you may need a new routine to flip 90 and flip left-right also. Depends on the answer above.

     
  • Anobium

    Anobium - 2019-02-24

    To flip 90, just add

    #define Pset max7219_LEDMatrix_PSet_90 do not make other changes until we have figured out the orientation.

     
  • stan cartwright

    stan cartwright - 2019-02-24

    Thank you for your time on this. Wish these were standard.
    This max .h is at the moment too complicated for me to understand.
    Change Max7219_Image_Buffer( element ) = Max7219_Image_Buffer( element ) OR FnLSL( PixelCol, elementbit )
    to FnLSR( PixelCol, elementbit )....ie shift other way for inverted data

     
    • Anobium

      Anobium - 2019-02-25

      OK.

      Please dont change stuff. Else, I will get very confused as my basline will be different.

      So, I am missing lots of information from previous posts.

      1. Does one Matrix work? Adapt the PCB to isolate the first Matrix. Set #define MAX7219_X_Devices 1 and then using what is the orientation? Where is the 0,0 pixel? It should be top left as it normal is when have the DIN on the left looking down. If the 0,0 pixel is elsewhere...like bottom right then this information would help understand the orientation of the Matrix.
        2.The other method. Stick them in the post to me.
      2. What happened when you flipped 90? By adding #define Pset max7219_LEDMatrix_PSet_90 to your user program.
       
      • Anobium

        Anobium - 2019-02-25

        And, then, only when you have answered the questions above. Try this, then, publish the results - this will show the buffer to a serial terminal using PUtty.exe

        Program, get the PUtty terminal running and you will see this, or, you should. This is the memory array for a four Matrix module. What does yours show? Shown below is the correct array results.

        00000000
        00000000
        00000000
        00000000
        00000000
        10000000       < row 3, module 1
        01111000       < row 2, module 1
        00000111       < row 1, module 1
        00000000
        00000000
        00000000
        00000000
        11110000
        00001111
        00000000
        00000000
        00000000
        00000000
        11110000
        00001111
        00000000
        00000000
        00000000
        00000000
        11100000       < row 7, module 4
        00011110       < row 6, module 4
        00000001       < row 5, module 4
        00000000
        00000000
        00000000
        00000000
        00000000
        
         
        • Anobium

          Anobium - 2019-02-25

          So, I have attached a revision with that has the potential mathematical to resolve the PCB issue.

          You have four options - two are tested to work. So, I applied maths to the issue and have calculated the potential option.

          Simly try Line 0,0,31,7 with one module attached.

          Try each of the four. Select ONLY one. So, uncomment.

          '#define Pset max7219_LEDMatrix_PSet_0       'you should have tested this in the previous test
          '#define Pset max7219_LEDMatrix_PSet_90       'and, you should have tested this in the previous test
          '#define Pset max7219_LEDMatrix_PSet_180       'new test.
          '#define Pset max7219_LEDMatrix_PSet_270       'new test.
          

          Anobium

           
  • stan cartwright

    stan cartwright - 2019-02-25

    I did isolate first device.
    pset 0,0,1 is bottom right.
    I didn't get the test program to display anything in putty. I used the usb connection.

     

    Last edit: stan cartwright 2019-02-25
  • stan cartwright

    stan cartwright - 2019-02-25

    The new include with #define Pset max7219_LEDMatrix_PSet_180 seems ok with 4 devices.
    GLCDPrint ( 0, 0, "abcd1234") gives image

     
  • stan cartwright

    stan cartwright - 2019-02-25

    Using #define Pset max7219_LEDMatrix_PSet_270 with GLCDPrint ( 0, 0, "abcd1234") gives

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.