Bi-Color matrix

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by brad » Wed Sep 26, 2012 10:01 pm

I have also just noticed that in your array for your arrow, you only have 7 bytes of data. If you want to scroll it, you need to have one full screen of nothing to start with, then the arrow then another full screen of nothing which means you should have 21bytes.

Otherwise you have nothing to scroll with - all you can do is display a static picture of your arrow, if you try and call data that is outside your arrow data, you are just calling random 1's and 0's stored within program memory.

For example, you have this piece of code:

Code: Select all

sub SaveGraphics()
    for x = 0 to 6 
         RedBuffer(x) = RedDataCol (x + Scrolling_Arrow )  
    next 
end sub
if scrolling_arrow = 0, then you are cycling through the reddatacol from 0 to 6 (which is every single byte in that array) If you increment scrolling_arrow by 1, then you are trying to cycle from reddatacol 1 to 7 but there is no 7 because reddatacol only contains data within the range 0 to 6 since it is reddatacol(7).

Does that make sense?

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Thu Sep 27, 2012 2:14 pm

U understand the basic principal of extracting the const array data which are 8 bits per byte which should work but trying to get all the rows to enable the colums dosen't seem to work.
take for example %00000001
if you load this into say porta then the led on pin 0 should light.
%00000111 = the leds on pins A0, A1, and A2 should light?
If I understand this correctly then i shouldn't get any ghosting and at one point I only had the RED leds to come on but I got some green leds as well which I never declared green leds on portD
Am going to start from scratch again and try and figure out what is going haywire
here is where I am now but when the LEDs in colum 2 only are supposed to light, I get LEDs in colum 3 that come on brighter than the leds in colum 2. Hope that makes sense.
Am contemplating just calling out say (A0, C1) which should turn on a red led in the first row (0-7Top to Bottom) and the second colum (0-4L>R). This may be wrong but ??

Code: Select all

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 9/26/2012                                                      *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}

Device = 18F4520
Clock = 20
//Config OSC = INTIO67                // Use the Internal Oscillator
 

 



'*********************************************************************
'Compiler directives like oscillator settings


'*********************************************************************
'#Options for include statements - must be before include statements
                                                                                   
                                                                                    



'*********************************************************************
'Includes


Include "utils.bas"



'*********************************************************************
'Dimension Statements (variable and constants
//                        row 3     row 2& 4   rows 1 & 5    row 1,2,4,5  all rows                stp
Const RowsA(7) As Byte = (%00000001, %00000010,  %00000100,   %0001000,   %00010000, %00100000, %10000000 ) // Active RowPort pins for each section of the arrow
Const RowsB(7) As Byte = (%00000001, %00000010,  %00000100,   %0001000,   %000010000, %00100000, %10000000 )
//                     7 colums from right to left                                                  
Const RedDataCol(7) As Byte = (%000010001, %00001010, %00000100, %000010001, %00001001, %00000000, %00000000)  // Active ColPort pin for each section of the arrow
Const GreenDataCol(7) As Byte =(%000010001, %00001010, %00000100, %000001010, %00000100, %00100000, %11100000) 
 //                       col3         col4       col5
 Const stp(8) As Byte = (%00000000, %00001110, %00010001,%00010001,%00010001,%00010001,%00001110, %00000000)        

  dim x as byte
  dim RedBuffer(7) as byte
  dim rowA_Buffer(7) as byte
  dim rowB_Buffer(7) as byte
  dim rowA as porta
  dim rowB as portb
  dim red_leds as portc
  
  
  //LOAD ARRAYS
  
  sub Save_graphics() 
      for x = 0 to 6
      RedBuffer(x) = RedDataCol(x)
      RowA_Buffer(x) = RowsA(x)
      rowB_Buffer(x)=  RowsB(x)
      next
      end sub
      
      
  sub Display_Graphics() 
      for x = 0 to 3
      red_leds =  RedDataCol(x)
     // if x<=3 then
      rowA =RowsA(x)
      delayms(2000)
      next
    //  else
    for x = 0 to 2
      red_leds =  RedDataCol(x)
      rowB = RowsB(x)
      delayms(3000)
    
      next
      end sub
      
      
 
    //start of program  
      setalldigital
      trisa = %00000000
      trisb = %00000000
      trisc = %00000000
      trisd = %00000000
      red_leds = 0
      
      Save_graphics()  
      Display_Graphics 

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Thu Sep 27, 2012 8:57 pm

