17 December 2012

How to Build a Simple LED Cube 4x4x4 - Part 4

Software
The software is derived from my earlier LED cube, the charlieplexed version. Of course the "hardware layer" had to be changed, because physical control of the LEDs is different. But the rest is very similar.

To add a bit more structure, I partitioned it into several files. There is the main routine (in LEDCube444.c), the file HWControl.c for low level hardware support and a collection of software routines to generate procedural patterns called PatternTools.c.

The patterns or rather pattern sequences are in individual files. This has the advantage that they can be included optionally or rearranged. You can also add your own creations.

If you are not interested in modifying anything, just skip the details. But if you are, here it goes.

LEDCube444
It contains the main routine.First it invokes the initialisation routine, then it displays the HW check pattern sequence once and finally it starts an endless loop displaying all the patterns. The patterns are #include'd so it is very easy to manage them.

HWControl
This file contains two important sub-routines. First, there is the "ioinit" routine. It initialises the IO ports of the controller and sets the timer for the multiplexing interrupt. Finally, it enables interrupts.

Second, there is the interrupt service routine (ISR). It switches through the LED groups (i.e. the half-levels) and sets the appropriate anode values. It gets these values from a pre-calculated array, so there is little processing in the ISR. As a small addition I added a dimming function. The global variable "dimmer" can be set to values between 0 and 32 to set the cube's brightness.

A secondary task in this routine is the implementation of an egg timer. It can be set to a certain value and then will count down in the ISR. This is a simple way to create delays. Quite often in sequences, the waiting time is always the same, so there is a global variable "current_delay". If set, all you have to do is invoke the "standard_delay" routine in order to get a fixed delay.

There are a few other routines in this module. They are secondary display functions. Most important is the calculate_IO routine. It translates the cube array values to port values for use in the ISR.

The cube array ("LED_Cube") contains the LEDs to be set. Each LED corresponds to one array element. The top, right, front LED is LED0. The one behind is LED1, after that follow LED2 and three. LED4 is the top, front, second from right LED. This continues in a regular sequence until LED63, which is bottom, back, left.

To help writing compact code, there is a "display" routine. It invokes the calculate_IO and then the standard_delay routine. And then there is the "do_plus" routine. It is the same as the "display" routine but also clears the cube after the delay. It is then ready for the next LED setting to be generated.



PatternTools
My pattern sequences are more or less generated by algorithms rather than just read back from memory somehow. To that end I created a set of tools to create certain elements.

The most obvious is a "set_LED" routine. It is almost trivial. The LED number is the argument and it is used the set the corresponding cube array element.

Far more interesting and powerful is the "set_pattern" routine. During my first attempts to generate patterns, I found that a lot of elements like a fully set plane or column are actually regular patterns in the cube array. As an example, setting the top plane means just to set the first 16 LEDs. To set the second plane you have to set 16 LEDs again, but this time with an offset of 16.

In order to set a vertical plane, you have to set 4 LEDs in sequence, then skip the next 12 LEDs. Then you have to repeat this 4 time.

The "set_pattern" routine has therefore 4 parameters: The offset ("start"), the no. of LEDS to be switched on ("LED_on"), the number of LEDs to be off ("LED_off") and a "repeat" value.

Based on this algorithm, there are many other pattern generating routines, like setting columns in various directions.

Finally, there is a support routine to generate "pseudo_random" numbers, via a LFSR.

Pattern Sequences
These are located in a sub-directory "patterns". Take a look if you want to write your own sequences. If you are not that firm, you can start by modifying the existing patterns. The loop variables i ,j and k are available for the pattern generating algorithms.

Programming the Controller
The software was written and compiled under Atmel AVR-Studio. The download package contains a hex-file in case you want to quickly get the cube working, without compiling the firmware first.

There is only the flash ROM to write. EEPROM is not used.

The fuse setting is default, but the internal RC clock oscillator is set to 4 MHz. In AVR-Studio the fuse setting is reported as:

HIGH: 0xD9
LOW: 0xE3

Further Possibilities
The patterns shown in the youtube video take less than 50% of the flash memory of the ATMega8 controller. So first of all it would be possible to add more pattern sequences. Then, there are still a few pins available. So, you could add some buttons and create some kind of interactive display. 

