Step 41Build the controller: RS-232
The ATmega has a built in serial interface called USART (Universal Synchronous and Asynchronous serial Receiver and Transmitter).
The USART communicates using TTL levels (0/5 volts). The computer talks serial using RS232. The signal levels for RS232 are anywhere from +/- 5 volts to +/- 15 volts.
To convert the serial signals from the micro controller to something the RS232 port on a PC can understand, and vice versa, we use the Maxim MAX232 IC. Actually, the chip we are using isn't from Maxim, but it is a pin-compatible clone.
There are some 100nF ceramic capacitors surrounding the MAX232. The MAX232 uses internal charge-pumps and the external capacitors to step up the voltage to appropriate RS232 levels. One of the 100nF capacitors is a filter capacitor.
The RS232 connector is at a 90 degree angle for easy access when the latch array board is mounted on top of the AVR board. We used a 4 pin connector and cut one of the pins out to make a polarized connector. This removes any confusion as to which way to plug in the RS232 cable.
In the second picture you can see two yellow wires running from the ATmega to the MAX232. These are the TTL level TX and RX lines.
1) Connect the GND and VCC pins using solder trace or wire. Place a 100nF capacitor close to the GND and VCC pins.
2) Solder in place the rest of the 100nF capacitors. You can solder these with solder traces, so its best to do this before you connect the tx/rx wires.
3) Solder in place a 4 pin 0.1" header with one pin removed. Connect the pin next to the one that was removed to GND.
4) Connect the tx/rx input lines to the micro controller, and the tx/rx output lines to the 4 pin header.
The wires going to the 4 pin header are crossed because the first serial cable we used had this pinout.
| « Previous Step | Download PDFView All Steps | Next Step » |































































































