11-26-2012 01:08 PM
Hi,
It has been several years since I worked with LabVIEW and now I need to utilize it for a project. The main idea is as follows:
There is a power supply whose output will need to be turned ON and OFF at a specific rate (45 minutes ON followed by 15 mins OFF)
This entire process should last for a specific durtation (days or months)
The vi should be able to take inputs from the user : Total Duration, ON duration, OFF duration.
VI should calculate the # of times ON/OFF sequence should be executed and when done, should stop.
Initially, I've implemented a wait (ms) to enable the output block to run for a specific duration until it moved to the next one which is to turn the output OFF. THis is not acceptable as I need to be able to STOP the VI at any time or it should be autmoatalically stopped if any alarms are triggered. With wait (ms), I could not do it.
My question is, what is the most efficient and stable way to do this?
Timed loops or sequences?
11-26-2012 01:11 PM - edited 11-26-2012 01:12 PM
State machine.
A single loop with a few states: Turn on, Turn off, Wait.
In the wait state, what you do is actually only wait for a short period of time such as a second. Determine whether the elapsed time has passed (the 15 or 45 minute type). If it has, then go to the turn on or turn off state. Otherwise return to the Wait state. If anything else happens, then you immediately go to the turn off state then stop the VI.
11-26-2012 01:32 PM
THanks for the suggestion, but I think it does satisfy my requirement.
Let's put some numbers to make it easier to grasp. Let's say I need to run the system for 10 days. During this time, I want the output to stay ON for 45 minutes then OFF for 15. This ON/OFF sequence should repeat for 10 days and should stop by itself or by a stop button.
How can the state machine with a sigle loop and elapsed time can distinguish between the first 45 mins of ON time and the 10th or 20th or so on?
11-26-2012 01:49 PM
The elapsed time express VI is pretty powerful.
It has a reset option. It also has a time target option. When you do your turn on state, you could pass the 45 minute value and a True for reset into a shift register that goes into the elapsed time VI in the wait state. The turn off state would pass a 15 minute value and a True boolean. All other states would just pass through the time target and a false boolean.
You can use another elapsed time VI to determine when 10 days have passed.
11-28-2012 08:49 AM
11-28-2012 11:26 AM
Thanks everyone for the help. I ended up using a large for loop, and inside the loop 2 flat sequence frames with while loops inside each. In each loop, there is an elapsed time vi that counts to a specific time and when time elapsed is True, stops the loop and resets the time. This results in next frame to be executed which is the OFF state. Same Elapsed time idea is used in that frame as well. The large for loop continues until the 10 days is done.