Since the serial RX/TX pins are left over deliberately, it would be possible to use some kind of remote control scheme to control the cube.

Lots of possibilities to experiment!

Last Words
That is it. If you build this cube, I would appreciate it if you could let me know. I am always interested to learn if this post inspired anyone. And if you have proposals to improve it, do let me know.

In case you have questions, either leave a comment or get in touch via email (see my profile). But please give some kind of name or alias. Otherwise it can get confusing...

Oh and the software, as with all my projects is available through the download page.

Have fun!  

84 comments:

  1. Hello!
    I'm following your tutorial, and I got a question:
    Should I save all the files on ATMEGA including subfolders?
    Thank you!

    ReplyDelete
    Replies
    1. Hi Thiago,

      yes you should download all files. If you follow the download link, you can see all the files that are contained in LEDCube444.zip. To download the whole zip file just click on "File" (top left) and then on "Download".

      If you only want to try the existing software without modifying it, you can download only the hex file and write it to the ATMega's flash ROM.

      Delete
  2. hi. very nice project congrat!
    i m interested too in build it, but need to ask you some clarify.explanations, i m not very expert , but i used Keil Uvision 4 and Proteus simulator and susscessfully built a blink led project using 80c51 intel based MCU, another 1 leds project with 8 leds running up and down always in 80c51 MCu, using some c examples code fouded on keil site and other websites on internet. these tool Keil seems does not support your attiny from ATmel even in ih his database has alot of ATmel chip for selecting and is possible in it add custom component MCU. i m talking of these to you cause when build a project with Keil it automatically produce *.HEX file ready to be programmed in your selected chip, as well as it includes a lot of *.H (header) files for various MCU.surely u know Keil uVision.i take a look to your 444 cube zip file ( im using xp sp3 and ie 8 and it advice me my browser is obsolete i know :)on other half hdd have WIN 8 now);my question for you are:
    1) i downloaded and install Atmel AT89LP Developer Studio
    2)Atmel Studio 6.0
    3)AVR toolchain
    i think i need insert directly in Atmel studio 6.0 all those files contained in your cube444.zip file ;
    then may i start debug code for example to view if i have no error in compiling ?(your code surely works if you have builded that:))
    which tool produce hex file? is made from ATmel studio 6.0? for which u mention
    "The download package contains a hex-file in case you want to quickly get the cube working, without compiling the firmware first".
    must i use Flip atmel or ..what to flash hex file to target(ATmega flashrom in your case)? since i have no breadboard or similar for now was interested seeing if i can view a debug session running without errors and building the hex file . i ve read about yuor isp asp usb programmer where u prefer LCsoft, what u suggest me to buy for that? do you think i have less problem and time waste if i choose atmel mk II programer? any help or suggest will be appreciated . i have discrete knowledge of C# , assembly, and im cracking games with OllyDBG all day!! Enrico /Italy
    feel free to answer with time, take time u need, i should like appreciate u answer me suggesting me some steps to do to arrive to conclusion, but i must say your blog is perfect as is, my main question is who make hex file. Many tx for your Attention Enrico /Italy u_1800@yahoo.it my e-mail (hope i dont violate nothing writing here my e-mail if yes free to delete it)

    ReplyDelete
    Replies
    1. i ve missing to add this for my question in previuos post sry:)this is my snapshot>
      http://imageshack.us/f/526/sshotl.jpg/
      must admit i have no browse all Atmel site , but in those 3 tools named above ,noone contain that demo, so im not able to load it in Atmel visual studio 6.0, and might be i found answer for my question to you :who make hex file , in guide snapshot is written Type "make" and press enter right 1 this?
      i browse great part of atmel but didnt find that atxmega128A1 demo, at this point need to find that , or am i mising install some utilis in my system, i done a search but that file is not found In Atmel folders.tx again- even here suggest where to find appreciated will be . tx alot Enrico /Iatly

      Delete
  3. How to you use the .hex file on atmel studio 6

    ReplyDelete
  4. Hola
    Magnifico trabajo. Quiero agradecerle su esfuerzo por mostrarlo tan claramente y me propongo intentarlo.
    Si logro concluirlo, le mostraré en vídeo el resultado porque pienso "vacilar", "fardar" con el ante mis amigos.

    En cualquier caso, lo haga o no ......Muchisimas gracias

    ReplyDelete
    Replies
    1. Thanks for your feedback.
      I'd love to see your cube!


      Google translator says: :-)

      Gracias por su colaboración.
      Me encantaría ver a tu cubo!

      Delete
  5. can i use an arduino uno since it seems to be the same thing

    ReplyDelete
    Replies
    1. In principle you could. But you would have to move the two pins PB6/PB7 somewhere else, because with the Arduino they are used for the crystal oscillator. There are probably more restrictions with the Arduino. I am no expert.

      You could then use avrdude to write the hex file to the Arduino. But you'd still need the driver IC and all connections to the cube, so I don't see the advantage.

      And for the price of one Arduino you can easily buy an ISP programmer plus several ATMega8L - at least if you order from China.

      Delete
  6. Hello

    Christophe from France is happy.

    I've made a cube it's wonderful.

    Thank you very much.

    ReplyDelete
    Replies
    1. Hey Christophe,

      well done and thanks for letting me know! I'd love to see a few photos of your cube on your blog or somewhere else.

      Did you find it easy to follow my instructions? Is there anything that I should improve?

      Thanks, Tom

      Delete
  7. hey i am computer science student..and i have lots of interest for this kind of stuff ..so i started with 8051 microcontroller....
    so i started with the simple led blink..and its blinking rather very dimm for port1 and 2 and it's not blinking for port 0 even if i use 250 ohm resistor...can u tell me the problem please..
    and i want to built the led cube using 8051 microcontroller ...here i have one more doubt...why we use transitors

    ReplyDelete
  8. Hey bhargav,
    I am not very familiar with the 8051. But a brief look shows me that the standard 8051 has very weak output drivers. Each pin must be limited to an output current of 10mA or less. The sum of all the currents of a port mus be less than 26 mA (port0) and less than 15 mA (ports 1/2/3).

    Standard LEDs on the other hand are rated at 20 mA. So the 8051 cannot even drive a single LED at its rated conditions. This means that even for a single LED you need a driver.

    Also, if you take a look at the 8051's data sheet you will find that the output voltage for the port pin set high isn't really 5 Volts, but closer to 2.4 Volts. If you have a voltmeter you can measure that voltage and see what you actually get. I don't know what the colour of your LED is, but LEDs have forward voltages of between 1.8 Volts (red) to 3.6 Volts (blue, white).

    So you will need drivers on every port pin of your controller. The AVR chip that I am using is more modern and can drive higher currents. But even it has its limitations. When multiplexing, one pin has to supply 8 LEDs, and for that even the AVR needs a driver.

    For your blinking LED there might be a small improvement, if you rewire the LED. Connect the anode to +5 volts and the cathode to the port. The 8051 is better with sinking currents. For currents of 1.6 mA, ports 1/2/3 are able to pull the output down to 0.45 Volts. That will probably result in more current for your LED.

    ReplyDelete
  9. gracias por enseñar y dedicarle tiempo para que se entienda...muy pronto lo intentare y hare un video :-) gracias de nuevo

    ReplyDelete
  10. Dear Mr. Fry

    I was reading on you 4x4x4 led cube and was wondering where did you hook up the ISP wires to program the AVR ATMEGA8L. This one is the most interesting one that I have came across yet and can't wait to build it. For weeks now i have been reading and watching videos on these neat little things lol and am so intrigued by them. Please contact me and let me know. Thank you for your time. This will be my first atempt at the AVR ATMEGA8L and the ULN2803 DRIVER.

    Jason Riley

    ReplyDelete
    Replies
    1. Hey Jason,

      your enthusiasm is a good base for building a cube. It actually takes enthusiasm to get you through all that soldering. :-)

      The relevant pins of the ATMega8L can be found in the data sheet (DIL28 package): Pin0 - Reset / Pin7 - Vcc / Pin8 - GND / Pin17 - MOSI / Pin18 - MISO / Pin19 - SCK

      I think one of my next tutorials will be on ISP programming...

      Delete
    2. thank you very much. And that tutorial would be great lol. Another qusetion, can any source code for a 4x4x4 cube work with this one? And where can I find more besides the ones u give?

      Delete
    3. Jason, you can not use other source code, because the code must fit the hardware, including pin-out and cube structure.

      So I am afraid, your only option is to write your own code. It is not too complicated. Have a look at my code. It is not too difficult to extend it. I kept the pattern routines separate and in a dedicated directory. Modify my code and see what happens!

      Delete
    4. im gonna do just that, I know some code, wont hurt, lol. thank you for the replies. Ill post here when done with and will share when my results are 100%. Thanks

      Delete
  11. Hello Mr.Tom,
    i really like the way you explained this project, though there's a little confusion when you mentioned top right & top left corner( from which point of view? ) . Here my doubt is, do I have to make any changes in the program if I use 'RGB' LEDs?
    Also, can you please leave me the complete details of the software you've used and any reference sites to understand the software and to find new patterns for the cube.
    Thanks in advance! :)

    ReplyDelete
    Replies
    1. Hi Manoj,

      I tried to explain this with the drawing two images down from "top right" and "top left" in part 3. Top means the actual top layer of the cube. There are two "half" layers: 8 LEDs right / 8 LEDs left.

      Actually, you cannot use RGB LEDs, because those contain 3 separate LEDs. And you would have to control those independently from each other. So you would have to control three separate cubes, really.

      Or do you mean those colour-changing LEDs? You can't use them either, because we are using multiplexing here. Every LED is switched on and off very rapidly. But that would restart the colour cycling, so you would always see the starting colour.

      The software is available from the download page, as stated at the very end of this blog post, part 4. Have a look at the pattern generating routines, this will help you to understand how to generate your own patterns.

      Delete
    2. Thank you Tom!
      My LED cube is now complete! :D
      There are few glitches though. The LEDs are generating noise. I used resistors to supress that. They are glowing with less brightness now.I will alter the input voltage and hope it works.

      Delete
    3. Well done! Seems odd that the LEDs should create noise. Perhaps a few capacitors on the supply rails near the controllers would help?

      Delete
  12. hello, this is Arnav from Agra,India.I've just completed 4x4x4 atmega8l minimum components cube.it is working but with slow speed in all patterns in comparison to your video as I've just loaded the provided hex file.This is my first microcontroller based project.pl comment what went wrong

    ReplyDelete
    Replies
    1. Hello Arnav, well done so far! I suspect that you didn't change the fuses. The fuses determine a couple of settings, like e.g. the clock speed.

      By default the ATMega runs at 1 MHz, so your cube would be 4 times slower than mine, and perhaps some flickering is visible.

      Above it says:
      The internal RC clock oscillator is set to 4 MHz. In AVR-Studio the fuse setting is reported as:

      HIGH: 0xD9
      LOW: 0xE3

      Be very careful. It is possible to set the bits wrong. This could mean that you lose access to the controller via ISP.

      Delete
  13. Thank you this is arnav again,It is working OK now. I've changed the Low fuse bits settings to 11100011(0xE3), checked boxes of BODLEVEL,BODEN,SUT1,CKSEL1,CKSEL0 and left blank CKSEL3,CKSEL2. I've used a small software khazama for that as I've no prior awareness of programming or using avr studio.
    Now my next query is about power supply can I use 7805 with 9v battery?

    ReplyDelete
    Replies
    1. Thank you this is arnav again,It is working OK now. I've changed the Low fuse bits settings to 11100011(0xE3), checked boxes of BODLEVEL,BODEN,SUT1,CKSEL1,CKSEL0 and left blank CKSEL3,CKSEL2,SUT0. I've used a small software khazama for that as I've no prior awareness of programming or using avr studio.
      Now my next query is about power supply can I use 7805 with 9v battery?

      Delete
    2. Well, in principle you could use a 9V battery. But usually they are really weak (6LR61) and can not deliver enough current for upto 8 LEDs.

      And keep in mind that 7805s need capacitors for stability, see the data sheet.

      Delete
    3. Oh, and thanks for the feedback. Perhaps others will profit from it.

      And well done! Enjoy your cube!

      Delete
  14. hello.I have finished the hardware but i have some problems with software.I have a usbasp and i dont know how to program the atmega8 with avrdude i started to do it and i get a message in the ide saying canot set sck period what i must to do? alex

    ReplyDelete
    Replies
    1. Hi there, I am currently writing a tutorial for that exact problem. I am half way through it and will need a few more days. Please bear with me!

      Delete
    2. ok then thnx you very much :)

      Delete
    3. Hi Tom,
      Thanks for the great cube design, but I too have come unstuck with the programming. Similar to the above I also get a "warning: cannot set sck period. please check for usbasp firmware update" error.
      A lot of trawling of the interwebs hasn't given me a solution so I'm hoping your next tutorial might have some insights

      Thanks,
      Keith

      Delete
    4. Hi Keith,

      the ISP tutorial is actually on-line. Haver a look! The reason and the solution for this effect is explained.

      If there is anything missing in the tutorial or needs better explanation, please let me know!

      Tom

      Delete
    5. Hi Tom,
      OK can I just say having the 10pin header twisted has been a monumental pain in the .... I read your comment (A USB/ISP Programmer (Part 1)) about your cable being swapped around and didn't think too much more as my cable looked the right way around in the USBisp. It wasn't until I pulled out my multimeter and tested to see where pin 1 ended on the other end did I work out the problem - pin 1 becomes pin 2 on the other end.

      Once I worked this out I was able to use a breadboard and wires to swapped the pins and programme the atmega8L. By the screen output it looks to have programmed OK,

      Ironically it is cheaper to buy another USBisp off "an auction site" than it is to source another cable.

      A couple of things I found is that with a 7 x 9 cm prototype board (which looks to be very common) you can fit the two chips and LED's all on top without too much trouble. Also using PCB Panel IC Breakable Header Socket allowed me to detach the LED's and work on the underside wiring a bit more easily.

      Now I just have to workout where my soldering fault is. Top layer doesn't look to light up and the patterns are very flickery and slow - the led flashing is quite visible.

      Thanks,
      Keith

      Delete
    6. Hi Heith,

      thanks for sharing your findings, I think that could be useful for others with the same.

      Well done for spotting the mix-up of the cable. And yes, those programmers are incredibly cheap. But maybe you can use the extra one for some other project. After all, it has a CAN interface and a few outputs available.

      Regarding the flickering, my guess is that you haven't changed the fuses yet. So your controller will run at 1 MHz, but it should run at 4 MHz. See above under "Programming the Controller".

      Delete
  15. 'm following your tutorial and finished the hardware. i cant programmed in atmega8 from your c++ source code.please help me how i get the hex file for it

    ReplyDelete
    Replies
    1. Actually, I included the hex file in the source code package. Look for a directory called /hex.

      Delete
  16. Hi Tom, and frind and i have both built the led cube here, and the build went well, however when wiring the HEX File to the flash we geta verification error saying

    "first mismach at byte 0x0000
    0x3d != 0xe6"

    when trying to run the LED cube only a few LED's light up and the simply flash.

    http://s17.postimg.org/6ffujjb73/LED_Cube_Error.jpg

    That is a print screen of the error.

    WE would greatly appreciate your help.

    Chris

    ReplyDelete
    Replies
    1. Hi Tom, Any help on this would be great.

      Delete
    2. Chris, sorry. I did write a reply yesterday, but it seems to have vanished. So here it goes again (thank god for copy and paste :-):

      Chris, hard to tell. But what the error message means is that it can't read back what it has written.

      I noticed that you are using the -F options. You should never do that. It is simply useless in 99% of all cases. I suspect that you did this because you got an error reading the device signature. But if you can't even read those three bytes, there is no chance you could read hundreds of bytes.

      I suspect (since you are using an USBasp programmer), that you are using a too high ISP frequency. That frequency should be less that a quarter of the controllers clock frequency. By default, the ATMega runs at 1 MHz. Also by default the USBasp's ISP frequency is 375kHz. You need less than 250 kHz.

      From the screenshot I can see that your programmer uses the old firmware, so you can't set the ISP frequency by software. Instead, you can set a jumper (usually J3, consult your programmer's documentation), and then the frequency is 8kHz. Slow enough, lol.

      And don't forget to uncheck the -F option!

      Good luck, let me know whether it works!

      Delete
  17. Hi Tom, please, help me. I was trying to compile your own code in Atmel Studio 6, and i cant. There are always 3 errors and 2 warnings :( Im bit confused. I know that i can use the hex. file, but i want to make my own code based on your. But i wont do that, if i cant even compile the original one. I dont know what i could done wrong, moustly that u made it. Please, help me a bit.

    Chris

    ReplyDelete
    Replies
    1. edit.

      Now i have only one error. It says "expected declaration or statement at end of input" and its 111 line, column 1 in ledcube444.c. Anny ideas, thanks for help :)

      Delete
    2. Hi Chris, please let me know what those errors and warnings are and I will try to help.

      Myself, I am still using Atmel Studio 4, so there is a chance that something is different that needs fixing.

      Delete
    3. That is odd. Apparently you get this error if the "}" of the main() routine is missing. But it is there. So I am not sure why you get this. Did you perhaps modify the code somehow, so that the bracket is actually missing?

      Delete
    4. I fixed that, but then several other errors came up. I dont know, will try on older version of Atmel Studio. I wasn't modifyimg your code, yet. Thats why its weird for me. I was only trying to compile all the files that i downloaded from your website.

      Delete
    5. Can I suggest that we continue this via email and only copy the results here? You can click on "Tom F." and on the new page click on email.

      Delete
    6. Solved. Dont know have u got my emails, but the patterns need to be in ledcube444.c Everythingis working now, but the cube is flickering. The connections on the board and the leds are okey. So, anny idea?

      Delete
    7. Chris, I am sorry about not replying. I was quite busy recently and I saw that you got it working without my help. But I did have another look now. And I think I know what happened.

      The reason is the "unconventional" way I divided the source code. The pattern files are not separate functions, but just parts of source code. This source code gets #included from the main source file.

      You probably added them to the source code file list in the project. This means that the compiler tries to compile them separately and that goes wrong, as these files are not self-contained. Remove them from the list of source files. They will get included before compiling and everything should be fine - unless there is a change in Studio 6, which I am not aware of.

      Concerning the flickering, most people who had the problem until now had forgotten to set the fuses as described in the last part. That will set the controller clock from 1 to 4 MHz and the flickering is gone.

      Delete
  18. helo sir, can u plese tell me that what ic u r using with atmega8?? and how it works

    ReplyDelete
    Replies
    1. Amit, please have a look at part1 of this post. All is explained there.

      Delete
  19. Sir i have completed the cube...but i am now stuck at the programming the controller.....i know c++ and i write small programs to blink\flash 5-10 led's.....but i have never transfered the hex file directly into the chip......can u please tell me what to do after downloading ledcube444.zip.(procedure)....

    ReplyDelete
    Replies
    1. Rushikesh, I have written a tutorial on how to get the hex file into the controller. This is part 1:

      http://tomscircuits.blogspot.de/2013/05/howto-isp-p1.html

      Delete
  20. Sir can u please tell me how to get hex file into the chip using winavr.....the avrdudr is a bit confusing......and
    Secondaly in ur .zip file there are two types of files....namely(main.c and main.h..for very catygory....)..What does this .h stands for......i know .c stands for the main program code...?.....
    I know all the procedure how to transfer the program to the chip as i already told u.....
    The only thing i am not getting is how to transfer all these files to the chip....?
    I am following the same procedure like this video's - take a look-http://www.newbiehack.com/MicrocontrollerWritingthefirstprogramandtransfer.aspx

    I am opening the .hex file and compiling it ,which gives me 200 error's . I don't need a brief description , i only need a small guidance.....which will save ur time.....please help....

    ReplyDelete
    Replies
    1. I have done programs like blinking of 2-6 leds at a time using a switch..etc...i am able to program my chip but now i am stuck because i have never transferd a ready mate .hex file the to chip like this.........
      There r 9 files in ledcube444 file .....how to put them inside the chip all at once...?Thats the big question

      Delete
    2. Rushikesh, I am sorry, but I have no experience with WinAVR. So I can't help you there. But I did have a look at the video, which you mention. They also use AVRdude, albeit preconfigured (look at the log data when they program). So why not read through my tutorial?

      Apart from that, the sole purpose of a programmer is to transfer a hex file to a controller. So the programmer you have should come with some instructions how to do that.

      .h files are "header files". Search e.g. the wikipedia for this term. This is a standard source file when programming in c.

      Finally, about the 9 files. You don't transfer the source code to the programmer. You compile the source code to create a hex file.

      For your first attempts, you do not need to compile anything, because the hex file is already compiled for you. And you cannot compile the hex file itself. This is the result of the compilation.

      All in all I must tell you that I can only give limited support. And it seems to me that if you really want to modify the c code and create your own patterns, you should read up on writing c code. But this is beyond the scope of my web site.

      If all you want to do is to get the cube up and running, please have another look at my ISP tutorial. It really isn't that complicated.

      Delete
  21. Tom sir thanku for ur ultimate support......i have done it at the last .......successfully ........now only to test it.........my cube is almost ready........will definately test in this week.........

    And secondaly do i have to compile every .c file to make hex file which i have to transfer into the chip using the same procedure by avrdudness........?
    If yes how to put all the hex files all at once........??
    For example the r files like(hwcontrol.c , ledcube444.c , patterntools.c) and pattern file which has all the 21 patterns ....so my question is -- Do i have to compile all the files including the 21 patterns to get the hex files and later to transfer these hex files to the chip.....? if yes then how to put all the .hex files to the chip all at once.

    ReplyDelete
  22. Replies
    1. Rushikesh, I can't tell you how to use WinAVR and I don't know if WinAVR can actually comile my code. Some porting might be necessary. I use the free AVR Studio 4 from Atmel (with the gcc toolchain) to compile the code.

      There, you create a new project called LEDCube444 as a C project. Select the ATMega8 as device, let the project wizzard create the directory. Unpack the zip file into this directory, preserve the directory structure. A new subdirectory "patterns" will be created, containing all the pattern files.

      Add the files HWControl.c, LedCube444.c and PatternTools.c as source files. Press the "build" button.

      And if all is well you find a new hex file in the project directory.

      Delete
  23. Sir i have downloaded Avr studio 4 and done all the steps what u told ......but it is giving the following error....
    avr-objcopy: 'Ledcube444.elf': No such file
    make: *** [Ledcube444.hex] Error 1



    I will tell u step by step what i have done...u please tell me where i went wrong...

    Steps-
    1) In avr studio 4 i have made a new project and selected AVR GCC (In project type) . Project name - LEDCube444 ....saved it in one of the new folder......
    2) Selected atmega8
    3)Then copied all the files from the LEDCube444.zip to this new folder , where the new project was working.
    4) It asked me to replace the LEDCube444.c as there were 2 files ...(one was created by the new project and the other was from the ledcube444.zip file)..hence i replaced them (the file from the ledcube444.zip remained)
    5)Added the source files HWControl.c, LedCube444.c and PatternTools.c from ledcube444.zip.........and then built it...
    6) It is giving the above mentioned error....

    PLEASE tell me what is wrong...

    ReplyDelete
    Replies
    1. Rushikesh, I think you did everything correctly. But there seems to be a problem with your toolchain. Did you install the "AVR Toolchain"? This is the C compiler. Without it, you can only write assembler code.

      Here is a direct link to the toolchain download:

      http://www.atmel.com/images/avr-toolchain-installer-3.4.2.1573-win32.win32.x86.exe

      It is also possible that something went wrong with the installation of the AVR Studio, so please (re-)install the toolchain anyway.

      Delete
  24. Sir i have uninstalled both the software and reinstalled them again as recommended by u.......now when i am going to the avr studio 4 , and opening a new project it is asking me for a debug platform.....what should i put....?.....and secondaly what is the use of the toolchain...?
    Should i follow the remaining steps as told by u earlier.?......Please clarify.....m bit confused.....

    ReplyDelete
    Replies
    1. And also earlier i have not installed the gcc toolchain.....now i have sufficiently understood the avr studio but please tell me a bit about gcc toolchain......i know nothing about it.........So as to how to run it and operate it.......Thanku sir

      Delete
    2. Rushikesh, when starting a new project, select AVR simulator 2 for debugging. Almost all other options relate to hardware debugger devices.

      Yes follow all other steps as explained before.

      The gcc toolchain is a plugin for AVR Studio. The Studio on its own can only handle assembler code. Atmel made a plugin so that the Studio can use gcc to compile C code.

      Once you have chosen to create an AVR gcc project, the Studio uses gcc for building the project. So you don't have to run the toolchain yourself. The Studio does that for you.

      Delete
    3. Sir it's done......at last.....a hex file of 10 KB is created with few more files......now i have to transfer this file into the chip ........that's it......Right......???
      Thank u

      Delete
    4. Rushikesh, that is very good news. The size is in the right range.

      Yes, all that is left is to transfer this hex file to the chip. I hope all goes well!

      Delete
  25. Sir can u please tell me what is the exact use of the driver chip...is the driver chip increases the voltage or something else...i have searched many sites but i cant find proper stuff......please can u tell me.....and also How to choose correct driver chip for the mincrocontroller....(like ULN2803 you have used).Please tell me on what criteria u have chossen the same........Thank u

    ReplyDelete
    Replies
    1. Rushikesh, AVR controllers can only drive currents of about 20-30 mA (one standard LED). Due to the multiplexing scheme used here, up to 8 LEDs need to be driven at the same time. The controller can't do this. So I needed to add a stronger driver.

      Effectively the drivers consist of 8 transistor switches. Take a look at the data sheet. The internal circuit is shown there.

      I chose this driver for its availability, price, ease of use, driving capability and number of outputs. There is not general way to find the right driver. Look at manufacturer's web sites what is on offer. Look what others have done.

      Delete
  26. sir so is it apllifying the voltage? or
    is it amplifying the current?

    ReplyDelete
  27. Hello mi nombre es Martín , me gusto mucho tu proyecto del cubo 4x4x4 y me propuse hacer uno, no tengo mucha experiencia en electrónica pero me facina, tengo para empezar con este proyecto RGB les rápidos, resistencias de 24map , y una proyecto boar, pero me falta lo mas importante , el controlador de secuencia, te pido por favor me recomiendes algunos modelos para este proyecto, el que tienes en el vídeo del youtube me parece muy bien , como se llama y si lo puedo comprar por AMAZON, por favor ayudarme , mi email es paracho57@gmail.con , espero me respondas con tu valiosa ayuda

    ReplyDelete
    Replies
    1. Martin, I don't speak Spanish, but with the help of Google translater I think I understand that you are asking about the controller.

      This project uses a Atmel AVR Mega8L and the software that I have written works only with this controller.

      It is a very cheap component and relatively easily available.

      Delete
  28. can i get report of this project in pdf ?

    ReplyDelete
  29. Hello i built your cube with Atmega8 without L, so i put 47 ohm resistors on blue lines and its working perfect. I only got one question. Im trying to make my own program in bascom avr (assembler) so im wondering about dimming function. I saw that you added dimming function in your program so i want to know if cube will work properly without dimming and how bright will it be? Cause i dont want it to be to bright.

    ReplyDelete
    Replies
    1. Denis,

      don't worry. Even without the dimming, the cube uses multiplexing, so it shouldn't be too bright. Worst case you can increase your resistors or reduce the operating voltage.

      But why do you want to switch to bascom. Have a look at my pattern routines an then write your own. It is not too complicated.

      Delete
  30. HI tom.how r u buddy??
    i am a amateur and i want to describe the electric parts in this project.such as model IC , micro ,resistors,capacitors and everything that i know.
    pls answer ...

    ReplyDelete
    Replies
    1. Tom , I wanted to name of the parts and the model used in this project.

      Delete
  31. Tom , I wanted to name of the parts and the model used in this project.

    ReplyDelete
    Replies
    1. This is all described in part 1 of this project description. All you need are two ICs and the LEDs.

      Delete
  32. Hi, my name is Tom and Nicola wanted some advice from you, since you're very experienced in electronics; I built the Simple 4x4x4 LED Cube with exactly the same components that you usto you and with the same connections, after trying it, it makes me accordingly ls of defects is right but is also slightly more LEDs light up that should not light, I tried to change also both the ATMEGA8L and the drive but the continuous defect, can you give me an explanation? Thank you

    ReplyDelete
  33. Hello Tom. my final year project is 8x8x8 Led cube. I want your help !
    Zahid

    ReplyDelete