LED Cube Questions

DDJ2011

Member
Well, my daughter's water spraying alarm clock got nowhere - not helped by me fritzing the pump the day before the competition!

My next project will be an LED cube. I'll be starting small - 3*3*3 single colour to get my eye in, but ultimately I'd like to do a 7*7*7 (or maybe 9*9*9) RGB like this one.

http://www.youtube.com/watch?v=59qIZKKGrkM

The good stuff starts 1 minute in - it's the best home-made LED cube I have ever seen, although you can buy a kit and just assemble it.

There are plenty of hints and tips out there for smaller cubes which I will work through, however I am also looking to the future and would appreciate your thoughts.

** If I'm using chips to enable more outputs than the picaxe provides I don't need to use multiplexing or charliplexing, right?

** Looking at that video and combining that with my very limited knowledge of electronics, will a picaxe be fast enough to switch the various lines on and off to create similar effects? It uses a PIC16F688-I/P chip which I guess does not have the overhead of Basic interpretation?

** For program memory, can a Picaxe handle what is required? I'd like to have a pre-programmed section - say the waves or upward rain in the video - but also have a randomly generated section, then finally loop around the lot.

** If there is a chance that the program memory is not enough, I'd like to design the circuit to be able to read from a memory card - I could store the pre-ptrogrammed stuff in there - can you point me in the direction of threads here which cover (simply!) how to write to and read from a memory card or chip?

Many thanks,

DDJ
 

PaulRB

Senior Member
Hi DDJ, I have not (yet) attempted LED cubes, but no-one else has replied yet, so...

If I'm using chips to enable more outputs than the picaxe provides I don't need to use multiplexing or charliplexing, right?
Yes, although depending on what chips and which picaxe, there may be some overheads for communicating with them. For example, unlike the x2 series, the m2 chips don't have hardware SPI interface, so if using chips with that style of serial interface you must do it in software (note there are faster ways than the example code in part 2 of the manual).

Looking at that video and combining that with my very limited knowledge of electronics, will a picaxe be fast enough to switch the various lines on and off to create similar effects?
Tough question, but you can crank an m2 chip up to 32MHz, or an X2 up to 64MHz, and combining that with chips to relieve the picaxe of any multiplexing duties, I bet you can get a long way.

For program memory, can a Picaxe handle what is required?
The X2 series have multiple banks of program memory.

If there is a chance that the program memory is not enough, I'd like to design the circuit to be able to read from a memory card - I could store the pre-ptrogrammed stuff in there - can you point me in the direction of threads here which cover (simply!) how to write to and read from a memory card or chip?
There are examples in the manuals of using i2c eeprom chips. Getting the data into them could be awkward though.

Good idea to start with something simple, like 3x3x3 or 4x4x4 and a 14m2 or 20m2 and work up from there.

Cheers,

Paul
 

hippy

Technical Support
Staff member
Key to success is the hardware; an 8 x 8 x 8 RGB cube with a layer of LED's controlled at a time with a 50Hz refresh rate only needs to send out 24 bytes of data every 2ms. A 20X2 at 64MHz can achieve that in under 400us using HSPI so it should be achievable.

Note that gives even greater control than the one in the video; allows seven colours rather than just three and multiple colours on at the same time.

Trying to only multiplex with no hardware assist is likely to be difficult to impossible, not just having only 13us per LED, but each LED will only be on a maximum of 0.07% of the time so quite dim, and even over driving current may not make them bright enough.
 

Buzby

Senior Member
Hi DDJ,

I too have not built a big LED cube, but I have driven hundreds of LEDs from a PICAXE, so I've got a bit of knowledge about this.

