5x5x5 led cube Manual programming

Hi there,

I was wondering if it is possible to program the 5x5x5 manually. Now you have to use the CubeAnimator, which is fine, but what I would like to do is make some manual programming, in C or C++ or something similar. Are there are specs somewhere on how the things works? I noticed it creates a new COM port, so I assume a program is uploaded using a serial connection?
Is there any more information on this?

Thanks!

The CubeAnimator software uploads the animations you created to the LED cube. What kind of manual programming would you like to do?

C or C++ would be nice
I could be whatever… sorry to say but the Cube Animator is a very limited program. Or maybe you could release the file format for the .cb5 files, so i can generate my own animation files.

Ok I looked into the cube animator files, it stores the leds as bits, where 4 bytes are used for each plane, leaving 7 bits free. Some of those are used to set the intensity of the frame, some other bits are also set, but I don’t know why. They are not needed.

I created this simple C(++) program to test it out, it works great :slight_smile: This code generates a bouncing ball animation of 1000 frames. Looks great on the higest speed.

You can run the code in visual c++ and it will generate the file in c:\

I also uploaded the animation file that you can load into CubeAnimator.

bouncingball.cb5

#include "stdafx.h"

#include <math.h>

//general stuff
bool leds[125];
FILE *fp;

//ball stuff
float ballx, bally, ballz;
float dirx, diry, dirz;
float ballwidth=3.5;


void clear()
{
	for (int i=0; i<125; i++)
		leds[i]=false;
}

void set(int x, int y, int z, bool value)
{
	leds[z*25 + y*5 + x]=value;
}

bool get(int x, int y, int z)
{
	return leds[z*25 + y*5 + x];
}

void writePlane(int plane)
{
	char bits=0;
	char bitcount=7;
	for (int y=0; y<5; y++)
	{
		for (int x=0; x<5; x++)
		{
			if (get(x,y,plane))
				bits |= 1 << bitcount;
			else
				bits &= ~(1 << bitcount);
			bitcount--;
			
			if (bitcount==-1)
			{
				fwrite(&bits, sizeof(unsigned char), 1, fp);
				bitcount=7;
				bits=0;
			}

		}
	}
	fwrite(&bits, sizeof(unsigned char), 1, fp);
	
			
}


void writeFrame()
{
	for (int z=0; z<5; z++)
		writePlane(z);
}

void checkForBall(int x, int y, int z)
{
	//if (x>=5 || x<0 || y>=5 || y<0 || z>=5 || z<0) return;
	float dist =	sqrt(
						(x-ballx)*(x-ballx) + 
						(y-bally)*(y-bally) +
						(z-ballz)*(z-ballz)
					);
	if (dist<ballwidth/2) set(x,y,z,true);
}



int _tmain(int argc, _TCHAR* argv[])
{
	clear();

	fp = fopen("c:\\bouncingball.cb5","w");

	
	ballx = bally = ballz = 2.5;
	dirx = 0.1;
	diry = 0.2;
	dirz = 0.3;

	int frames = 1000;

	while (frames>0)
	{
		clear();

		for (int z=0; z<5; z++)
		{
			for (int y=0; y<5; y++)
			{
				for (int x=0; x<5; x++)
				{
					checkForBall(x,y,z);
				}
			}
		}

		ballx+=dirx;
		bally+=diry;
		ballz+=dirz;

		if (ballx + (ballwidth/4) > 5 || ballx - (ballwidth/4) < 0) dirx*=-1;
		if (bally + (ballwidth/4) > 5 || bally - (ballwidth/4) < 0) diry*=-1;
		if (ballz + (ballwidth/4) > 5 || ballz - (ballwidth/4) < 0) dirz*=-1;

		writeFrame();

		frames--;
	}
	

	fclose(fp);

	return 0;
}

It would be great though if more information would be given bij velleman about the chips, the programs that run on the MP, the protocol used by the cubeanimator etc. etc.
For example I would love to make it so that some leds are more brighter than others in the animation. I cannot do that with the cubeanimator, but I think it should be possible if we could do more hacking on this neat thing, but there is hardly any information on the software-side of the project.

Sorry, for copyright reasons we never release firmware.
If we would do that, we would be out of business soon.
It is a lot of work to write firmware, so it is expensive, as our engineers don’t work for free.

Basically, you have the diagram, you know what PIC is used, the PIC datasheets are available from Microchip, so you could write your own firmware.

Well first, you can release it under some licence that makes sure nobody can just take your project and firmware and sell it themselves.

Second, 99% of your customers are not going to know, or care, about the details of the firmware. They just see the product in the store, buy it to assemble and have fun making some animation. The fact you put some details about the software and/or firmware somewhere on the internet is not going to change that. Most people do not care and do not have tools to program the PIC anyway. For myself I also don’t need to know everything. I assume there is some pre programmed part on the PIC, and some part is uploaded trough the cubeanimator? Or how does it work? I just want to mess around with it a bit, see if I can improve it without reprograming the whole PIC.

And third, it might even be an advantage to be a bit more open source. Then hobbyist can extend your project further so it becomes more interesting and have more features, all free of charge for Velleman.

Anyway, I’ll just try for myself to fiddle with it for now, but I just wanted to point out that releasing more details about software and firmware on your projects is not necessarily a bad thing. I would be very surprised if you would sell less cubes if you gave out some more details…

Sorry to revive this,
Anything to tell, show, say on the data exchange between the cube and a PC?

(i have no windows system, so i need to have something running on linux).