An Intro to arrays

Zanthess's picture
A way to control more LEDs than you have pins in your chip!

Description: 

Update: I added a video with my grad cap hacked with 64 individually addressed LEDs! This multiplexing/matrixing/array-ing sure is fun :3

This is pretty barebones so far. Be assured, more infomation will be added as I push along.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

First I started with a really basic setup: 16 LEDs controlled by 16 pins. This is great, but leaves no pins left for output! Being limited makes me antsy, so I sat down and figured out how to get more.

Matrices.jpg

Here is the code(first video):

main:

for b0 = 0 to 7
high b0
pause 250
low b0
next b0

for b0 = 0 to 7
high pinsc b0
pause 250
low pinsc b0
next b0

goto main

 

Controlling 16 separate motors/lights/etc. is great and all, but what if you want to do more?

I removed one 8 LED output bank and set up two of the free pins as "enablers". The 8 led pins are pulldown pins, and each enabler pin supplies a logic on/off to a 2N3904 Transistor to supply a +5 voltage.

Matrices__2_.jpg

A small change in code, and we are back in business! (second video)

main:

high pinsc 0
for b0 = 0 to 7
high b0
pause 250
low b0
next b0

low pinsc 0 high pinsc 1

for b0 = 0 to 7
high b0
pause 250
low b0
next b0
low pinsc 1

goto main

 

10 pins to control 16 LEDs? Cool!

This can be worked further. How many can we control with 16 pins?

With mathematics, all you have to do take the total number of pins you can use, divide by two, and then square that number.

With 16 pins: 16/2=8, 8^2=64! That's pretty sweet if you ask me.

This is just with one Picaxe 28x1 chip, what could we use to multiply the out pins with other chips to control a multitude more?

Your rating: None Average: 5 (1 vote)
buhatkj's picture

or you could maybe use one

or you could maybe use one of these?

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=296-8757-5-ND

I have not as yet, but it seems like it should allow you to make 16 outputs from 4.  Seems nifty anyways...

:-)

Zanthess's picture

ooh, I might have to try

ooh, I might have to try some of these out!

I'm preparing a digi-key order right now, so I'll have to add one of these on :)

Thanks for the link!

CaptainTuna's picture

you could also use nothing

you could also use nothing but 8 pins to control 16 leds! 

Think about arranging them in columns and rows. That's gonna give you a 4x4 matrix. Now you just need to connect all the anodes of every row (opposite would work as well: cathodes of every row, no change) to an output and every cathode of every column to an output. (hope i made myself clear) Then what you want to do is rapidly activate HIGHs and LOWs to control all of them! 

But still charlieplexing is better... if you're using similar LEDs (similar voltage drops to be more precise)

Zanthess's picture

Funny how I miss that... I

Funny how I miss that... I guess I was just lazy and didn't want to make lots of changes, since I was planning on hooking up 64 LEDs with the current circuit.
OddBot's picture

With or without additional hardware, that is the question.

I agree that without additional hardware (what are all those chips? you only need the picaxe :/) 16 pins can control 64 leds if those pins can only go high or low. Because picaxe pins can also go high impedance (input) it is possible to do more. This is called Charlieplexing. If you have n number of pins then you can control n(n-1) LEDs from a pic proccesor. This method does have limits to size.

Using additional hardware such as the 4 to 16 decoder suggested by buhatki or serial in/parallel out ICs such as the 74hc164 your only limited by how fast you can update the display.

ndupont's picture

counters will do the job

16 leds on each 4 to 16 decoder

one  4 bit counter to control each decoder   (two counters in each 7459 package)

cascade the counters 

--> 1 pin to count

--> 1 pin to reset 

 

My only concern is speed ,  but there are chips running upto 100Mhz

mintvelt's picture

Your breadboard looks so

Your breadboard looks so tidy!
Zanthess's picture

I can't stand messes on

I can't stand messes on breadboards... so hard to troubleshoot!
rik's picture

clean and methodical

Just the way I like'm!

8ik

Zanthess's picture

Thankies :)

Thankies :)
fritsl's picture

This may kill the fun, but

This may kill the fun, but it may start some new fun: http://letsmakerobots.com/node/131
jka's picture

For added fun, check out

For added fun, check out Microchips MCP23016, 23017 or 23018, which is 16port I/O expanders for I2C, capable of 3 different speeds. It also exists in a serial version, which can run faster than the I2C editions:

http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=11034&mid=...

Also, you can check out the 74HC595, which is an 8-bit serial latch, but they are output only. There is an equivalent input chip, which I can't remember the name of.

Zanthess's picture

So many new chips to

So many new chips to experiment with!

This walkthrough was mainly to highlight using less pins to get more out with only one chip. Just interesting how many different ways there are to achive this :) 

fritsl's picture

STOP RESISTING!You want more

STOP RESISTING!

You want more chips!

Zanthess's picture

My school as drilled into me

My school as drilled into me finding the cheapest way to achive something. Companies look for that, so I keep training myself that way.

If I wasn't working towards a career in designing circuits, I'd say "to hell with it" and go the easy route :P

OddBot's picture

Ultimate 3D LED array!

This is the most impressive LED array I've ever seen, must have cost a fortune in LEDs.

16x16x16=4096 RGB LEDs!

http://www.youtube.com/watch?v=Aj3_v7xCyJ0&feature=related

Although this is probably more in our price range, driven by a Pic processor not a super computer!

http://www.youtube.com/watch?v=_SO1J1kP3YQ&feature=related

Zanthess's picture

Well, if one picked up 4

Well, if one picked up 4 chips that buhatkj suggested, we'd have a total of 64 ports out.

so.... (because I love numbers) 64/2 = 32, 32^2=1024

Still being controlled by a picaxe, would be quite impressive ^_^

OddBot's picture

Fair enough

Just out of curiosity, do you work out a schematic first or do you just do it in your head? I don't remember any schematics with Mr. Tea.
Zanthess's picture

I did it in my head. I

I did it in my head. I rarely put stuff on paper, and I think that's what gets me in trouble most times. I did do one schematic, just for the picaxe part, because I had to attach the box to the back of the machine, and needed to color-code my wires.

jklug80's picture

I don't do schematics

I don't do schematics either. I solder first and ask questions later. I usually test after each chip is put in place though. For example I solder a chip, power supply, and stereo socket into place and see if I can transfer code. Then solder in a motor driver and see if it will make motors work, then...
Zanthess's picture

I won't solder until I've

I won't solder until I've set up a schematic. Breadboarding is easy, but I hate HATE H.A.T.E. desoldering. I try to atleast get something on paper that shows what connects to what, even a small scribble helps :P
TheCowGod's picture

That graduation cap is

That graduation cap is pretty awesome :) That'd make a great robot after you're done with it. It could drive around your house and find college degrees to obtain.

Dan

Zanthess's picture

That would be quite

That would be quite interesting.

I think what I'll do is take the cap and hang it on the wall of my workspace, as soon as I'm given one other than the dining room :P

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.