3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

LED Cube 8x8x8

Step 64PC Software: Introduction

PC Software: Introduction

The cube just receives binary data via RS232. This data could easily be generated by a number of different programming languages, like python, perl or even php.

We chose to use C for the PC software, since the micro controller software is written in C. This way effects from the micro controller code can just be copy-pasted into the PC software.

Just like in the micro controller code, this code also does two things. Where the micro controller has an interrupt routine that draws the contents of cube[][] onto the LED cube, the PC software has a thread that continually sends data to the LED cube.

« Previous StepDownload PDFView All StepsNext Step »
26 comments
Apr 30, 2012. 2:43 PMjenkycents says:
how i can run this "PC Software "?
Apr 30, 2012. 5:19 AMjenkycents says:
some one can send to me the hex file of these effects ?
i can't compile them :(
Jan 28, 2012. 12:41 PMmoubette says:
Hi!
My cube works fine with the usbtiny, but it doesn't work with the rs232 cable and i don't understand why?
i checked the used port (for my usb-serial cable) and used the procedure of ristdaro (on ubuntu 11.10)
I succeed to create the new file "cube" then execute it with the following command:
"sudo ./cube"
but nothing happens.
What can I do? what do I have to test and how? is that the LED on the card (rs232) should light?

Thanks in advance for your help
Feb 9, 2012. 7:25 AMmoubette says:
since the beginning of the construction of my cube, my secret dream is to create a snake game on the cube, but without this connection, I can't do it.... :(
........ please .... help me
Feb 10, 2012. 3:21 AMtriumphtotty says:
Hi. There was a slight error on the schematics for the MAX232 to the I/O pins on the ATmega32. Basically they are swapped (in-in, out-out instead of in-out, out-in). Check if you have followed the schematics, and if so swap pins 14 and 15 (I think!) on the microcontroller and try again. I don't think the RS232 LED is actually used by Chr's code, but one of the two normal status LEDs, LED_RED, should "flicker" every time data is received on the RS232 bus.  You could even try opening a serial terminal window to your RS232 interface and type some random data to check that comms are working?
Feb 13, 2012. 10:07 AMmoubette says:
Thanks for your answer. Indeed, i followed the schematics of Chr, however I fixed it but it still doesn't work. I should probably have a problem either in the send data in the program execution either in the adapater USB/RS232.
I will look again...
Jan 11, 2012. 4:51 PMBlackX777 says:
Im managed to compile pc software for windows using cygwin.

A default installation of cygwin doesn't work so I installed it full (7 GB :o).
Copy the Sources to your \cygwin\home\name folder.

Change "/dev/ttyUSB0" in cube.c in the cube_init function to e.g. "/dev/ttyS2" for COM3 in windows. Mine is a vitual com port using a uart to usb converter.

Start cygwin terminal and type "make" you should get an cube.exe which needs the cygwin1.dll in the same folder to run. You can find them in \cygwin\bin.

WARNING: To get it run, you must first make a connect to the desired com port using a terminal programm e.g. HTerm. (I have no idea why, its a workaround.)
Set the right baud rate (38400) klick Connect then Disconnect and close the terminal.

Now you can try cube.exe, best in command prompt.

If you get an error like: /dev/ttyS0: No such file or directory you set the wrong com port.

You may also note:

Masterfruit says:
sorry, havent read here for a long time... i postet the solution already somewhre else, so just the quote here:

If you are using a physical Com Port of you computer you have to add a flush command to send the data faster

add to the cube_push function in the cube.c
tcdrain(tty)
behind the write command - it should work
Dec 31, 2011. 12:06 PMristdaro says:
My procedure for getting the rs232 up and running

Install unbuntu 11.04
in terminal type the following to install:

sudo apt-get install gcc-avr
sudo apt-get install binutils-gold

sudo apt-get nautilus-open-terminal

i used a prolific usb-serial cable
checked that comms pointing at usb0 or usb1 with command 'dmesg'
if pointing at wrong port change cube.c and re-compile
open source folder cube_pc in terminal and type ;make'
copy the newly created file 'cube' to nautilus terminal window

worked perfectly for me!
Aug 9, 2011. 12:12 PMlazardj says:
can some1 give me changed code for windows so i can use rs232 on windows...

I have made cable and have rs232 port but now i need code for windows...

Thanks in advance
Dec 30, 2011. 2:38 AMristdaro says:
Hi,
Did you ever get the code to work in windows using winavr?
Dec 30, 2011. 1:34 AMristdaro says:
Hi,

Have any bright sparks out there managed to successfully get the software to run in winavr - windows xp without using unbuntu?