got up early as usual and contemplated WHAT IF?
well I just discovered something weird
If you look at my revised code (took out most all and it should display just two leds on row 0 colum 0 & 4
WELL thats not the case, I get colum 0 & 4 alright but in rows 0, 5, 6
going back and find out WHY!!

Code: Select all

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 9/26/2012                                                      *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}

Device = 18F4520
Clock = 20
//Config OSC = INTIO67                // Use the Internal Oscillator
 

 



'*********************************************************************
'Compiler directives like oscillator settings


'*********************************************************************
'#Options for include statements - must be before include statements
                                                                                   
                                                                                    



'*********************************************************************
'Includes


Include "utils.bas"



'*********************************************************************
'Dimension Statements (variable and constants
//                        row 3     row 2& 4   rows 1 & 5    row 1,2,4,5  all rows                stp
Const RowsA(7) As Byte = (%00000001, %00000010,  %00000100,   %0001000,   %00010000, %00100000, %10000000 ) // Active RowPort pins for each section of the arrow
Const RowsB(7) As Byte = (%00000001, %00000010,  %00000100,   %0001000,   %000010000, %00100000, %10000000 )
//                     7 colums from right to left                                                  
Const RedDataCol(7) As Byte = (%000010001, %00001010, %00000100, %000010001, %00001001, %00000000, %00000000)  // Active ColPort pin for each section of the arrow
Const GreenDataCol(7) As Byte =(%000010001, %00001010, %00000100, %000001010, %00000100, %00100000, %11100000) 
 //                       col3         col4       col5
 Const stp(8) As Byte = (%00000000, %00001110, %00010001,%00010001,%00010001,%00010001,%00001110, %00000000)        

  dim x as byte
  dim RedBuffer(7) as byte
  dim rowA_Buffer(7) as byte
  dim rowB_Buffer(7) as byte
  dim rowA as porta
  dim rowB as portb
  dim red_leds as portc
  
  
  //LOAD ARRAYS
  {
  
  sub Save_graphics() 
      for x = 0 to 6
      RedBuffer(x) = RedDataCol(x)
      RowA_Buffer(x) = RowsA(x)
      rowB_Buffer(x)=  RowsB(x)
      next
      end sub
   }   
      
  sub Display_Graphics() 
    //  for x = 0 to 3
      red_leds =  RedDataCol(0)
     // if x<=3 then
      rowA =RowsA(0)
      delayms(2000)
     // next
    //  else
  //  for x = 0 to 2
  //    red_leds =  RedDataCol(x)
  //    rowB = RowsB(x)
   //   delayms(3000)
    
   //   next
      end sub
      
      
 
    //start of program  
      setalldigital
      trisa = %00000000
      trisb = %00000000
      trisc = %00000000
      trisd = %00000000
      red_leds = 0
      
    //  Save_graphics()  
      Display_Graphics 

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by brad » Thu Sep 27, 2012 9:12 pm

It's time like these that I would go back to the breadboard and make sure the circuit itself is all good. Can you put this altogether on a breadboard I.E. do have enough parts?

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Fri Sep 28, 2012 5:48 am

Yes I have enough parts BUT I went through and able to turn on each LED by itself.
portA.0=1
portd.0 = 1
delayms(1000)
porta.0 = 0
etc.
All apeearrs to work but have self dout so going to re do using a for next loop. Been fiddling with the code trying to construct a for x - 0 to 35 loop where x is the port designation.
do it with the A ports then the B ports (could combine?)
I was even contemplating putting the port into an array
FIRST(A.0,D.0) but haven't got that far. Probably a dumb idea anyway.

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Fri Sep 28, 2012 2:17 pm

