One for Technical

alband

Senior Member
I have a 7 x 7 grid of LED's in a two layered board. The top layer takes all the negatives in each column and the bottom layer takes all the positives in each row. Therefore any LED can be lit by making a pin low and another high.
I'm using a 40X and the positives are connected to the portc outputs:
Row 1 = portc 1
Row 2 = portc 2
Row 3 = portc 3
Row 4 = portc 4
Row 5 = portc 5
Row 6 = portc 6
Row 7 = portc 7
The negative are connected odly because some of the output pins had to be used elseware (not seen in attached code):
Column 1 = portc 0
Column 2 = out 2
Column 3 = out 3
Column 4 = out 4
Column 5 = out 5
Column 6 = out 6
Column 7 = out 7
This is the code to light all the LED's:
Code:
main:		low 2
		low 3
		low 4
		low 5
		low 6
		low 7
		low portc 0
		high portc 7
		high portc 1
		high portc 2
		high portc 3
		high portc 4
		high portc 5
		high portc 6 'HERE
		goto main
Now, whichever "high portc" I put HERE, that row is brighter. i.e. whichever is last shines brightest.
It is purely to do with order.
Is there a reason for this?
 

BeanieBots

Moderator
That's because it is very last output to be set. It includes a "goto" before any of the other commands are executed and thus is on for slightly longer.
To get around it, insert a short pause between the other lines.
 

alband

Senior Member
Nope, that's not it. If I use "pause 1" It makes the other pins slightly brighter but the last row in the code is brightest.
Code:
main:		low 2
		pause 1
		low 3
		pause 1
		low 4
		pause 1
		low 5
		pause 1
		low 6
		pause 1
		low portc 0
		pause 1
		high portc 7
		pause 1
		high portc 1
		pause 1
		high portc 2
		pause 1
		high portc 3
		pause 1
		high portc 4
		pause 1
		high portc 5
		pause 1
		high portc 6
		pause 1
		low 7
		goto main
It is to do with the portc.
If I put a normal pin (not portc) the last portc is the row that shines brightest.
 

alband

Senior Member
That's wierd; when I use this code, there are no problems:
Code:
main: 	let pins = %00000000
		low portc 0
		pause 1
		high portc 7
		pause 1
		high portc 1
		pause 1
		high portc 2
		pause 1
		high portc 3
		pause 1
		high portc 4
		pause 1
		high portc 5
		pause 1
		high portc 6
		pause 1
		goto main
I can't get "let pinsc = %11111110" to work.
 

alband

Senior Member
Ah, just got "let pinc" working. Did'nt have the "let dirsc" command.
Code:
let dirsc = %11111111
main: 	let pins = %00000000
		let pinsc = %11111110
		goto main
It doesn't matter now but I'm still curious to know why that last row "high portc" shines brighter but only when the "low" command is used for the other pins. :confused:
 

inglewoodpete

Senior Member
I don't know the answer but I suspect that PortC 0 was being left on longer than the others, making it appear brighter. If so, the reason could be due to the way the firmware handles the bothway port - I imagine there would be more to do when toggling a bothway pin.

The only way to prove it would be to use a pulse timer or an oscilloscope.
 
Last edited:
Top