a little 4x4x4 LED cube I had built and programmed with an AVR. However, I fancied the challenge of programming this in LabVIEW using an M-Series PCI DAQ card. I used an NI PCI-6251 connected to a SCB-68 breakout box.Also, I fancied the challenge of doing this using LabVIEW OOP.
LabVIEW had many advantages, the main one being that I could build an animation builder to effortlessly program animations. If you scroll on down a bit you should see a description of this!You can see the results in this video:
This was one of those projects which could have gone on forever, bug fixing and adding new features. However, I needed to call it quits on this particular application so it is very a bit buggy but the main functionality is all there.
I have attached the code for you to take a look at, as I have said it is buggy but it does generally work, you won’t be able to test it unfortunately as you don’t have a cube - feel free to build one though! I would love to know how you would have approached programming this and if you would have used a similar approach to me – you probably wouldn’t have!
As you would expect for an LED cube of this size, it works using the principle of multiplexing. Electronically, you can only address a layer and each of the 16 verticals. To simultaneously display layers at the same time, the program switches each layer on in turn very fast (~ 200Hz). If you would like to know a little more about the construction of the cube check out: http://www.instructables.com/id/LED-Cube-4x4x4/ for a great guide which I used.
The main structure of the program contains 4 classes:
Animation Builder - Responsible for Building animations
Animation – A collection of frames, one is loaded into display cube
Frame – contains a 3D array of Booleans, i.e one frame of animation.
Display Cube – contains the UI and DAQ code.
The main architecture is a queued state machine which allows the user to interrupt the running of the cube animation.
The Animation class has a run method which will display one frame of animation. This run method is then continuously queued to show the animation. This allows methods such as pause and stop to be queued. I’m not sure if I really like this implementation but the pass-by-value nature of the objects means it would be difficult to stop the animation if it was running in a parallel loop.
The animation builder runs standalone and can save animations by simply saving class data to a binary file for loading later. The Random Gen button allowed me to build the random LED sequences you can see in the video.
LabVIEW 2012 or compatible
NI-DAQmx 9.5.5 or compatible
NI Multifunction DAQ Device
Steps to Implement or Execute Code
Configure the parameter for the right channel and device.
Connect your hardware appropriately.
Run the VI.
**This document has been updated to meet the current required format for the NI Code Exchange.**