LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer out control to switch off lights connected to a LabJack U12 interface card.

Hi there,

Currently I have a LabJack U12 interface card and running LabVIEW 6.1. Connected to the LabJack card via the Analogue output port, AI0, is a light with dimmer circuitry. Within LabVIEW I am able to control the dimming of the external light by varying the voltage between 0-5volts. This is achieved using the "EAnalogOut.vi".

What I would like to achieve is the lights being turned off automatically by some timer function within LabVIEW, by a time entered by the user of the application on the front form. I am unsure as to how to set the voltage applied to the external light to 0volts, which in turn would turn off the light, after a certain amount of time elapsing. Pl
ease find attached my vi.

Any ideas on the matter would be greatly appreciated.

Thanks in advance,

Neil Sampson.
0 Kudos
Message 1 of 12
(3,854 Views)
You've already got half of what you need. The Get Date/Time in Seconds function outside of the loop is the start time. Put another one inside the loop and subtract the start time from that value. Compare it to a value from a front panel control. This control should be wired from outside the loop if you don't want the user to change the timeout value once the VI starts or put it inside the loop to enable changes while the loop is running. Or the output of the comparison with the front panel stop button.

p.s. Get rid of the Stop function that you have wired to the Boolean stop. You don't need it and it will mess up any functions that you might want to execute when the while loop finishes (like restoring your lights to a default condition).
0 Kudos
Message 2 of 12
(3,854 Views)
Hi again Dennis,

I wonder if you could shed some light on the problems I have now encountered concerning your instructions. After implementing your suggestions into LabVIEW 6.1, I find that the program does not stop after the time, entered in milliseconds, on the front panel indicator. Thus the light connected to the LabJack interface card does not go out.

Secondly, I have found that by not having the Stop function wired to the Boolean stop, the program never seems to stop when I press the Boolean stop button on the front panel. I have encountered this problem in all example vi's I run from the internet or even in the LabVIEW 6.1 Help files, without the application control stop button being implemented. It just seems to reset the progr
am, rather than stop it.

Thirdly, when the program is stopped the light connected to the LabJack card does not go out, due to the fact that the card seems to maintain the last voltage supplied on analogue output AI0, even although the program has stopped. I wonder if you know a way of making LabVIEW supply 0volts to the analogue output when the program is either stopped manually, or by the timeout value set by the user?

Also I would like the time entered by the user on the front panel to decrement every second to show how much time there is left until the light goes out.

Please find my efforts in my modified vi.

Thanks again,

Neil Sampson.
0 Kudos
Message 3 of 12
(3,854 Views)
1. Your vi doesn't stop on timeout because the output of the function isn't wired to anything. The only way your vi will stop (currently) is by pressing the front panel stop button. You need to wire the to the loop stop icon.

2. Do you mean the toolbar abort button? When you stop the vi using the toolbar abort, the vi stops executing commands. This is an abrupt abort - it will prevent the normal program completion (closing files, references, stopping a/d, etc.). Use it only if you get into an endless loop or similar problem.

3. To set the AO to 0 volts on program completion, you need a piece of code to execute after the loop stops. See the attached example.

Good luck,
Tim
0 Kudos
Message 4 of 12
(3,854 Views)
Here's your modified VI. I also took the time to straighten out some of the wires because frankly, I can't stand a messy diagram.
0 Kudos
Message 5 of 12
(3,854 Views)
Hi there Tim,

Thanks for your reply there, but the problem still remains with stopping applications in this manner. With your example vi, if I press the stop button on the front panel when the program is running, the program does not stop. The only way that I can in fact stop the program is to press the toolbar abort button. I have had this problem with all vi's of this sort. Any ideas on the reason why - maybe the version of LabVIEW I am using (Version 6.1)??

Thanks very much,

Neil Sampson.
0 Kudos
Message 6 of 12
(3,854 Views)
Sorry, I can't think of why it won't stop. Does the button depress (change color and appear pressed) when you click it? I don't have this problem in 6.1 (or any previous version).

Tim
0 Kudos
Message 7 of 12
(3,854 Views)
Hi again Dennis,

Thanks for taking the time out to sort out my vi. The program is just about working, but I still have the problem of stopping the application when:

(a) I press the Boolean stop button on the front panel. Instead of stopping the program, it just seems to reset it.

(b) As the indicator on the front panel decrements to 0, the light connected to the interface card goes out for a split second, then relights again to the voltage that was being applied to it. I think 0volts is being sent to the analogue output port, but again the program does not stop at this point. The program just seems to get into a infinite loop.

I have found in all vi's (from the internet, LabVIEW 6.1 Help files, etc)I run using th
is stop method that it will not stop the program, but just resets it. The only way I find I can stop the program is to have the stop function from the application control menu wired as before. This however does not solve the problem of turning the external light off when the time period has ended.

Any ideas would be greatly appreciated and again thanks for taking the time to help me.

I've included my vi again.

Thanks

Neil Sampson.
0 Kudos
Message 8 of 12
(3,854 Views)
Are you definitely starting all your VIs with the regular "Run" button rather than "Run Continuously"?

Regards,
James.
0 Kudos
Message 9 of 12
(3,854 Views)
Neil,

I think I know why you can't seem to stop any vi's. What button do you press to start the vi - the RUN button or RUN CONTINUOUSLY button? If you're using the RUN CONTINUOUSLY button, your vi's will behave exactly as you describe. Under most circumstances the RUN button is the appropriate one. See the attached figure.

Tim
0 Kudos
Message 10 of 12
(3,685 Views)