![Hard Wired LED Cube: [No Programming]](http://img.instructables.com/files/deriv/FTD/SF1T/GO8DC8KW/FTDSF1TGO8DC8KW.SQUARE.jpg)















beacause i'm the new comer on the field
However I have optimised Game Of Life, sidewaves and ripples to run at full speed on the ATmega32, so could send you over the C code for these if you would like? There are other effects I have coded which might be of interest too, even if just to show what goes on my mad programmer's mind!?
I've tried following your instructions regarding the new animations. I get the following error when I try to compile
effect.c:279: error: 'FF_DELAY' undeclared (first use in this function)
I'm not sure if I've missed something. Where should this be defined?
any help appreciated
#define FF_DELAY 500
at the top near the other define statements in effect.c
Let me know how you get on!
The ATmega32 does NOT have any ability to do floating point maths internally, so these are emulated in integer maths. Any time you do (float)3.5+(float)101.2 it takes tens of processor cycles. sin(x) takes hundreds of cycles and sqrt(x) takes thousands.
If you look at how I did int_ripples, the principle is the same for converting those other routines. Work in BIG integers, then scale them down from 0-7 to plot on the cube at the end. I wrote tottymath.c to do just that. Right now there's just totty_sin and totty_cos, although I have a beta totty_sqrt which is VERY fast, using a Newtonian approximation. There's a bit of that in int_ripples again, although the comments are a bit out of date.
Anyway, I'm out all day today, but will take a poke at spheremove later on, if only to tidy up totty_sqrt for once and for all. :o)
ok, that worked but now got a few more for you!
launch_effect.c:178: error: too few arguments to function 'int_ripples'
launch_effect.c:220: error 'x' undeclared
launch_effect.c:221: error 'y' undeclared
launch_effect.c:222: error 'z' undeclared
Thanks
int_ripples(100,300);
The x,y and z declarations should be at the top of launch_effect.c within the launch_effect function. Safest place is immediately above the fill(0x00); statement. Just paste in:
unsigned char x,y,z;
Hopefully no more compiler errors... Fingers crossed. :o)
I love the ripples and sidewaves effects.
One last question. how do i get the ripple effect to last longer, its amazing !!!
int_ripples(200,500); to make it last twice as long, or:
int_ripples(200,400); to make it run faster and last longer. You can concatenate these within the case statement, e.g.:
case 5:
int_ripples(100,500);
int_ripples(150,400);
int_ripples(200,300);
break;
Will make the effect run 3 times at different speeds one after the other.
I've a question for you on the ripples effect
I've noticed that the wave stops short of using the full cube at layer 1 of the cube
Is there a reason for this or can I make an adjustment so that the effect uses layer 0 as well.
Thanks
Flying blind, I think you need to find this line in int_ripples:
height=4+totty_sin(LUT,distance+i)/52;
and change it to:
height=(181+totty_sin(LUT,distance+i))/46;
totty_sin() returns a value from -181 to +181 (see comments for reason for using this range), so 181+totty_sin() should be a value from 0 to 362.
Dividing this by 46 should hopefully give a centred integer value from 0 to 7.
If that looks too "flat" top and bottom, try changing the 181 and 46 to 196 and 49, which should reduce the time spent at the top and bottom.
Hopefully the code and the explanation make sense! With luck, it might even compile... :o)
Thanks for the quick reply,
I've tried both sets of values and it looks great with 196 and 49 !!! It now also uses all the layers 0-7
Thanks again....
i don't know how to change it , i had try but there are error when i compile
Here is my modified effect.c file
The modified line is
height=(196+totty_sin(LUT,distance+i))/49;
as per Triumphtotty's intructions
i do the following from the Install new tottyeffect but the commend said ( Missing separator. stop. ) it look there is something missing?
http://www.instructables.com/file/F8JYOBUGZHK30NN/
The effects are all at the end, so if you want to reshuffle them you'll need to edit the case statements yourself as in INSTALL.TXT in my last message.
Cheers!
T
this is the error Compiling: launch_effect.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=14745600UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=launch_effect.lst -std=gnu99 -MD -MP -MF .dep/launch_effect.o.d launch_effect.c -o launch_effect.o
launch_effect.c: In function 'launch_effect':
launch_effect.c:9: error: 'x' undeclared (first use in this function)
launch_effect.c:9: error: (Each undeclared identifier is reported only once
launch_effect.c:9: error: for each function it appears in.)
launch_effect.c:9: error: 'y' undeclared (first use in this function)
launch_effect.c:9: warning: left-hand operand of comma expression has no effect
launch_effect.c:9: error: 'z' undeclared (first use in this function)
launch_effect.c:9: warning: left-hand operand of comma expression has no effect
launch_effect.c:177: error: too few arguments to function 'int_ripples'
Makefile:460: recipe for target `launch_effect.o' failed
make: *** [launch_effect.o] Error 1
I've attached a copy of my modified files.
Just compile and you are good to go
Make these changes to launch_effect.c:
Change the line int_ripples(100) to:
int_ripples(100,300);
The x,y and z declarations should be at the top within the launch_effect function. Safest place is immediately above the fill(0x00); statement. Just paste in:
unsigned char x,y,z;
Secondly, the 16 on has 1K of RAM and the 32 has 2K, so there might be some effects which won't run in just 1K.
Note that although the 16 is pin and code compatible, it is not binary compatible, so the code must be specifically compiled for it. You cannot use the test.hex code for example. You need to change the first line in the Makefile to MCU=atmega16 and recompile.
u are a big help for me buddy, again truely thank to your hard work Triumph
wish you have a wonderful life buddy
I'm always fiddling and changing my code. Should I keep posting stuff in here? Maybe start my own Instructable on coding and effects?
Just remember none of this would be possible without the genius of Chr et al. Truly we stand on the shoulders of giants!
Check the video, some of the best animations I've seen
May give you a few ideas !!!! :o)
http://www.youtube.com/watch?v=03bkigwYOx0&context=C346dbdaADOEgsToPDskJy6EYiZ-m3BJ5MaZ1ny1M_
that sounds like a great idea. I would definitely be interested in seeing more of your creations.
Thanks again for the coding you've shared so far.
Could you please share the C code for the animations with me also. It would be nice to see them running on the ATMEGA32
could you send it to me over the C code? and you said you have more effect code that made me feel very interested ...
I'm in a bit of hurry, but quickly scribbles some install instructions for the new effects. Should be OK. Message me if anything goes wrong!