Your first point, direct drive or multiplexing or charliplexing ?.
Don't try charliplexing. it won't work for this application. Too many LEDs need to appear on at once.
Direct drive will work fine, but need a *lot* of hardware. ( Don't forget,the number of LEDs goes up in powers of 3. A 7x7 block has 343 LEDs, 8x8 has 512, 9x9 has 729 Triple all these if you want RGB. )
Multiplexing gives you the best of both worlds. Modern LEDs can still be bright even when multiplexed, and the hardware requirment is dramatically reduced.

Is a PICAXE quick enough ?
Yes, but you have to know how to program for speed.

PICAXE memory big enough?
Program memory - yes. Data memory - it depends.
For an 8x8 ( I wouldn't consider less if you want to make shapes like the video ) to display a shape needs 64 bytes ( assuming single colour ).
To get smooth movement you will need maybe 8 per second, thats 512 bytes per sec.
So 4K memory page in a PICAXE would give 8 seconds of continuous monochrome movement.
Obviously this can be split into short sections and repeated in different sequences, but that all adds to the effort need to code it.

Extra memory ?
Yes, SD or I2C.
I2C is easy, and PICAXE drives it easily.

So all in all I see no reason why you shouldn't have I go.

I'll tell you why I didn't.
I made a 4x4, it looked crap !. Just a bunch of LEDs flashing.
It was too small to get any smooth movement. It needed to be bigger, 8x8 was my minimum.
There would be no problem with the PICAXE code, it just needs to select the data and put it on show.

What put me off was the patterns.

How would I design the hundreds of patterns. I could see me with sheets of graph paper everywhere.
Then, how would I enter the 10's of thousand of bytes needed to hold those patterns.

In the end I decided that the 8x8 would need too much boring work, not the interesting stuff like how to drive the LEDs, or the infrared remote I was going to use.

I'm not trying to put you off, big LED cubes are very impressive, but they take more than engineering effort to make the shapes look good.

Good luck,

Buzby

EDIT : Just to clarify. After reading hippy's post it might look like I was suggesting full software multiplexing. No way !. You will need some hardware, just not as much !.
 
Last edited:

PaulRB

Senior Member
Don't try charliplexing. it won't work for this application. Too many LEDs need to appear on at once.
An interesting challenge!

If you haven't read up on Charlieplexing yet, DDJ, you normally only light one led in the matrix at any instant. So with careful programming to make fast switching, you can make several appear lit at once.

What if you Charlieplex each layer of a 3x3x3 with a separate matrix? Each matrix would need 4 lines, 12 in total, so a 20m2 might be up to it at 32MHz.

The wiring would be a nightmare. But the component count would be minimal - 12 resistors, 27 leds, 1 picaxe and... that's it.

Paul
 

Buzby

Senior Member
Hi Paul,

I charliplexed 552 LEDs, and found that lighting 20 at a time was starting to push the envelope.
It's fine for up to about 15 at a time, no matter how big the matrix is.

The images for an 8x8 will have lots more thasn 15.
Imagine an image which is just two flat sheets, each 8x8, approaching each other from opposite sides.
This has a total of 128 LEDs lit at any time.

I've never tried charliplexing multiple matrices, but obviously that will give better results.

Charliplexing is also very code intensive. It's difficult to build the code incrementally, you need to have lots of it running before you see anything.
( The difficulty comes from trying to display images which are stored as bitmaps. I do however have an idea to make it much simpler, but it means storing the images differently. )

It is a misconception that wiring a charliplex is more difficult than a multiplex. It's the same complexity, but with different pin numbers.
You must have a plan to follow, it's not just linking all LEDs in a row or column like multiplexing does.

Cheers,

Buzby
 

PaulRB

Senior Member
Buzby, I wasn't really making a case for using Charlieplexing on 8x8x8 matrix. But DDJ wants, quite sensibly, to start with 3x3x3 or 4x4x4 single colour.

So your finding of up to 20 charlieplexed leds lit at once would cover it, if you had one matrix per layer.

For 4x4x4, you would need 5 lines per layer, 20 in total, so I think a 28x2 at 64MHz could work.

For 5x5x5, you would at least start to need some transistors I think, as otherwise the total current would exceed picaxe maximum.

Your 500+ charlieplexed leds beets my one-any-only attempt so far hands down. I have done 20, with only one lit at a time! You are right about drawing up a plan for the wiring. Even then it took me 3+ attempts to follow my own plan without making a mistake! Luckily I was breadboarding, so nothing wasted except time.

Paul

PS. Can you give us a clue about the three wet legs, or is it too rude?
 

DDJ2011

Member
Hippy,

This looks like good news but I'm interested in the maths you have used here - can you explain more how you worked this out?

Key to success is the hardware; an 8 x 8 x 8 RGB cube with a layer of LED's controlled at a time with a 50Hz refresh rate only needs to send out 24 bytes of data every 2ms. A 20X2 at 64MHz can achieve that in under 400us using HSPI so it should be achievable.

Note that gives even greater control than the one in the video; allows seven colours rather than just three and multiple colours on at the same time.

Trying to only multiplex with no hardware assist is likely to be difficult to impossible, not just having only 13us per LED, but each LED will only be on a maximum of 0.07% of the time so quite dim, and even over driving current may not make them bright enough.
Many thanks,

DDJ
 

hippy

Technical Support
Staff member
For the layer at a time -

1 second / refresh rate / layers = time per layer

1000000us / 50Hz = 20000us
20000us / 8 = 2500us = 2.5ms per layer

For one LED at a time -

1 second / refresh rate / number of LED's = timer per LED

1000000us / 50Hz = 20000us
20000us / (8x8x8x3) = 13us per LED

Percentage time LED is on for -

13 = (n%/100) * 2000

n% = 13 * 100 / 2000 = 0.065% = 0.07%
 

Buzby

Senior Member
... For one LED at a time -

1 second / refresh rate / number of LED's = timer per LED

1000000us / 50Hz = 20000us
20000us / (8x8x8x3) = 13us per LED
Quite true, if you need to control all 512 LEDs at once.

But charliplexing only lights the LEDs that need to be on, no matter how big the cube.

My experiments with lots of charliplexed LEDs showed that lighting about 20 was the limit, .i.e 5% of the time, using the very basic code I wrote.

I think to determine the feasabilty of charliplexing an 8x8x8, there will be a need to find out more about patterns.

There are a few LED cube simulations on the web, cubesense is one, but I've not tried any. ( When I was contemplating an 8x8x8 there was no web !. )

It may turn out that charliplexing, plus a more intelligent storage strategy, may make an 8x8x8 from a single 40X2 a possibility !
 

Phil bee

Member
Hi my solution is to use MAX6956 i2c port expander chips or the MAX6957 spi version to drive my 5*5*5 cube and have got the basic PCB design for a stackable shield with 2 6956's that can be stacked 8 hi.
 

PaulRB

Senior Member
It may turn out that charliplexing, plus a more intelligent storage strategy, may make an 8x8x8 from a single 40X2 a possibility !
Oh no, what have I started!?!

If you only want to light 20 "at once" out of 512, you would only need 24 in/out lines, which a 40x2 probably has. But if you want to light 20 per layer, you would need 9 x 8 in/out lines, so lots of support chips needed, so might aswell do full/proper multiplexing.

I still can't understand why you say wiring a charlieplex matrix is no more complex than ordinary matrix. Maybe I just can't picture the topology in my head that makes it easiest.

Paul
 

hippy

Technical Support
Staff member
Some timings which may be of interest. This is a traditional 8 x 8 multiplexor, one LED at a time; LED anodes to pinsB ( active high ), cathodes to pinsC (active low ), no resistors on LED's - Take care !!!

Code:
#Picaxe 28X2

SetFreq EM32

dirsB = %11111111
dirsC = %11111111

b0 = $FF
b1 = $FF
b2 = $FF
b3 = $FF
b4 = $FF
b5 = $FF
b6 = $FF
b7 = $FF

Do
  Gosub Frame
Loop

Frame:
  bPtr  = 0
  pinsC = %01111111 : Gosub Row
  pinsC = %10111111 : Gosub Row
  pinsC = %11011111 : Gosub Row
  pinsC = %11101111 : Gosub Row
  pinsC = %11110111 : Gosub Row
  pinsC = %11111011 : Gosub Row
  pinsC = %11111101 : Gosub Row
  pinsC = %11111110 : Gosub Row
  Return

Row:
  pinsB = %10000000 & @bPtr
  pinsB = %01000000 & @bPtr
  pinsB = %00100000 & @bPtr
  pinsB = %00010000 & @bPtr
  pinsB = %00001000 & @bPtr
  pinsB = %00000100 & @bPtr
  pinsB = %00000010 & @bPtr
  pinsB = %00000001 & @bPtrInc
  pinsB = 0
  Return
At 32MHz that runs with a frame time of just under 12ms, just over 84Hz refresh, is flicker-free, the LED's are a bit dim but bright enough to be usable.

Extending the frame time towards 25ms/40Hz it still seems flicker free, LED's still bright enough but slower and it starts to feel more flickery.

In-lining the code ( no GOSUB's ) and the original 12ms/84Hz improves slightly to 10ms/100Hz.

From all that it seems entirely possible at 64MHz to individually refresh 16 x 16, 64 LED's in total, and I'd edge towards betting 5 x 5 x 5 is possible, even RGB if you only wanted one colour at a time.
 

Buzby

Senior Member
A warning about charlieplexing RGB in one grid. The different Vfwd can cause spurious twinkles in LEDs which are supposed to be off. You can just see it faintly in my orrery. ( See blog )
 

PaulRB

Senior Member
If you read the thread from the beginning you will see I couldn't picture the topology either, until it just clicked !.
I read that thread ages ago. But that's a 2-D matrix.

I understand how a conventional led cube is constructed. Like the steel frame of a building. The anodes form the columns and the cathodes form the floors (or vice versa). Multiplexing enables one floor at a time. The columns determine which leds light up on that floor.

How do you map the 2-D matrix onto a cube without the wiring becoming horribly complicated?
 

Buzby

Senior Member
How do you map the 2-D matrix onto a cube without the wiring becoming horribly complicated?
It looks complicated, but there are patterns very similar to 2D matrices.

In the picture below, each letter represents one of the 24 bits on 3 PICAXE ports, and each letter pair represents the connections to a single LED.

For convenience we will call the first letter of each pair the Anode and the second the Cathode.

The eight shaded groups each represent a single 'layer' of the cube.

Consider the top-right group.

The first rank of 8 LEDs all have their Anodes connected to 'Q'.
The second rank 0f 8 LEDs all have their Anodes connected to 'R'.
Etc, etc.

The first file of 8 LEDs all have their Cathodes connected to 'A'
The second file of 8 LEDs all have their Cathodes connected to 'B'
Etc, etc.

Some files are split between two letters, mainly along the diagonal, but the pattern is similar.

There's a bit of a break in the pattern on the very bottom row of the bottom two groups, due the 7/8 mismatch.

( This took me 20mins in Excel, so it might not be optimum. )

Physically constructing this would be not much different to constructing a 2D.
You would still have a jig to hold the LEDS in place while you soldered them, and a wiring plan.

( To see a serious cube, search Youtube for 32x32x32 RGB. I doubt that uses Charliplexing, but I'll bet he still had a wiring plan !. )

Cheers,

Buzby





CharlieplexCube_1.jpg
 

DDJ2011

Member
More Efficient Lighting Strategy?

Apologies if this is old news but I haven't seen it documented elsewhere.

Also, if I am missing something obvious here by proposing this approach please explain why so that I don't waste any more time on it!

In thinking about the time available to light each LED I think that there are efficiencies to be gained by careful design of the characters to be displayed (I'm using characters loosely here - I don't mean just letters and numbers but would apply this process to any fixed shape).

I have worked this out for capital letters so far, and believe that I can display any of them with a maximum of 4 cycles on a 5*5 grid. When you look into the letters I have designed, the most LEDs required to be lit is 14 (letters G and R). If I were to light each LED in turn that would be 14 cycles. My approach saves a maxium of 12 cycles (on letter G by coincidence), a minimum of 4 cycles (letter Y) and an average saving of 8.5 cycles across all letters.

I have tried to show this in the attached image, where each set of LEDs to be lit is numbered for the cycle that lights it. My assumption is that the persistence effect is largely driven by the off-time of the LEDs. By reducing the number of cycles I also reduce the off-time, which should - in theory - produce a better effect.

@Buzby
In the end I decided that the 8x8 would need too much boring work, not the interesting stuff like how to drive the LEDs, or the infrared remote I was going to use.
My background is in software development, and while I like the electronics (altho I'm not very good at it) I'm going to get as much of a kick out of designing the patterns as I will out of actually making a big cube that works.

As always, happy to receive your thoughts and wisdom!

DDJ
Letters.jpg
 

PaulRB

Senior Member
Sorry DDJ, Buzby and I hijacked your thread to talk about charlieplexing!

Buzby seems to be up for the challenge of charlieplexing an 8x8x8, but it will be limited in terms of the patterns it could make. I still haven't worked out how to make 3x3x3 work without turning it into a bird's nest of wiring.

Suggest you stick to using additional driver chips.

Paul
 

DDJ2011

Member
No problem.

I have given up on Charliplexing - it's an interesting concept but not right for this project (for me anyway!).
 

Buzby

Senior Member
Hi DDJ,
You are right, charlipexing 8x8x8 is not proven to work, stick with multiplexing for a guaranteed result. I'm just interested in the possibility. Good Luck !

EDIT : I'm going for an 8x8x8 !. See blog.
 
Last edited:
Top