Going to start over on a perf board
Use PortB.0 - PortB.4 for the Green LEDs and PortC.0 - PortC.6 for the 7 rows
getting ghosting on the led that is supposed to be ON portC.2 but PortC.3 LED is bright

Code: Select all

// if device and clock are omitted, then the compiler defaults to 
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F4520
Clock = 20

 
Include "utils.bas"
                 // Assign an alias for "LED"



// ROWS

Dim rowA As PORTA.0
dim rowB as porta.1
Dim rowC As PORTA.2
dim rowD as porta.3
Dim rowE As PORTb.0
Dim rowF As PORTb.1
Dim rowG As PORTb.2

dim row(5) as byte
dim cathodes as portc
//COLUMS
Dim redA  as portc.0
dim redB  as portc.1
Dim redC  as portc.2
dim redD  as portc.3
Dim redE  as portc.4
Dim x As Byte
 
// Start Of Program...
                 // Assign an alias for "LED"

 
 // START OF PROGRAM
 

SetAllDigital
trisa = %00000000
trisb = %00000000
trisc = %00000000 
trisd = %00000000
porta = 0
portb = 0
portc = 0
portd = 0
While true
portb=0
portd = 0
portc = 0
   for x = 0 to 5
   rowc = 1
   redc=1  // portC.2 ghosting but port c.3 is bright
   delayms(1000)
   rowc = 0
   delayms(1000)
   next
Wend 
I have something really screwed up??
stating over

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by brad » Fri Sep 28, 2012 10:31 pm

Unfortunately your code seems to be going all over the place.

Having a look at your schematic from the first page of this thread, you are using a couple of ULN2803's to drive the red and green cathodes. However, (because I don't have any 7x5 Matrix displays) I looked some up on google and they appear to be mainly common cathode matrix'.

This means that you need to send logic 1's to the red anode or green anode to turn them on. You can't do that with an UN2803. Are you sure your Matrix' are common anode?

If you can send me a link to a datasheet I can draw up a simple schematic and will modify my Merry Christmas code slightly to give you something that will work.

Having said that, have you tried going right back to basics? I.E. not even trying and for loops at all but just trying to turn on specific LED's E.G. the bottom left LED or the third one from the left fourth one up etc...?

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Sat Sep 29, 2012 12:24 am

YES I am able to turn on desired LEDs.
I realize I need to send a HIGH to the port pins connected to the anodes and cathodes.
I got confused as to what denotes a common anode and common cathode. Google was my answer.
Using a simple BLINK LED code I am able to blink any LED. Will recheck again but I recall that I get some ghosting


http://pdf1.alldatasheet.com/datasheet- ... 1EGWA.html

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by brad » Mon Oct 01, 2012 12:00 am

Sorry for the late reply, have been quite busy working on the house lately.

I'll check out the data sheet and get back to you :)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Mon Oct 01, 2012 1:49 pm

I got the new wired board assembled and now testing.
Looks right but going through each port pin.
PortA = 0-4 colums green cathodes
PortC 0 to 7 rows anodes
portD = 0 to 4 colums red cathodes

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by brad » Mon Oct 01, 2012 10:02 pm

Excellent, Could you tell me how they are connected to the matrix? e.g. PORTC pins 0 to 7 go through a resistor to the anodes and PORTA and PORTD pins go to an ULN2803 and then onto the cathodes etc...

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Tue Oct 02, 2012 4:31 am

Need to redo the schematic then will post.
I got to thinking anbout code and realized my train of though may be in left field.
the code PORTC.BIT(x) is one bit only not an entire byte. I was interpertaining as a byte (the const array data)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Tue Oct 02, 2012 4:55 am

new schematic
NOTE the oscillator crystal section is not included. Using internal osc.
Attachments
new bike schematic.jpg
new bike schematic.jpg (118.82 KiB) Viewed 20785 times

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by MrDEB » Tue Oct 02, 2012 10:02 pm

