LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[Beginner] Turn off LED when program times out?

Hello! I'm trying to create a program that will turn off LEDs after a number of seconds, or when the program is ended. I found this program - http://forums.ni.com/t5/LabVIEW/how-to-automatically-turn-off-leds-after-1-minute-button-press/td-p/...

but can't seem to configure it with the DAQ Assistant I've been using. The program I've been working on is attached. 

Any ideas or help would be much appreciated!

Ashleigh

0 Kudos
Message 1 of 5
(4,376 Views)

Sorry, I don't have DAQ, but you seem to have a few misconceptions.

 

Does the program currently work?

 

Some general points on programming stype:

  • The shift register is not needed because the value in it never changes. You can use a plain tunnel on the left. (Of course if you later want to add functionality (e.g. the ability to reset the timer without stopping the program), you need the shift register again.
  • The wire going to the local variable and the loop boundary makes little sense and does not eliminate any race condition. After the wire branch, the loop starts in parallel to writing the local variable, so the wire going to the loop probably makes no difference. It also seems unecessary to set te boolean here. Just delete the local variable and diagram constant  and just wire it the the output of the OR node (after inverting the value).
  • The "lock boolean text" is a static property. Since it is true by default you never need to write it again. It cannot change during the run, so why hammer the same value into it 10 times per second?
  • The OR inside the case structure is irrelevant, since the upper value is always FALSE. You probably should eliminate the case structure entirely, now it makes sense and writes a false to all LEDs when the program stops. But you need a boolean AND after inverting the comparison!
  • The "light control" should probably contain default data and not be zero size. Make current values default then save the VI.
  • It might be more efficient to use lower level DAQ function. define the task before the loop, write the LEDs inside the loop, and stop the task once the loop has completed.
0 Kudos
Message 2 of 5
(4,362 Views)

Ashleigh,

 

It helps us to help you if you ask a specific question. I am guessing, from the way your program works, that you want to know how to set the Digital Output to the hardware LED to the off state when the program is stopped, right?

 

To do that you need to write a set of all False values to the Digital Output in the False case or after the while loop exits.

 

Since you are a beginner and are trying to learn, I will give you some hints but not do it for you.

1. If you need to write to Digital Output in both the True and False cases, consider the problems of duplicating code. Also, you will probably get an error if you try to set two DAQ Assitants to write to the same Digital Port. Hint: Only the data is different between the cases.

2. What is the purpose of the shift register? The same value is wired across the loop. 

3. You could set the Lock Boolean Text by context-clicking on the indicator and checking the box in the Properties dialog. Or, if you prefer to use the property node as you have it in your VI, make a second property node and set that property one time before the loop starts. There is no need to write the same value to that property 10 times per second.

 

Lynn

 

0 Kudos
Message 3 of 5
(4,357 Views)

altenbach,

 

The default property for a boolean LED (which does not have boolean text visible) is with Lock text in center unchecked. It is checked on booleans which have text showing when dropped.

 

Lynn

 

Boolean Properties.png

0 Kudos
Message 4 of 5
(4,356 Views)

johnsold wrote:

The default property for a boolean LED (which does not have boolean text visible) is with Lock text in center unchecked. It is checked on booleans which have text showing when dropped.


Well yes, but once it is set, e.g. after running the VI once, it never needs to be changed again unless the VI is not saved. (I was talking about the program default, not the system default. Sorry for not being completely clear).

 

Here is a simple code skeleton that does exactly what's required (simulated).

 

 

 

 

0 Kudos
Message 5 of 5
(4,348 Views)