8x8x8 LED Cube Controlled with a PICAXE Microcontroller

nfk

Senior Member
If anyone's interested in building an LED cube that they can control with a PICAXE microcontroller, my daughter and I have just made one from a kit. I'm happy to say that it works fine with PICAXE (we're using HSEROUT at 57600 baud) and we are now having fun writing programs for it.

The problem with the particular kit we bought (which I think is available from a variety of sources) is that all the instructions are in Chinese so we decided to write a blog about how to build it (or at least how we built ours). The blog can be found here:

http://8x8x8ledcube.blogspot.co.uk/

Although we have got the thing working almost perfectly, we do have one mystery to solve - how to 'reset' the cube so that it is expecting the next byte to be a command (not data). If we run it with the software provided, the cube magically seems to know that the first command it receives is indeed a command and not data. We can get around this by simply resetting the cube and PICAXE chip at the beginning of the sequence but it frustrates me that it's clearly possible to do - I just can't work out how. If anyone can guess how it is done please let me know.

Cheers,
Nigel

PS I must emphasise that I have nothing to do with anyone involved in the manufacture or sale of the kit and there may well be better ones out there.
 
Last edited:

hippy

Ex-Staff (retired)
Although we have got the thing working almost perfectly, we do have one mystery to solve - how to 'reset' the cube so that it is expecting the next byte to be a command (not data).
I would have thought the cube would most likely be auto-resetting, go into expecting a command byte if it received no data for a while and would be in command mode after having received a previous command and correct amount of data for that command. Perhaps not. If you can post a link to the datasheet I'm sure people would take a look at it.

It's probably worth starting your program by sending more zeroes than the maximum amount of data it could ever receive in a command and it should then kick it out of any data mode it is stuck in, enter command mode and ignore any zeroes as not valid commands. The next command byte you send should hopefully then be seen as a command.
 

nfk

Senior Member
Hi Hippy,

Many thanks. There is no datasheet - or at least not in English - that's the problem so I'm hoping our blog will help one or two people.

Your idea about sending too many zeroes is excellent but surprisingly it didn't work. A little messing around seems to indicate that it 'listens' for about 1 second's worth of data stream and then somehow recognises where the command bytes are. I will continue to investigate...
 

westaust55

Moderator
Well done on the progress you have achieved to date.

some chips such as the World Semi WS2801 and WS2803 use a break in data transmission of > 500 usec as the mechanism to latch data to the outputs.
Do you have the part numbers for the chip(s) forming the LED cube controller?
That might offer some insight into how it operates.

Any chance of a link to the site where you purchased your cube?
 
Last edited:

nfk

Senior Member
Thanks Westaust55,

I bought the cube from a UK-based eBayer - the link is above the picture of the cube on our first blog page here.

I did try different break lengths to see if that made a difference but it doesn't seem to - although having said that I haven't explore this idea very thoroughly yet.

The LED driver is the TM1818. There are references to it on the Internet although I can't find a datasheet for it. I put a (slightly untidy) list of the components as well as the schematics here.

For interest I attach an example of some code that works nicely with the cube. It randomly lights up one LED in each column.

Code:
init:
	setfreq em8
	hsersetup B57600_8,$00
	hserout 0,($F4,$80)	'Turn the brightness down a bit
main:
	gosub sparkler
	gosub dsp
	goto main

sparkler:
	random w10
	let b15=w10/8192	'Gives you a number between 0 and 7
	if b15=7 then let b15=128:endif
	if b15=6 then let b15=64:endif
	if b15=5 then let b15=32:endif
	if b15=4 then let b15=16:endif
	if b15=3 then let b15=8:endif
	if b15=2 then let b15=4:endif
	if b15=1 then let b15=2:endif
	if b15=0 then let b15=1:endif
	'Horrible way to find 2^x - is there a better way???
	
	random w10
	random w10		'You get a non-random effect if you don't include a second one
	let b16=w10/1024	'Gives you a number between 0 and 63
	let b16=b16+1
	
	put b16,b15
	return
	
dsp:
	ptr=1
	hserout 0,($F2)
	for b0=1 to 8
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
	next b0
	return
It does raise one small mathematical question that I'm sure has been answered many times before - how do you get exponents with PICAXE? It would be nice if I could raise 2 to the power of a variable to avoid that rather messy series of if statements.

Regards,
Nigel
 

hippy

Ex-Staff (retired)
There is no datasheet - or at least not in English - that's the problem so I'm hoping our blog will help one or two people.
Do you have a direct link to the Chinese datasheet, or whatever else you used to get as far as you have in figuring out commands etc ?


It does raise one small mathematical question that I'm sure has been answered many times before - how do you get exponents with PICAXE? It would be nice if I could raise 2 to the power of a variable to avoid that rather messy series of if statements.
To achieve 2n ...

Let var = 1 << n

Let var = DCD n

Lookup n, (1,2,4,8,16...32768), var
 

nfk

Senior Member
Hi Hippy,

Many thanks for the tips about exponents - much appreciated. I'll give it a go.

I figured out the commands by using a terminal application (RealTerm) to look at the output of the PC application that comes with the kit. It's an application that allows you to control the cube via serial. Here is a screenshot...

Capture1.JPG

I understand it's open source and can be downloaded from the Chinese website (http://www.syyyd.com) but it seems that you have to be a registered user to download it and I've never managed to. I got my copy from the guy who sold me the kit.

Nigel
 
Last edited:

nfk

Senior Member
In case anyone's interested, I have just put a very quick video the cube working. I'll try to put up more on the blog as soon as we have written some decent programs for it.

[video=youtube_share;VMLcHFptBmc]http://youtu.be/VMLcHFptBmc[/video]

In this example, it is being run by a 28X2 module. I initially had the processor running fairly slowly but I couldn't believe how fast it went once I set it to run at 64 MHz. When you consider what it's having to do it's a really good way to get an appreciation of how fast modern electronics run!
 

westaust55

Moderator
A search on the manufacturers website (Titan Microelectronics in ShenZhen) finds a link in the English pages where the chip status is "under research and development" but the link to the English pdf datasheet is inaccessible from my current location at least.
http://www.titanmec.com/doce/product-list.html
I can download in Chinese language. Still a fair bit effectively in English on diagrams charts and tables and thus understandable.
 
Last edited:
Top