Shop OBEX P1 Docs P2 Docs Learn Events
8x8 led matrix help apreciated. — Parallax Forums

8x8 led matrix help apreciated.

ninogenioninogenio Posts: 7
edited 2012-09-04 13:59 in General Discussion
hi all,

ive been a coder for quite some time now and messed around in many laungauges. so i though id take the jump and start learning about electronics and how the code ive been writting for years does its stuff.

well a few days ago i recived a quickstart board and 8x8 led matrix with the max7221 from gadget ganster and thought how hard can it be.... lol.

the 8x8 matrix has 5 pins to interact with the prop so i tryed the power line on both pin 30 (usb_power_en) and pin 40 (3.3v) and negative to pin 39.

now this leaves din load and clk wires for data so i ran these through a breadboard with a 10k resistor on each because the max can have problems with inteference, to pin 0 5 9 on the prop and used this code i found on this forum.
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
 Scan =    $0B
 Brite =   $0A
 Decode =  $09
 ShutDn =  $0C
 TestMax = $0F
 LOAD =    5                                                                'Connected to max pin 12     
 DataIO =  0                                                                'Connected to max pin 1     
 Clock =   9                                                                'Connected to max pin 13
 
 #4,LSBFIRST,MSBFIRST                                                        'Used for SHIFTOUT routines

OBJ                       
 BS2: "BS2_Functions"

PUB Main| index,INIT
  dira[0..9]:=%111111111        
  BS2.start(31,30)
  WAITCNT(CLKFREQ/2+CNT)
  Repeat index from 1 to 2
    INIT := lookup(index:ShutDn, 1)
    BS2.SHIFTOUT(DataIO, Clock, INIT, MSBFIRST, 8)
    BS2.PULSOUT(LOAD, 5)
  Repeat index from 1 to 2
    INIT := lookup(index:TestMax, 1)   
    BS2.SHIFTOUT(0, 9, index, MSBFIRST, 8)                                       'push the test command to the max7221
    BS2.PULSOUT(5, 5)

but nothing the leds stay off. sometimes if i ground the positive of the max then connect it back i get a quick flash. also if i connect the power and neg of the max too a battery instead of the prop the leds go crazy flashing on and off and making weird patterns. but these are not dependent on din load or clk wires.

i am probably making some stupid mistakes i am completely new too all of this but if i can get a starting point where i know everything is working as it should i should be able to get stuck in and really start learning spin and the propeller.

