Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

4x4x4 LabVIEW LED Cube

Overview

This example shows a a little 4x4x4 LED cube. 

Description

 

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:

  1. Animation Builder - Responsible for Building animations
  2. Animation – A collection of frames, one is loaded into display cube
  3. Frame – contains a 3D array of Booleans, i.e one frame of animation.
  4. 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.

 

code.png

 

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.

 

builder.png

 

 

Requirements

Software

  • LabVIEW 2012 or compatible
  • NI-DAQmx 9.5.5 or compatible

Hardware

  • NI Multifunction DAQ Device

 

Steps to Implement or Execute Code

  1. Configure the parameter for the right channel and device.
  2. Connect your hardware appropriately.
  3. Run the VI.

 

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Nick
Comments
Not applicable

Dear niNickC,

We built also an LED Cube 4x4x4 for a school project and have a few questions:
We used 3x 8 Bit Shift Registers for controlling the Cube but our other parts are each similar to your Cube.
Now, our question is: can you help us with a LabView programm?
We will show you our shematic image to show what we got.

Hope to hear you soon.

Greets

Member niNickC
Member

Hello,

Thanks for getting in contact.

I was abit lazy and didn't use a shift register - I think it might present a few extra challenges!

But yes I would be very happy to lend a hand where I can!

If you take a look at my code and then it might be best if you make a post on the forums (and post a link here) or make a new discussion here on the community.

ni.com/forums      https://decibel.ni.com/content/threads

Nick
Member guillermo_mecat
Member

Hi

Excelent work!!!!

I've done a LED cube 4 X 4 X 4, but not where to start programming, I think to do with a MSP430 microcontroller in C language, and I have some questions ... As I start to do the frames? ... or I can make a program that is similar to the last image? thanks