1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Half way done and wish I had made a PCboard

Discussion in 'General Electronics Chat' started by MrDEB, Jul 20, 2014.

  1. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    I have posted nearly every detail you need here in this thread.

    Please, please, please follow what I have posted here. I'm not posting here because I has nothing else to do. Post #52 covers the Dim statements.

    The stuff you're reading at Digital-DIY is a different project, different day and does things differently. If you read the include statements, there's an AS1106 module included. That is used for 7-segment displays with decode. You're not using a 7-segment display here are you?

    If you think I haven't addressed a point, READ AGAIN. It's more likely ou missed it than I did.d
     
    Last edited: Aug 11, 2014
  2. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    After studying your post about a different project I get the drift of differences.
    Am in process of rewriting my code as per your suggestions.
    I get to wandering and wondering alot. I ask too many wHAT IF
     
  3. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    I have given you ALL OF THE BASICS RIGHT HERE. Please just try it exactly the way I've laid it out before you start "experimenting" or trying to "fix" something. There are an infinite number of ways to screw this up – you don't need to prove that right now.

    Just do it as I've laid it out, describe the pattern here in enough words that an idiot will be able to understand exactly what you get. Then and only then try this test: make the outer square of LEDs illuminate....and post the code. Then you'll on your own. Actually, until you post the code to do that, I'm done.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22

    Making lots of progress AFTER I looked over everything and just by chance I discovered the matrix in in backwards as per picture.Arduino - ShiftOut. The pcboard is marked w/ LED1 on one side but the square mounting hole is on the other side. Turned matrix around and I now have a working matrix. Now to make a square as Jon suggested.
    Code (text):
    {
    *****************************************************************************
    *  Name    : UNTITLED.BAS                                                   *
    *  Author  : [select VIEW...EDITOR OPTIONS]                                 *
    *  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
    *          : All Rights Reserved                                            *
    *  Date    : 8/4/2014                                                       *
    *  Version : 1.0                                                            *
    *  Notes   :  new revision by starting over and addressing the registers.                                                              *
    *          :                                                                *
    *****************************************************************************
    }

    DEVICE = 18F2420
    CLOCK = 20
    INCLUDE "shift.bas"
    INCLUDE "utils.bas"
    INCLUDE "convert.bas"
       ' INCLUDE "DS18B20.bas"
    INCLUDE "Utils.bas"
    include "convert.bas"
    //PIN DESCRIPTION
    DIM Load_pin  AS PORTC.5   // LATCH
    DIM Data_pin AS PORTC.4    // DATA
    DIM Clock_pin AS PORTC.3   // CLOCK

    //DIM X AS BYTE
    //DIM index AS WORD
    DIM Display_Reg AS BYTE     //register settings
    DIM Display_Data AS BYTE    // Data to be displayed
    DIM Data_out AS WORD        // Data for additional matrix (4)
    {
                         // define max7219 registers
    byte max7219_reg_noop        = 0x00;
    byte max7219_reg_digit0      = 0x01;
    byte max7219_reg_digit1      = 0x02;
    byte max7219_reg_digit2      = 0x03;
    byte max7219_reg_digit3      = 0x04;
    byte max7219_reg_digit4      = 0x05;
    byte max7219_reg_digit5      = 0x06;
    byte max7219_reg_digit6      = 0x07;
    byte max7219_reg_digit7      = 0x08;
    byte max7219_reg_decodeMode  = 0x09;
    byte max7219_reg_intensity   = 0x0a;
    byte max7219_reg_scanLimit   = 0x0b;
    byte max7219_reg_shutdown    = 0x0c;
    byte max7219_reg_displayTest = 0x0f;
    }
    //DIM Options(16) AS BYTE
    //DIM I AS WORD
    SUB Write_Matrix ()
            Load_pin = 0
            Data_out =256*Display_Reg+ Display_Data
            shift.out (MSB_first,Data_out,16)
            Load_pin =1
    END SUB

    PUBLIC SUB InitLed()
           Display_Reg = 9    // decode
           Display_Data = 0  //all
        Write_Matrix        // write to matrix
     
           Display_Reg = 10    //intensity
           Display_Data = 15   //max
        Write_Matrix
     
           Display_Reg = 11    //scan limit
           Display_Data = 2
        Write_Matrix
     
           Display_Reg = 12    //shut down
           Display_Data = 1
        Write_Matrix
    END SUB
    PUBLIC SUB clear_display()
               DIM I AS INTEGER
               FOR I = 1 TO 3
               Display_Reg = I
               Display_Data = 0
               Write_Matrix
           NEXT
    END SUB

    public sub TestMode(Test as boolean)
           if test = true then
              Display_data = 1
              Display_reg = %1111
              write_matrix
            else
              Display_data = 0
              Display_reg = %1111
              write_matrix
            end if
       end sub
    // PROGRAM CODE SET UP
    setalldigital
    shift.setoutput(Data_pin)
    shift.setclock(clock_pin)
    output(load_pin)
    load_pin = 0
    InitLed
      Display_data = 1
              Display_reg = %1111
              write_matrix
            delayms(500)
              Display_data = 0
              Display_reg = %1111
              write_matrix  
    //InitLED 'sets up the registers

    WHILE 1 = 1

    Display_Reg  = 1
    Display_Data = %11111111
    Write_Matrix

    Display_Reg  = 2
    Display_Data = %00000111
    Write_Matrix

    Display_Reg  = 3
    Display_Data = %00000100
    Write_Matrix

    Display_Reg  = 4
    Display_Data= %00001000
    Write_Matrix

    Display_Reg = 5
    Display_Data = %00010000
    Write_Matrix

    Display_Reg  = 6
    Display_Data= %00100000
    Write_Matrix

    Display_Reg = 7
    Display_Data = %01000000
    Write_Matrix

    Display_Reg  = 8
    Display_Data= %10000000
    Write_Matrix

    DELAYMS(1000)

    clear_display

    DELAYMS(1000)

    WEND
     
     
  6. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    Why in the Init routine is the scan limit set to 2? What should it be set to?

    Why in the clear_display routine is I = 3? What should it be?

    You got creative in the program loop. Clearly, what you're seeing is not what I intended. Why are you seeing what you're seeing, and why don't all the columns illuminate?
     
  7. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I copied the code using select all but I guess It didn't paste what I wanted.
    I changed to 7 because there are 8 leds.
    we have 8 leds to clear out. I tried with original suggested settings and only some of the leds lit up. Only the first 3 colums.
    here is the code with a colum scrolling from left to right. Amazing what happens when the matrix is put in correctly, not as per pcboard silkscreen. Have to change the scan limit for number of Max7219/matrix displays but first to get a letter to scroll using a const array??
    Code (text):

    DEVICE = 18F2420
    CLOCK = 20
    INCLUDE "shift.bas"
    INCLUDE "utils.bas"
    INCLUDE "convert.bas"
       ' INCLUDE "DS18B20.bas"
    INCLUDE "Utils.bas"
    include "convert.bas"
    //PIN DESCRIPTION
    DIM Load_pin  AS PORTC.5   // LATCH
    DIM Data_pin AS PORTC.4    // DATA
    DIM Clock_pin AS PORTC.3   // CLOCK

    DIM X AS BYTE
    //DIM index AS WORD
    DIM Display_Reg AS BYTE     //register settings
    DIM Display_Data AS BYTE    // Data to be displayed
    DIM Data_out AS WORD        // Data for additional matrix (4)
    {
                         // define max7219 registers
    byte max7219_reg_noop        = 0x00;
    byte max7219_reg_digit0      = 0x01;
    byte max7219_reg_digit1      = 0x02;
    byte max7219_reg_digit2      = 0x03;
    byte max7219_reg_digit3      = 0x04;
    byte max7219_reg_digit4      = 0x05;
    byte max7219_reg_digit5      = 0x06;
    byte max7219_reg_digit6      = 0x07;
    byte max7219_reg_digit7      = 0x08;
    byte max7219_reg_decodeMode  = 0x09;
    byte max7219_reg_intensity   = 0x0a;
    byte max7219_reg_scanLimit   = 0x0b;
    byte max7219_reg_shutdown    = 0x0c;
    byte max7219_reg_displayTest = 0x0f;
    }
    //DIM Options(16) AS BYTE
    //DIM I AS WORD
    SUB Write_Matrix ()
            Load_pin = 0
            Data_out =256*Display_Reg+ Display_Data
            shift.out (MSB_first,Data_out,16)
            Load_pin =1
    END SUB

    PUBLIC SUB InitLed()
           Display_Reg = 9    // decode
           Display_Data = 0  //all
        Write_Matrix        // write to matrix
     
           Display_Reg = 10    //intensity
           Display_Data = 8   //max
        Write_Matrix
     
           Display_Reg = 11    //scan limit
           Display_Data = 7    // to scan entire matrix
        Write_Matrix
     
           Display_Reg = 12    //shut down
           Display_Data = 1
        Write_Matrix
    END SUB
    PUBLIC SUB clear_display()
               DIM I AS INTEGER
               FOR I = 1 TO 8        // for 8 colums
               Display_Reg = I
               Display_Data = 0
               Write_Matrix
           NEXT
    END SUB

    public sub TestMode(Test as boolean)
           if test = true then
              Display_data = 1
              Display_reg = %1111
              write_matrix
            else
              Display_data = 0
              Display_reg = %1111
              write_matrix
            end if
       end sub
    // PROGRAM CODE SET UP
    setalldigital
    shift.setoutput(Data_pin)
    shift.setclock(clock_pin)
    output(load_pin)
    load_pin = 0
    InitLed
      Display_data = 1
              Display_reg = %1111
              write_matrix
            delayms(500)
              Display_data = 0
              Display_reg = %1111
              write_matrix  
    //InitLED 'sets up the registers

    WHILE 1 = 1
    for x = 1 to 8
    Display_Reg  = x
    Display_Data = %11111111
    Write_Matrix
    delayms(500)
    DELAYMS(10)

    clear_display

    DELAYMS(10)
    next
    WEND
     
     
  8. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    The scan limit has nothing to do with adding additional MAX7219 boards in a string with the first. Better go back and read the data sheet.

    To use multiple MAX7219s, you'll have to shift out 16 bits for each chip (i.e., 32 bits for 2 chips, 48 for 3...) before strobing the latch.

    The multi-matrix board controlled by an HT1632C I recommended probably would be easier to use instead of several of the MAX7219 boards strung together. If I'm reading the description correctly, you'll have to rotate the boards so the "columns" are horizontal to position them side-by-side. It's do-able, but it's seriously going to complicate scrolling.
     
  9. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I realize the scan limit has nothing to do with multiple boards. When I had the limit set to 3 I could only enable the first 3 colums of leds. Changed to 7 and I can enable all 8 leds across.
    Going to have a look at the HT1632C but ordering anything at this point in time until after Sept 1st. is iffy to receive as we are in process of moving last week of August.
    In fact we are headed your way and I hope to buy you lunch or dinner after we get settled in.
    Moving to Ryderwood Wa.
     
  10. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    Oh, perhaps I misunderstood exactly what you wrote?

    No....your new place is quite far away from me still.
     
  11. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    Yea it is kinda about 100+ miles but I want to go back to the Space Needle for dinner and visit the Lasizerium again. We were there about 10+ years ago and they had THE WALL.
    Would like to go to the science museum as well.
    Took a brief look at the HT1632C, pretty awesome chip to drive several matrices.
    Need to wait until after I move to purchase any more stuff. Thinking about a couple more Tap 28 boards if they are still available.
     
  12. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    MrDEB has decide to continue this conversation on the Swordfish Basic forum, but apparently forgot to go back and see if anybody replied. It's really kind of bad form to ask the same question in multiple forums.
     
    Last edited: Aug 6, 2014
  13. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I didn't forget, I visited the Swordfish forum several times today in between internet going down.
    I got a letter to scroll across one matrix but getting a second to display correctly.
    Going back to one matrix and see if I can get the code slimmed down into a simple 15 lines of code or less to display desired text.
    Experimented with two max7219's and one colum of leds but to no avail yet.
    Going to look at the "easier" to understand data sheet and maybe??
    If I can't get it working by Saturday its time to pack this project up for moving .
     
  14. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    After looking at page 12 for the as1106 I see where I need to address the no-op reg several times as per number of matrixes.
     
  15. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    No. Data is latched into the MAX7219 when the latch line is strobed.

    Instead of shifting out 16 bits for the single MAX7219 and strobing the latch, you shift out 16 bits of data for each one in the string, with the data destined for the furthest one shifted out first. Then strobe the latch line to latch the data into all of them at the same time.

    The Dout pin of the first matrix goes to the Din pin of the second and so on.

    If you use exactly the code I have above with no changes, the character on the first matrix will appear on the following matrices, one step behind.
     
  16. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    I realize the above means nothing to MrDEB.

    Lets say you have 3 Max7219s in series, Dout to Din....

    Change

    shift.out (MSB_first,Data_out,16)

    To

    shift.out (MSB_first,Data_out3, Data_out2, Data_out1, 48)

    You'll have to revise the Write_LED routine a little.
     
  17. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I changed code to post 51 but a no go
    referring to the as1106 data sheet page 12 it says the no-op reg to be addressed after each write? this seemed to help but it makes sense to use shift.out (MSB_first,Data_out3, Data_out2, Data_out1, 48)
    going to change as per post 75
     
  18. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    too many parameters
    Code (text):
      shift.out (MSB_first,Data_out1,data_out2,32)
    if I use 16 its ok. I realize maybe 32 bits but dosen't the first 16 bits just migrate into the second matrix?? Seems like that's what it should do??
    I got both matrixes displaying the same thing when I use the no-op register setting.
     
  19. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    Ok, the shift routine can handle a maximum of 32 bits, so you could shift data for two of the MAX7219s at a time. Since you're using more than two, just stick to the no-op codes.

    Realize if you shift data into the first MAX7219, you'll have to "flush it out" by shifting it past each additional MAX7219 without strobing the latch line.

    A string of matrices driven by MAX7219s is not ideal for scrolling text using any method I can see at the moment.
     
  20. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,118
    Likes:
    90
    Location:
    Seattle, WA
    Don't say I've never done anything for you. Here's a revised WriteLED subroutine that handles the no-ops for you. Sorry, the code formatting didn't survive copying.

    To use it, define LED_Data and LED_Reg and then

    WriteLED(x) where x is the unit number from 1 to 4. Unit 1 is the first in the string.

    Code (text):

    {
    Sub WriteLED ()
      LoadPin = 0
      Data_Out = 256*LED_Reg + LED_Data
      Shift.Out (MSB_FIRST, Data_Out, 16)
      LoadPin = 1
    End Sub
    }


    Sub WriteLED (Unit As Byte)
      'This subroutine supports 4 MAX7219s in series
      'Unit 1 is the first in the string, 4 is the last
      LoadPin = 0
      Select unit
      Case = 1
      data_out = 256* 0 + LED_Data ' no op
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 4
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 3
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 2
      Data_Out = 256*LED_Reg + LED_Data  'data to unit 1
      Shift.Out (MSB_FIRST, Data_Out, 16)
      Case = 2
      data_out = 256* 0 + LED_Data ' no op
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 4
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 3
      Data_Out = 256*LED_Reg + LED_Data  'data to unit 2
      Shift.Out (MSB_FIRST, Data_Out, 16)
      data_out = 256* 0 + LED_Data ' no op
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 1
       
      Case = 3
      data_out = 256* 0 + LED_Data ' no op
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 4
      Data_Out = 256*LED_Reg + LED_Data  'data to unit 3
      Shift.Out (MSB_FIRST, Data_Out, 16)
      data_out = 256* 0 + LED_Data ' no op
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 2
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 1
       
      Case = 4
      Data_Out = 256*LED_Reg + LED_Data  'data to unit 4
      Shift.Out (MSB_FIRST, Data_Out, 16)
      data_out = 256* 0 + LED_Data ' no op
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 3
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 2
      Shift.Out (MSB_FIRST, Data_Out, 16)  'no op unit 1
       
      End Select
      LoadPin = 1
    End Sub

     
     
  21. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,364
    Likes:
    22
    I started going in that direction of addressing each matrix as itself but wasn't sure so I didn't go any futher but perhaps I should have.
    I call it GETTING FRUSTRATED
    But with all I have on my plate I think I am going bonkers.
    Worrying about the house in Washington getting the required repairs by Aug 27th and throw in the appraisal, hope escrow closes before we leave Idaho. If not well I guess we are homeless for a few days.
    As I revise code I think back to all the help you Jon in particular have given me.
    Thanks
    Now to go write in the new WRITE_matrix routine. I printed it out first so I can make required revisions to suit my DIM statements etc.
     

Share This Page