11-07-2011 06:40 AM
Hi
What is the best way to implement this code in labview programming.
I have an analogue input which triggers a boolean light when it reaches a certain voltage. but at the same time i would like it to enable two other outputs one for a set period of time and the other stay on until another statement becomes true.
For example
case 1:
Set output high
Delay(2000ms)
Set output low
Case 2:
Set output high
If statement 2 is true
then set out put low
if not then repeat until statement is true
Thanks for your help
11-07-2011 07:14 AM - edited 11-07-2011 07:15 AM
Repeat what?
What is statement 2?
11-07-2011 07:45 AM
lol I started to explain myself further and just answered my own question about the second case so we dont need to worry about that one at the moment i will try it later. My main problem is finding the function that will turn something on for a certain period of time and then turn it off.
for example
If voltage is greater than 1 -> light turns on -> delay 2 hours -> light turns off
But during that 2 hours even if the voltage drops below 1 it wont turn the light off.
mainly just looking for the right delay function that can delay that section of the program for 2 hours whilst the rest of the program is still running. im guessing it will have to go into some sort of a contained structure. Still getting used to all the functions on labview 😞 !
Thanks
11-07-2011 08:11 AM
You could use a state machine which has a "Wait" case - in this case you can poll an Elapsed Time Express VI, or use a functional global variable (FGV) to query whether or not the time has elapsed.
If it has not elapsed, stay in the "Wait" case. If it has elapsed, or another condition occurs, move to the appropriate case.
11-07-2011 08:12 AM
Hello,
I have attached a piece of code that I have written to do what I believe you require. The time that the VI waits for can be adjusted by changing the constant wired to the Wait (ms) function. This VI is very simple and only uses a numeric constant as an input but you could modify it quite easily to fit into your code.
Regards
11-07-2011 08:24 AM - edited 11-07-2011 08:27 AM
Hi David,
The code you posted will work, although note that the front panel becomes 'unresponsive' - as changes in the controls are only read once per iteration. The wait function is an example of an execution timing VI, however if we want to do software timing (like a 2 hour wait) - we should use software timing VIs.
Check out the following example (note we can stop execution during run-time):
11-07-2011 09:05 AM
this looks like what i was looking for i will have ago at it later and get back to you guys.
thanks for the quick reply
11-07-2011 09:43 AM
No problem, I look forward to hearing how you get on!
Created a related community example showing the key difference between the two types of timing.