3x5 Matrix
Hi guys,
confusion,confusion.
Please, Any ideas.
-5ms
confusion,confusion.
Start:
OUTPUT RB
Main:
FOR idx = 0 TO 3
READ Pattern + idx, RB ' move pattern to LEDs
PAUSE 100
NEXT idx
FOR idx = 4 TO 1 STEP -1
READ Pattern + idx, RB
PAUSE 100
NEXT idx
GOTO Main
' -------------------------------------------------------------------------
Pattern: ' LED patterns
DATA %00000000
DATA %00011000
DATA %00111100
DATA %01111110
DATA %11111111
' Good Good! nice and simple, Example :)
' ---------------------------------------------------------------------------------------
' ------------------------ Then My Code -------------------------------------------------
' -------------------------- 3x5 Matrix ------------------------------------------------
' ---------------------------------------------------------------------------------------
' ------------------ My logic disappears up it self -----------------------------------------
line1 VAR Byte(4) ' line 1 buffer ¿Bit?
line2 VAR Byte(4) ' line 2 buffer
line3 VAR Byte(4) ' line 3 buffer
CommOut PIN RA.0 OUTPUT
CommIn PIN RA.1
Butt1 PIN RA.2
Butt2 PIN RA.3
line1 PIN RB.0 OUTPUT, RB.1 OUTPUT, RB.2 OUTPUT, RB.3 OUTPUT, RB.4 OUTPUT ' ?
line2 PIN RB.5 OUTPUT, RB.6 OUTPUT, RB.7 OUTPUT, RC.0 OUTPUT, RC.1 OUTPUT ' ?
line3 PIN RC.2 OUTPUT, RC.3 OUTPUT, RC.4 OUTPUT, RC.5 OUTPUT, RC.6 OUTPUT ' ?
Main:
FOR idx = 0 TO 15
READ Pattern + idx, line1 ' move pattern to LEDs_line1 ' ?
READ Pattern - idx, line2 ' move pattern to LEDs_line2 ' ?
READ Pattern + idx, line3 ' move pattern to LEDs_line3 ' ?
PAUSE 100
NEXT idx
GOTO Main
Pattern: ' LED patterns
DATA %00000
DATA %10000
DATA %11000
DATA %11100
DATA %11110
DATA %10101
DATA %01110
DATA %11010
DATA %11001
DATA %10110
DATA %00110
DATA %00001
DATA %00011
DATA %00111
DATA %01111
DATA %11111
' ---------------------------------------------------------------------------------------
' ------------------------------ Or maybe -----------------------------------------------
' ---------------------------------------------------------------------------------------
line1 VAR Bit(4) ' line 1 buffer
line2 VAR Bit(4) ' line 2 buffer
line3 VAR Bit(4) ' line 3 buffer
line1.0 PIN RB.0 OUTPUT
line1.1 PIN RB.1 OUTPUT
line1.2 PIN RB.2 OUTPUT
line1.3 PIN RB.3 OUTPUT
line1.4 PIN RB.4 OUTPUT
line2.0 PIN RB.5 OUTPUT
' so on ........
line3.0 PIN RC.2 OUTPUT
' so on ........
Please, Any ideas.
-5ms
Comments
Second, just make RB and RC outputs in one fell swoop (e.g. lineOut PIN RB OUTPUT)
Third, you need to change the comm pins BETWEEN each read. The idea is you turn on one "bank" of LEDs (these are columns/rows in a display matrix?), then read the pattern to the output pins. Then pause a tiny bit. Then turn off that bank and turn on the next bank (column?) and read the next pattern.
Even a hand drawn schematic would also help so we can see how you actually have things wired.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Thanks for your INPUT [noparse]:)[/noparse]
A schematic.
and this... ok?
lineOut PIN RABC OUTPUT CommOut PIN RA.0 CommIn PIN RA.1 INPUT Butt1 PIN RA.2 Butt2 PIN RA.3 line1 PIN RB.0, RB.1, RB.2, RB.3, RB.4 line2 PIN RB.5, RB.6, RB.7, RC.0, RC.1 line3 PIN RC.2, RC.3, RC.4, RC.5, RC.6
Also I'm not sure about your patterns -- you really want to write the same 5 bits to every line each time?
outPort PIN RBC OUTPUT ' treat the whole thing as a word, it's easier outBuff VAR Word ' a word sized "buffer" to set up all the outputs tmpW1 VAR Word ' reuseable word numPixels CON 5 ' how many leds on each bank/column/line whatever numPixels2 CON numPixels*2 Main: FOR idx = 0 TO 15 outBuff = $0000 ' zero out the buffer READ Pattern + idx, tmpW1_LSB ' read pattern byte outBuff = outBuff | tmpW1_LSB ' you could also inc idx here w/o for/next to read different lines for each line individually tmpW1_MSB = 0 READ Pattern + idx, tmpW1_LSB ' read pattern byte tmpW1 = tmpW1 << numPixels ' shift 5 pins over outBuff = outBuff | tmpW1 ' OR it onto buffer ' ditto tmpW1_MSB = 0 READ Pattern + idx, tmpW1_LSB ' read pattern byte tmpW1 = tmpW1 << numPixels2 outBuff = outBuff | tmpW1 ' now move to pins outPort = outBuff PAUSE 100 NEXT idx GOTO Main Pattern: ' LED patterns DATA %00000 DATA %10000 DATA %11000 DATA %11100 DATA %11110 DATA %10101 DATA %01110 DATA %11010 DATA %11001 DATA %10110 DATA %00110 DATA %00001 DATA %00011 DATA %00111 DATA %01111 DATA %11111
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 6/17/2009 3:42:51 AM GMT
Sorry for the slow reply.
I'm new to sxb, I've been looking at your code and trying to understand it, and experimenting
More than make my code work, I what to understand it.
Looking for moor information, Please, Zoot, or Anyone
binary numbers & concatenation:
So,
Q,1: "Can You concatenate binary numbers, or did You concatenate string".
thisCON CON %1011 thatCON CON "0100" thisVAR VAR Byte ' thatVAR VAR Word ' outBuff VAR Word tmpW1 VAR Word thisVAR = %1011 thatVAR = "0100" outBuff = $0000 ' zero out the buffer. Q,3: could this be %0000, or is this $0000 a string mask tmpW1_LSB = thisCON ' thisCON=%1011 outBuff = outBuff | tmpW1_LSB ' OR it onto buffer. Q,4: Would this make outBuff =%1011, or outBuff ="1011"
Thanks for your time [noparse]:)[/noparse]
-5ms?
If you don't understand the difference between %0000 and $0000 and "0000" then it is time to read the documentation (%number is binary, $number is hex, "" is a byte string, which can only be used/handled under certain circumstances).
Yes, the temp gets ORed onto the BLANK (i.e. = 0) Word. A Word is 16bits. I used a Word as a buffer (a place to build up the final state of the LED pins) because you have 15 pins you are controlling. The 5 bits you need for each bank are read, but then shifted over 5 bits each time so it is ORed onto the appropriate 5 bit "chunk" of pins. The best I can try to do here is add more commentary to the code.
outPort PIN RBC OUTPUT ' treat the whole thing as a word, it's easier outBuff VAR Word ' a word sized "buffer" to set up all the outputs tmpW1 VAR Word ' reuseable word numPixels CON 5 ' how many leds on each bank/column/line whatever numPixels2 CON numPixels*2 Main: FOR idx = 0 TO 15 outBuff = $0000 ' zero out the buffer ' first read data for the FIRST 5 LEDS READ Pattern + idx, tmpW1_LSB ' read pattern byte just into the LSB since there are <= 8 bits of data outBuff = outBuff | tmpW1_LSB ' OR just the LSB onto the zeroed buffer, as there can't be any 1 bits in tmpW1 tmpW1_MSB = 0 ' clear the MSB of tmpW1; after shifting, some of these bits might be 1 READ Pattern + idx, tmpW1_LSB ' read pattern byte into LSB tmpW1 = tmpW1 << numPixels ' remember it's A WORD, so we can shift the bits over by 5, so they are in the right place outBuff = outBuff | tmpW1 ' OR it onto buffer (bits 0-4 are 0, bits 5-9 are whatever the read data is, bits 10-15 are 0 ' ditto tmpW1_MSB = 0 ' clear the MSB of tmpW1; after shifting, some of these bits might be 1 READ Pattern + idx, tmpW1_LSB ' read pattern byte tmpW1 = tmpW1 << numPixels2 ' remember it's A WORD, so we can shift the bits over by 10, so they are in the right place outBuff = outBuff | tmpW1 ' OR it onto buffer (bits 0-9 are 0, bits 10-14 are whatever the read data is, bit 15 is ' now move to pins outPort = outBuff ' remember we defined outPort as pseudo-Word where the LSB is RB output pins and the MSB are the RC output pins PAUSE 100 ' wait NEXT idx ' next data byte GOTO Main ' do it all again Pattern: ' LED patterns DATA %00000 DATA %10000 DATA %11000 DATA %11100 DATA %11110 DATA %10101 DATA %01110 DATA %11010 DATA %11001 DATA %10110 DATA %00110 DATA %00001 DATA %00011 DATA %00111 DATA %01111 DATA %11111
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php