Apr 22, 2011. 12:32 AMIce1 says:
I dont understand how to use this source code to send binary data to the RS232. When i try to compile it using avr-gcc it says the system cant find the file specified. Can someone please make this step clearer, its like chr forgot to explain how to do this.
May 9, 2011. 4:30 AMMasterfruit says:
@Step 64 and above: Heres what i have discovered so far for the RS232 thing...

However, i don't have any understanding of coding in any language nor have i ever programmed any ic or chip or whatever.. this was my first project with an atmel chip.

Apparently its easy to compile the RS232 code provided by chr in linux... just "make" and the executable is done - as long as you have something like an usb to serial dapter.. i dont know exactly what this function

char *tty_path = "/dev/ttyUSB0";

exactly means, but i think its calling somekind of this adapter (and thats where im stuck now)

But I'm running on a win xp machine, so i had to compile here... i had the same problem as you and 'mist egal'.. the gcc compiler seems to have some glitches, bugs... whatever in windows.
so i tried the hint of a friend and installed cygwin.. a console-program that allows you to start a linux console under windows with lots of plugins in it. i finally managed to compile the program, yes i have a cube.exe, but now i'm stuck on the adapter thing (Running it I get an error in win saying

/dev/ttyUSB0; No such file or directory

I'd like to run the RS232-Mode in windows, but my friend told me also that it would be a hell of a code for win to use my serial port (COM1) to work with the cube

even if i'd install now linux on my machine i think iwill still stuck on the USB-Serial-Adapter-thing

so any suggestions here? if not, i'll leave the rs232 part of this instructable.... the cube is also awesome standing alone and making effects. :-D

P.S. I have also recognized that the code for the font-effects on the atmel cpu is mixed up a bit... if i compile the code for myself the fonts, bitmaps etc are just displayed as blocks. i managed to get the font to work, but at least im stuck at the bitmaps (for example the arrow moving around or the omega-symbol rotating appear correctly) if this is also a windows thing let me please know ;-)
Nov 24, 2011. 3:18 PMScerion says:
In Linux the /dev/ tree looks like part of the file system (you can actually go in there and look at things that look like files) but it's actually a fake directory that is created by the Linux kernel at boot time. It contains links to the physical devices in the machine like hard drives, ports, keyboard, mouse etc. A tty is a terminal device (serial input/output) and USB0 is what the kernel has found as the first USB port. So /dev/ttyUSB0 is a reference to the usb port itself. Sending data to this device will push data through the USB port, and reading from the device will read from the USB port. Linux is pretty easy to understand really - everything in the machine looks like a file!

I assume you can go into the control panel and look up the name of the usb port in windows in a similar way!
May 9, 2011. 7:08 AMIce1 says:
Ohh ok thanks a lot! Sounds like i will have to get linux, iv been thinking of doing that anyway, even if i run it in a virtual box. Thanks for taking the time to make this comment!
May 10, 2011. 4:42 AMMasterfruit says:
uhm thx Ice1 for the idea with the virtual machine... i just installed ubuntu on virtual box yesterday and managed to get the rs232 thing to work now!

i just had to link the virtual serial port (ttyS0) with the COM1 of my windows machine, compile the code in Ubuntu again and run it.

The only problem i now have that the connection between Virtual Box serial output and the hardware serial output is messed up a bit... i get only an effect picture every two seconds on the cube.. have to look into that this evening.;-)

P.S. you'll also have to change the wires of the RX/TX pins... 'troller1' described this before
Oct 18, 2011. 3:37 AMgoyr says:
I have the same problem I just get picture every two seconds did you find any solution for this ?
Nov 18, 2011. 5:44 AMMasterfruit says:
sorry, havent read here for a long time... i postet the solution already somewhre else, so just the quote here:

If you are using a physical Com Port of you computer you have to add a flush command to send the data faster

add to the cube_push function in the cube.c
tcdrain(tty)
behind the write command - it should work
Jul 12, 2011. 6:07 PMqwertyboy says:
Just a quick question, I have no idea how to compile the code. I have Ubuntu running in Virtual Box, but I need help getting a program made.
Jul 13, 2011. 3:17 AMMasterfruit says:
just have a quick look in the makefile which is in the cube_pc program. i compiled the code "per hand" every time in the linux-terminal, executing the command
"gcc -lpthread -lm -o cube main.c cube.c draw.c effect.c font.c 3d.c draw_3d.c gameoflife.c"
in the main folder where the files are. a file named "cube" should be generatet. if executet, it should feed the cube via
"  char *tty_path = "/dev/ttyUSB0";  "
with data. if youre using a physical com-port, change it in the cube.c to ttyS0 or ttyS1 whatever port you are using. chr seem to have used an usb-to serial adapter fo this.
Jul 13, 2011. 8:46 AMqwertyboy says:
Thanks for the quick response. I've got the program made, but my USB to serial adaptor is giving me greif. I'm going to try doing a dual boot with Ubuntu and give it a try from there.
May 10, 2011. 6:47 AMIce1 says:
Ah nice! Well done. Yeah im not too sure whats going on with that serial output, it should be capable of a solid connection. Im still building my cube at this point, so i havnt had chance to try this yet.
Nov 14, 2011. 7:17 AMastroboy907 says:
if it downloads as .tmp just rename the .tmp part of the file to the right filename (I think .hex or .pde)
Jun 18, 2011. 9:27 PMITman496 says:
How do you actually get the pc to send data to the cube? What application do you need?
May 20, 2011. 4:04 AMhatschel says:
I got a failuremessage:
Compiler: Default compiler
Building Makefile: "D:\cube_pc\Neuer Ordner\Makefile.win"
Executing make...
make.exe -f "D:\cube_pc\Neuer Ordner\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

