LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Turning on a set of LEDs

Solved!
Go to solution

Hello everyone I am new to labview. I am trying to set up a vi in which I have a row of 8 LEDs and a push button. I want to be able to push the button and have it start and stop specific LEDs for a desired amount of time. specifically I want to start LEDs 1,3,7 and 8 and keep them on for 3 minutes, turn off 8 and then 7 in that order and then keep the remaining on for 2 minutes. Then turn the rest off and move to the next sequence. I have tried separating the LEDs into groups of 3 for the sequences but then I was left with 3 while loops and was not sure how to control the timing.

 

The reason I am setting this up is to run solenoid valves that clean 3 different lines with each sequence of LEDs representing a different line. So I wanted to essentially set up an autonomous cleaning cycle.

 

Thanks

Message 1 of 9
(8,659 Views)

By "LED", I assume you mean a Boolean Indicator on the Front Panel, right?

 

Let me see if I can restate your problem in a slightly different way:

  • You have an Array of N (8, in your case) Booleans.
  • You want to do the following thing M times:
    • Set the Array to a particular pattern (e.g. 1, 3, 7, 8 on, 2, 4, 5, 6 off)
    • Wait for some period of time (e.g. 3 min)

Do you see a Data Structure here?  I see a Cluster consisting of an Array of Booleans and a Delay (which you might specify in milliseconds, as this is LabVIEW's "natural" time measurement), and an Array of such Clusters, with the Boolean Array corresponding to your LEDs and their desired pattern, and the Array of Clusters specifying the sequence of steps.  If you know about Data Flow and how a For Loop works, you should be able to see that you can easily create your Flashing Light Show with nothing more than a single For Loop, an Unbundle (please learn to use Unbundle By Name) to get the Boolean Array and the desired Delay, an assignment to your Array of LED Indicators, a Wait (ms) function, and Bob's Your Uncle (well, technically, I'm not ...).

 

For a little fancier application, put the Booleans and Time Delay in a SpreadSheet (either Excel, if you have the Report Generation Toolkit, or a Delimited SpreadSheet), write a little more code to read this Spreadsheet and use it to build the Array of Clusters, then feed the Array into the For Loop.

 

As this is clearly a Learning Assignment, I'll leave finishing this to you.  Be sure you understand why you are doing it this way.

 

Bob Schor

0 Kudos
Message 2 of 9
(8,651 Views)

You can control an entire port (8 lines) with a single call to DAQmx.  If you have a physical button you would like to push, start by creating a loop to monitor the state of that input, based on the state of the input, create another loop to control the 8 Booleans.  This loop could be a simple state machine with an event structure in it.

 

See the attached snippet and give it a try.  You can save and copy the png directly into a VI and it will pull the source code in.

 

Cheers,

 

Tim

0 Kudos
Message 3 of 9
(8,648 Views)

You could start with something simple like this. Use each bit in the U8 integer controls one LED. Pre-load the array of U8s to define the solenoid sequence.

 

 I didn't feel like waiting 5 minutes for the complete cycle, so I just have them changing once per second.

 

cycle.png

0 Kudos
Message 4 of 9
(8,640 Views)

Hi

thank you for the response I wanted to ask how would you indicate which Boolean LED is the integer input in the U8. like how do I make the first Boolean led the first input into the array.

0 Kudos
Message 5 of 9
(8,602 Views)

Bob_Schor

" Do you see a Data Structure here?  I see a Cluster consisting of an Array of Booleans and a Delay (which you might specify in milliseconds, as this is LabVIEW's "natural" time measurement), and an Array of such Clusters, with the Boolean Array corresponding to your LEDs and their desired pattern, and the Array of Clusters specifying the sequence of steps.  If you know about Data Flow and how a For Loop works, you should be able to see that you can easily create your Flashing Light Show with nothing more than a single For Loop, an Unbundle (please learn to use Unbundle By Name) to get the Boolean Array and the desired Delay, an assignment to your Array of LED Indicators, a Wait (ms) function,"

 

so just to make sure I understood your suggestion, and again thank you, First I should use Unbundle to create the Boolean array with its specific delay. the Boolean array will specify the pattern that I wanted. and then have this array go to a cluster. and basically I will have multiple clusters for each set of Booleans or is it a single cluster for lets say a line which has 3 sets of Boolean patterns? that was the part I was unsure about. But once that is done, the clusters go to an array and that is the whole combination? sorry was thrown off by the wording.

 

thanks

0 Kudos
Message 6 of 9
(8,598 Views)

@Athakore wrote:

Hi

thank you for the response I wanted to ask how would you indicate which Boolean LED is the integer input in the U8. like how do I make the first Boolean led the first input into the array.


The first LED would be Bit 0 in the U8 and would correspond to the Solenoid Valve[0], the second LED would be bit 1 and Solenoid Valve[1], etc.

 

Many commercial switch matrices use this method (was assuming you would be trying to control real hardware and not just the front panel UI). If you use clusters then it would look something like this (I used msec instead of minutes for the dwell)

 

Capture.JPG

cycle (with dwell).png

 

0 Kudos
Message 7 of 9
(8,579 Views)
Solution
Accepted by topic author Athakore

This is just a very simple state machine. I would recommend to use "high resolution relative seconds" because the units are nicer and you can easily use a time format numeric directly.

 

You did not specify a time interval between turning off 8 and 7 ("then" implies an order and thus requires the definition of a delay!)

 

Here'is a simple simulation. It would be trivial to add a DIO write whenever the LED status has just changed.

 

LEDSequencing.png

 

 

 

Message 8 of 9
(8,573 Views)

So here is a Cluster called LED State consisting of an Array of Boolean Controls (called LEDs) and a U32 called Delay (ms), as well as an Array called Array of LED States.

LED State Types.png

And here is how you might use this Array (I left out doing things with the Array of LEDs).

LED Processing.png

Bob Schor

0 Kudos
Message 9 of 9
(8,560 Views)