Led matrix I/O pin setup ?
Areal Person
Posts: 197
·
Ok, I’m a newbe at this and I don’t want to blow up allot of
Led’s so I need some help.
·
I’ve made a led matrix of 10 rows and 10 cols or so of ·leds
·
There are 10 rows that all the anodes on that row are connected to, and there are 10 columns that all the cathodes on that column are connected to.
·
Now, if I apply current to a row and then ground a single column pin I can turn ONE(1)
Led on, however if I ground all the cathodes the whole row will come on.
·
QUESTION:
·
How to I wire the leds for the propeller so I can toggle a I/O pin and only have 1 led on a row come on based on the column (how do I set up the column pin to ground)? Do I need to use two pins in order to turn one led on ? How do I ?
·
QUESTION #2
·
Do I still need to use a resistor, I know this is common knowledge, but I’ve not worked with the propeller in a while.
·
Please help,
Thanks,
-Areal
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but
what do you expect ? I'm a programmer.
Ok, I’m a newbe at this and I don’t want to blow up allot of
Led’s so I need some help.
·
I’ve made a led matrix of 10 rows and 10 cols or so of ·leds
·
There are 10 rows that all the anodes on that row are connected to, and there are 10 columns that all the cathodes on that column are connected to.
·
Now, if I apply current to a row and then ground a single column pin I can turn ONE(1)
Led on, however if I ground all the cathodes the whole row will come on.
·
QUESTION:
·
How to I wire the leds for the propeller so I can toggle a I/O pin and only have 1 led on a row come on based on the column (how do I set up the column pin to ground)? Do I need to use two pins in order to turn one led on ? How do I ?
·
QUESTION #2
·
Do I still need to use a resistor, I know this is common knowledge, but I’ve not worked with the propeller in a while.
·
Please help,
Thanks,
-Areal
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but
what do you expect ? I'm a programmer.
Comments
WRT the propeller, the pins are assumed to be current limited @ 40 mA, but this is much to much for most LEDs. However a good technique is using PW-modulation with a duty cycle so that the mean current comes arount the LEDs capacity.
This is risky however, for the smallest progarmming error will most likely burn your LEDs so take resistors .
Post Edited (deSilva) : 8/17/2007 7:04:15 PM GMT
where the all the leds anodes are on the same i/o pin.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but
what do you expect ? I'm a programmer.
To light up an LED, set DIRA for the row and column pins you want to use to output (1). Set the OUTA for the row to high (1) and for the column to low (0). This will light one LED.
Is 410ohm resistor ok ?
I could not be successful without everyone’s help, I really am new to electronics.
Actually this is my first electronics project ever !
I’m thinking about making a utube video in a day or so, I’m almost finished with this
project. I’ll post the link asap.
I had to build a DIY CNC machine to mill the PCB and also drill the black acrylic panel
for the cover.
And it's actualy a 15x9 RGB Led Matrix Panel 19mm dot pitch
Thanks,
-Areal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but
what do you expect ? I'm a programmer.
I'm assuming these are red LEDs with a Vf (forward voltage) of 1.7V. Other colors will have different forward voltages.
The Propeller pins go from about 0.3V to about 3.0V, so you have to drop about 3.0V - 0.3V - 1.7V using the resistor = 1.0V.
Ohm's Law is: E = I R or I = E / R or R = E / I. In this case: R = 1.0V / 0.02A = 50 ohms. Using 1/2 in the anode circuit and 1/2 in the cathode circuit give you about 25 ohms. The nearest standard value is 27 ohms.
If you use a 410 ohm resistor, you'll get: I = E / R = 1.0V / (2 * 410 ohms) = 1.0V / 820 ohms = 1.2ma.
That will give enough light to notice in a dim room, but not much more. You need a minimum of 5-10ma for decent light.
Go with the 27 ohm resistors. That will give you the maximum constant current for most LEDs and will let you
experiment with dimming using PWM and scanning the matrix.
-Areal
CON
'Set clock speed to 80 MHz
· _clkmode = xtal1 + pll16x······· 'Sets the clock speed to 80 MHz using a times 16 multiplier
· _xinfreq = 5_000_000············ 'Crystal speed: 5 MHz
'
· High = 1························ 'A CONstant used to set an output port to about 3 volts
· Low· = 0························ 'A CONstant used to set an output port to about 0 volts
· Out = %1························ 'A CONstant used to set a port's direction to Out
'
VAR
· Byte Row························ 'Declares Pin to be a global VARiable of a type Byte
· Byte Col························ 'Declares Pin to be a global VARiable of a type Byte
'
PUB Start························· 'A PUBlick procedure named Start····························································
· FlashLEDS····················
'······························································································································
PRI FlashLEDS····················
· Row := 17······················· 'Assigns 17 to the variable Pin
· Col := 16······················· 'Assigns 16 to the variable Pin
····································
· DirA[noparse][[/noparse]Row] := Out················ 'Makes port A16 an output port
· DirA[noparse][[/noparse]Col] := Out················ 'Makes port A17 an output port
· OutA[noparse][[/noparse]Row] := High···········································
· OutA[noparse][[/noparse]Col] := Low········
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but
what do you expect ? I'm a programmer.
The problem is that the start routine calls FlashLEDS, then exits which resets the cog it's running on.
That makes all the I/O pins inputs. At least put a "WAITCNT(CLKFREQ + CNT)" after the call to
FlashLEDS. That will pause the cog for a second after turning the LEDs on.
-Areal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but
what do you expect ? I'm a programmer.
Many persons prefer a SPIN operation, written ~ and ~~
This - used in a postfix position - will clear or set the bits of a variable or I/O pin or pins independent of their length.
Example:
OUTA[noparse][[/noparse] 3 ]~ is OUTA[noparse][[/noparse] 3 ] := 0
DIRA[noparse][[/noparse] 3 ]~~ is DIRA[noparse][[/noparse] 3 ] := 1
DIRA[noparse][[/noparse] 0..3 ]~~ is DIRA[noparse][[/noparse] 0..3 ] := %1111 (or DIRA | $F)
ROW ~~ is ROW := $FF
Nb. It is not my intention to recommend this; I think the "old fashioned" way is much clearer. But I have the impression you will have A LOT to set and clear....
Memory hook: ~~ is "more" than ~ as 1 is "more" than 0
In the CON section, only an equal sign is used. The single equal sign is used to imply "is defined as" while the colon-equals is used to indicate the assignment operation.· The single equal sign functions as a compile-time operation while the colon-equals works only at run-time.· I know some languages don't make the distinction, but in Spin (and in Pascal for instance) this convention is used.
Post Edited (Mike Green) : 8/18/2007 12:13:06 AM GMT
(mutter, mutter. Another Hairshirt to wear. mutter, mutter)
This is OT:
I think this is one of the 10 or 12 wrong decisions taken during the design of SPIN. There is no need for it, as constant expressions are constrained to the CON section and there can never be any doubt. The reasons ALGOL-like languages used this notation have long been forgotten by the global use of "=" as assigment operation.
But there is one merrit (And I thinkl this could have been one of the reasons for Parallax's decision): There can be no undetected "=" within a condition expression. (Which contributes about 10% of all bugs in C programs )