g++.exe -c ../3d.c -o ../3d.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

../3d.c: In function `void linespin(int, int)':
../3d.c:46: error: `line_3d' undeclared (first use this function)
../3d.c:46: error: (Each undeclared identifier is reported only once for each function it appears in.)

../3d.c: In function `void sinelines(int, int)':
../3d.c:76: error: `line_3d' undeclared (first use this function)

../3d.c: In function `void fireworks(int, int, int)':
../3d.c:220: warning: passing `float' for converting 1 of `void setvoxel(int, int, int)'
../3d.c:220: warning: passing `float' for converting 2 of `void setvoxel(int, int, int)'

../3d.c:257: warning: passing `float' for converting 1 of `void setvoxel(int, int, int)'
../3d.c:257: warning: passing `float' for converting 2 of `void setvoxel(int, int, int)'
../3d.c:257: warning: passing `float' for converting 3 of `void setvoxel(int, int, int)'

make.exe: *** [../3d.o] Error 1

Execution terminated


I dont understand about kompiling etz i have tryed about one week succsessless anyway!
Is there a executable file?
May 21, 2011. 10:33 PMfebinjohn says:
am also stuck with pc source code
how did u manege make file???
May 23, 2011. 2:40 AMhatschel says:
i have run a archlinx Live cd by Das Labor with all toolchain etz. inkludet for handle with AVR[
So i only type "make" to crete the flashfiles
May 23, 2011. 3:33 AMfebinjohn says:
any idea how to compile in windows platform ???
May 23, 2011. 12:43 PMMasterfruit says:
look in the comments.. i already wrote that you have to reprogram some things for windows, especially the COM-Port thing... install ubuntu on a virtual machine, you can compile there without problems
May 23, 2011. 4:58 AMhatschel says:
I hav tryed wit Winavr but many errors,so i think whats so bat about download the Live cd it[ free,its easy, and no toolchain must installed
for me the best solution

Hm..maybe cygwin works!
May 31, 2011. 8:27 PMfebinjohn says:
no cygwin didn't work im getting same error the

system cannot find the file specified
make: *** {cube} Error2
Apr 25, 2011. 10:35 PMmist egal says:
I have the same problem like Ice1 , can anyone help please .... ?!?
Jan 25, 2011. 8:21 PMdevsfan1830 says:
Awesome stuff and really considering giving it a go myself, but I would like to use the more advanced animations (the ones requiring a PC) without the use of a PC. Is there any small modules that could possibly handle the processing the PC does but in a smaller form and autonomous like the microprocessor? I would love to be able to use all the animations and have it just start up automatically when powered on.
Mar 28, 2011. 3:04 PMbpark1000 says:
You can do this if you use assembly language. Lookup tables can "calculate" trig functions (to the precision needed for this cube) faster than the PC. I do this for a laser show which works on a 256 x 256 x 256 resolution at 16 frames per second. The PC only sends commands such as "rotate A image at B speed around C axis". The computer I am using is a 6MHz 65816 that doesn't even have a hardware multiply or divide! The computer does have a 24 bit address bus so I can have a nice big fat EPROM holding 100s of base patterns (such as logos, etc).

I can show you how to write routines that are 100s of times faster than C. I can also debug the routines while they run.
Jan 28, 2011. 9:57 AMrabrez says:
how i send data via rs232. How program i need???
Jan 16, 2011. 8:25 PMchengpeng19851005 says:
hello!it's looks very nice ,my mother like it very much !but i can't download all the files, they are type of 'tmp" when i download them,would you please send me the files?my E-mail:chengpeng19851005@163.com;thanks so much!
Jan 17, 2011. 7:40 AMDaredee says:
just rename tmp files to right names
Jan 17, 2011. 8:09 PMchengpeng19851005 says:
thank you very much!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
651
Followers
7
Author:chr
I like microcontrollers and LEDs :D