LED Cube 8x8x8

Step 66: PC Software: Effect 1, ripples

This is the first effect we made for the PC software, and we think it turned out very nice.

While this may seem like a complicated effect, it's really not!

All the effect functions running on the micro controller mostly use if() statements to create effects. The effects on the PC software are built a little different. We use a lot of sin(), cos() and other math functions here. Most coordinates are calculated as floating point coordinates then typecast into integers before being drawn on the cube.

The effect you see in the video is actually just a sine wave eminating from the center of the cube, x=3.5, y=3.5.

Here is how it works:

1) Loop through the iteration counter.

2) Loop through all 64 x and y coordinates.

3) Calculate the distance between the center of the cube and the x/y coordinate.

4) The z coordinate is calculated with sin() based on the distance from the center + the iteration counter. The result is that the sine wave moves out from the center as the iteration counter increases.

Look how easy that was!

Remove these ads by Signing Up
jenkycents says: 1 year ago
good work ;)
could you please send me the hex file of this effect ?
I'm not good at math
jwestenberg in reply to jenkycents1 year ago
jenkycents in reply to jwestenberg1 year ago
ok i found the effects thanks .

But now I can not compile the hex file.

i have only the c files
jwestenberg in reply to jenkycents1 year ago

It ain't that hard to figure out.
jenkycents in reply to jwestenberg1 year ago
how can I do to make the effects of the "PC Software" without a PC?
bpark1000 in reply to jenkycents6 months ago
Contrary to what jwestenberg says, you can! And easily! Keep in mind that all those "complicated" functions such as sin, cos, etc. need only need be "calculated" in low resolution (+/- 1/8) for a cube such as this. You can do this with lookup tables. Simplest angle unit to choose is 1/256th of a revolution per count, held in a byte. 256 bytes of table do for both sin and cos functions. The "problem" is that "nowdays" everyone programs in C, and tables can be done, but somewhat awkwardly, and the code runs slow! The way I would do this is in assembly. I have done this not for a cube, but for an X/Y laser projector, where my "cube" is 256 x 256 x 256. The worst limitation on Atmel processor is not having a lot of RAM (I have 32K of RAM in my system, 8-bit, 6MHz 65816 processor). 100% of code is in assembly, about 4K of code, and 600K of tables (512 K are for unsigned and signed multiply, which my processor doesn't have). Speed is fast enough unless you want to "stack" functions, such as morphing between 2 rotating objects. The other difficulty with Atmel processor is the Harvard architecture which makes writing assembly more difficult. I would choose a register-based Von Newman processor such as 65816 (RAM and ROM are external) , 6808 (RAM small), TI430 (but there is a voltage problem with that one). Now I would use a Renesas M32C/87 (>32K RAM, many megs flash, 5V power bus, 32M machine cycle rate). I would have it working now but I find myself fighting with the way too fancy assembler "librarian".
triumphtotty in reply to bpark10006 months ago
Exactly! I have created a trig library for the cube with sin/cos/tan. It's uploaded somewhere in my image files (tottymath.c), and can be used extensively from other code. See tetraspin and fireworks. It's also very easy to optimise Game Of Life to run at full speed on the ATMEGA32. chr's code was written for a fast processor, so he didn't need to optimise. I think it's in tottyeffects.zip somewhere. Don't ask me on here about these, but I might respond to a PM if not too much is requested. I've been out of the loop on here for months.
jwestenberg in reply to jenkycents1 year ago
You can't
jenkycents in reply to jwestenberg1 year ago
so how i can execute the software ?
jwestenberg in reply to jenkycents1 year ago
You can only do this on a linux operating system since no one ever got this working in Windows.
So you need to unpack the file open the folder in terminal window and type "make" .
This makes an executable file for linux.
After that you have to type ' sudo ./cube' to execute the file you just made.
jenkycents in reply to jwestenberg1 year ago
ok thanks ;)
jenkycents in reply to jwestenberg1 year ago
i'm looking for the wave , the ripples and the fire works effect hex . i dont found it :(
ristdaro in reply to jenkycents1 year ago
Compile the following attached file, Thanks to triumphtotty for the code. It gives you all the waves and ripple effects running directly from the ATMEGA32

ristdaro in reply to ristdaro1 year ago
Sorry didn't work the fist attempt

Here is the file again.
jenkycents in reply to ristdaro1 year ago
works perfectly and has other effects! o.o
ristdaro in reply to jenkycents1 year ago
Triumphtotty posted the code a while back. If you read through the earlier messages he explains how you can amend the code to create your own variations. You will probably want to change the text from my initials "RR" to your own for instance.
Open Launch_effect.c in programmers notepad and amend case 20. You will see "RR and "LED CUBE"

If you read Triumphs messages he explains how to change some of the more interesting effects.

Have fun
jenkycents in reply to ristdaro1 year ago
thanks so much ;)
jenkycents in reply to jenkycents1 year ago
the effect 1,2,3 and 4 . thanks
febinjohn says: 2 years ago
cooooooooooooooooollllllllllllllllll