thanks for any help it will be most appreciated.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2012-08-19 11:16
    If you tied +5V to pin 30 and pin 40 you may have damaged the quickstart board.

    If you have a 5V external supply:

    The +5V should go to pin 40 (Vin) and the negative to pin 39 on the quickstart board.
    The +5V should go to pin 1 (Vdd) and the negative to pin 5 of J1 on the led matrix.

    The quickstart board can be powered from an external 5V (pin 40) or an external 3.3V (pin 38). Only one of these should be connected at any time. Pin 39 is the negative (gnd) connection for both +5 and +3.3V. If neither one is connected then the board gets power from the USB connection.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-08-19 12:16
    kwinn wrote: »
    If you have a 5V external supply:

    The +5V should go to pin 40 (Vin) and the negative to pin 38 on the quickstart board.

    I think you mean "negative to pin 39 on the quickstart board."

    And again here:
    kwinn wrote: »
    Pin 38 is the negative (gnd) connection for both +5 and +3.3V.

    Should be "Pin 39 is the negative (gnd) connection".

    You do mention pin 38 being 3.3V which is correct.

    I know these are just a couple of typos, but didn't want anyone trying to connect ground to pin 38 (ground connects to pin 39).

    "usb_power_en" is tied to ground if using a non-data USB cable for power. Usually usb_power_en isn't connected to anything. It's not needed when using battery power or when using a normal USB cable connected to a computer.
  • kwinnkwinn Posts: 8,697
    edited 2012-08-19 13:02
    You are absolutely right Duane. Thanks for catching that. Made the changes to the post. I hope he didn't have time to read it yet.

    I think it's time for a new pair of reading glasses for me.
  • ninogenioninogenio Posts: 7
    edited 2012-08-19 14:49
    hi thanks very much guys.

    that clears a lot up. i now have pin 40 of the prop connected up too the 5v line on the max and the ground feed connected too pin 39. no damage has happened i only ever try one pin at a time never bridge.

    i have double and triple checked the data lines but i cannot get the max to load in test mode. the main problem being i bought the max pre built on a board from gadget gangster and have no info if i need to add any capacitors resisters etc to power or neg lines to make it work with the prop.

    do you guys think the code i posted looks about right to boot the max into testmode?

    thanks very much!
  • BitsBits Posts: 414
    edited 2012-08-19 21:23
    The code looks okay to me but I do think it is being done in the proper order.

    Make sure CS is set low First
    Then shift data out 16 bits not 8 but you may have this in check with the
    BS2.pulsout(load, 5)
    
  • kwinnkwinn Posts: 8,697
    edited 2012-08-20 00:26
    Hey Bits, good to see that you are up to helping out on the forum. All my best wishes for a speedy recovery. I know from experience how tough and painful it can be, but hang in and work at it and you will be back to your old self in no time..
  • ninogenioninogenio Posts: 7
    edited 2012-08-20 04:49
    thanks for helping bits. this is going to sound really dumb but when you say make sure CS is set low. could you tell me what CS is. could it perhaps be a pin on the max or prop ive looked at both schematics and cant see one.

    btw i read your thread and hope all is well soon also.....

    thanks
  • BitsBits Posts: 414
    edited 2012-08-20 07:07
    Kwinn thanks for the kind words, it helps me move forward.

    ninogenio CS = chip select. I think its pin 12 on the ic. Look at the top of page 6 and you will see that CS has to be pulled low to start a conversation to the IC.
    Serial-Addressing Modes For the MAX7219, serial data at DIN, sent in 16-bit packets, is shifted into the internal [B]16-bit[/B] shift register with each[B] rising edge of CLK[/B] regardless of the state ofLOAD. For the MAX7221, [B]CS must be low[/B] to clock data in or out....
    
  • PublisonPublison Posts: 12,366
    edited 2012-08-20 07:17
    Are you sure it's the MAX7221? All I could find on Gadget Gangster was a 8x8 matrix with a MAX7219.:

    http://gadgetgangster.com/find-a-project/56.html?projectnum=282

    If it's the MAX7219 this thread might help:

    http://forums.parallax.com/showthread.php?136470-MAX7219-Propeller-object.-Is-there-one-in-the-OBEX-or-in-the-Forums&highlight=MAX7219


  • ninogenioninogenio Posts: 7
    edited 2012-08-20 08:13
    ahh i totally overlooked that Bits thanks very much. as i understand to set CS to low. it is done through software on the load line?

    @Publison hi yes thats the kit i bought but for whatever reason the board has come with the 7221 installed. thanks for the link though im going to go through the thread very carefully to see if there is anything applicable to me.

    thanks very much guys.
  • PublisonPublison Posts: 12,366
    edited 2012-08-20 08:56
    ninogenio wrote: »
    ahh i totally overlooked that Bits thanks very much. as i understand to set CS to low. it is done through software on the load line?

    @Publison hi yes thats the kit i bought but for whatever reason the board has come with the 7221 installed. thanks for the link though im going to go through the thread very carefully to see if there is anything applicable to me.

    thanks very much guys.

    Bits is right. Pull CS low FIRST, (previously called LOAD).

    Nick should change the description on his website to reflect the usage of the MAX7221.
  • ninogenioninogenio Posts: 7
    edited 2012-09-04 12:04
    hey guys just wanted to drop a line to say i got this to work just fine once i pulled the lines low as well as a few other bits and peices. so i thought id share the code to help any one else finding it hard to get this particular combo with the max7221 going.
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      
     Scan =    $0B
     Brite =   $0A
     Decode =  $09
     ShutDn =  $0C
     TestMax = $0F
     LOAD =    4                                                               'Connected to max pin 12     
     DataIO =  0                                                                'Connected to max pin 1     
     Clock =   8                                                                'Connected to max pin 13
     
     #4,LSBFIRST,MSBFIRST                                                        'Used for SHIFTOUT routines
    
    VAR
      byte BackBuffer[7]
       
    OBJ                       
     BS2: "BS2_Functions"
     F: "Float32"
     
    PUB Main | X , Y, IDirX , IDirY , FX , FY , FDirX , FDirY
    
      dira[0..9]:=%111111111
      dira[LOAD]~
      dira[DataIO]~
      dira[Clock]~
    
      dira[LOAD]~~
      dira[DataIO]~~
      dira[Clock]~~
            
      BS2.start(31,30)
      F.Start
      
      SetUpMax7xx
      
      FX := 0.1
      FY := 0.1
      FDirX := 0.1
      FDirY := 0.06
        
      Repeat
           
        ClearBuff
        
        RenderPoint(X,Y)
        RenderPoint(X+1,Y)
        RenderPoint(X,Y+1)
        RenderPoint(X+1,Y+1)
    
        RenderPoint(X-1,Y-1)
        RenderPoint(X-1,Y+2)
        RenderPoint(X+2,Y-1)
        RenderPoint(X+2,Y+2)
        
        FX := F.FAdd(FX, FDirX)
        FY := F.FAdd(FY, FDirY)
    
        X := F.FTrunc(FX)
        Y := F.FTrunc(FY)
    
        If X > 9 or X < -2
          FDirX := F.FNeg(FDirX)
          
        if Y > 9 or Y < -2
          FDirY := F.FNeg(FDirY)
          
        UpdateMax7xx
         
    
        
    Pub ClearBuff | Ind
      Repeat Ind from 1 to 8
        BackBuffer[Ind] := 0
    
    
        
    Pub RenderPoint(X,Y) | Te
      Te := BackBuffer[Y]
        if X < 9 and X > 0
          if Y < 9 and Y > 0
            BackBuffer[Y] := ( ( 1 << ( X - 1 ) ) | Te )
        
    
        
    Pub UpdateMax7xx | Ind
      REPEAT Ind from 1 to 8
        BS2.SHIFTOUT(DataIO, Clock, Ind, BS2#MSBFIRST, 8)
        BS2.SHIFTOUT(DataIO, Clock, BackBuffer[Ind], BS2#MSBFIRST, 8)
        BS2.PULSOUT (LOAD, 5)
    
    
        
    Pub SetUpMax7xx | index,INIT
    
      WAITCNT(CLKFREQ/2+CNT)
      
      Repeat index from 1 to 2
        INIT := lookup(index:Scan, 7)
        BS2.SHIFTOUT(DataIO, Clock, INIT, BS2#MSBFIRST, 8)
        BS2.PULSOUT(LOAD, 5)
        
      Repeat index from 1 to 2
        INIT := lookup(index:Brite, 10)                                                      
        BS2.SHIFTOUT(DataIO, Clock, INIT, BS2#MSBFIRST, 8)
        BS2.PULSOUT(LOAD, 5)
        
    
      Repeat index from 1 to 2
        INIT := lookup(index:Decode,$00)
        BS2.SHIFTOUT(DataIO, Clock, INIT, BS2#MSBFIRST, 8)
        BS2.PULSOUT(LOAD, 5)
        
      Repeat index from 1 to 2
        INIT := lookup(index:ShutDn, 1)
        BS2.SHIFTOUT(DataIO, Clock, INIT, BS2#MSBFIRST, 8)
        BS2.PULSOUT(LOAD, 5)
    

    thanks for all the help
  • PublisonPublison Posts: 12,366
    edited 2012-09-04 13:59
    @ninogenio,

    Great that you got it working!

    Always glad to get a positive update. This helps others looking for the same solution.

    Jim
Sign In or Register to comment.