Made LOTS of progress with new wired board.
Now I need to tweek to get the scrolling smoother.
I contemplated using PORTD.BITS(x) but need to try configuring it different. I tried but couldn't get it to work right. Code IMO is kinda CLUNKY not smooth transition from one arrow to the next. Perhaps a shorter delay but then the arrow just flashes and can't make out the graphic.
Perhaps use INC??

Code: Select all

{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 9/19/2012                                                      *
*  Version : 1.0                                                            *
*  Notes   :brads suggestion 9/19/2012                                                                *
*          :                                                                *
*****************************************************************************
}
Device = 18F4520
Clock = 8
Config MCLRE = Off
 

'*********************************************************************
'Includes
Include "InternalOscillator.bas"

Include "utils.bas"
Include "convert.bas"


'*********************************************************************
'Dimension Statements (variable and constants

//Dim row As PORTD    // row 0 to 6 



Dim count As Word
Dim x As Byte

//
Const Red_Data(7) As Byte =   (%00010001, %00001010, %00000100 ,%00010001, %00001010,%00000100, %00010001)// 5 colums left to right
//Const green_data(7) As Byte = (%00000001, %00000011, %00000111 ,%00011111, %00111111, %01111111, %01111111)
Const R_ows(7) As Byte =      (%00000001, %00000010, %00000100 ,%00001000, %00010000, %00100000, %01000000)// 7 rows top to bottom
   

   
  
    

Sub display()
 
   
                  portc = red_data(0)
    portd = R_ows(0)
     DelayMS(70)
                  portc = red_data(1)
    portd = R_ows(1)
     DelayMS(70)
                  portc = red_data(2)
    portd = R_ows(2)
     DelayMS(70)
                  portc = red_data(0)
     portd = R_ows(1)
     DelayMS(70)
                  portc = red_data(1)
    portd = R_ows(2)
     DelayMS(70)
                  portc = red_data(2)
    portd = R_ows(3)
     DelayMS(70)
                  portc = red_data(0)
    portd = R_ows(2)
     DelayMS(70)
                  portc = red_data(1)
    portd = R_ows(3)
     DelayMS(70)
                  portc = red_data(2)
    portd = R_ows(4)
     DelayMS(70)      
                  portc = red_data(0)
    portd = R_ows(3)
     DelayMS(70)
                  portc = red_data(1)
    portd = R_ows(4)
     DelayMS(70)      
                 portc = red_data(2)
    portd = R_ows(5)
     DelayMS(70)      
                 portc = red_data(0)
    portd = R_ows(4)
     DelayMS(70)
                  portc = red_data(1)
    portd = R_ows(5)
     DelayMS(70)      
                 portc = red_data(2)
    portd = R_ows(6)
     DelayMS(70)
                          
           
End Sub


// set ports as outputs
TRISA = %00000000
TRISB = %00000000
TRISC = %00000000       
TRISD = %00000000




count = 0
SetAllDigital

//row = 0
PORTB = 0
PORTC = 0
PORTA = 0
PORTD=0
While true
 For count =0 To 20    // run 21 times
// load()

 display()                // sub call
 DelayMS(1000)
 Next Wend

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Bi-Color matrix

Post by brad » Wed Oct 03, 2012 9:25 pm

Since the Matrix is a common anode, you don't even need to use those ULN2803 chips (if it where common cathode then you would use them). The reason being is that you activate on row of anodes, and then you can turn on whichever LED's you want in that row by providing a path to ground to the respective cathode. The reason for having the ULN2803 is so you can provide this path to ground while still allowing for upto 500mA of current draw per output. Since each output of the ULN2803 (in your schematic) will only ever drive one LED, it is a little bit of overkill. Each output of the PIC will happily drive on LED however they don't like trying to drive upto 10 LED's at once (which could be the case if you happened to have all 5 of the green and all 5 of the red LED's on at once).

I would connect the common anodes through an NPN transistor and then the cathodes can go straight to the PORT pins. you just need to XOR the data with all 1's before sending it to the cathodes so that it inverts the 1's to 0's and vice versa.

So, having said that - here is how I would do it:
Matrix.png
Matrix.png (121.41 KiB) Viewed 20751 times

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 2 guests