From 11:00 PM CST Friday, Feb 14th - 6:30 PM CST Saturday, Feb 15th, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CST Friday, Feb 14th - 6:30 PM CST Saturday, Feb 15th, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-25-2010 04:13 PM
Hello Labviewers!!
Well, I've found myself stuck again. We've assembled a system comprised of an air compressor, a CO2 Adsorber (carbon dioxide remover), and a storage tank to hold the CO2-free air. My job now is to develop code which will automate the process of opening a series of solenoid valves (by firing relays) thus allowing for the creation and storage of CO2-free air. I think I've got the logic straight in my head but I'm having a hard time figuring out how to code this in LabVIEW. The system should operate like this:
A pressure gauge is continuously monitoring the pressure on the storage tank. I would like the storage tank pressure to stay between 30-50 psi. If the pressure reaches 30 psi I need to open a solenoid, wait for 1 minute, and open anther solenoid and wait. At this point the system should be adding pressure to the storage tank. When the pressure in the storage tank reaches 50 psi I would like to close the solenoids and wait for the pressure to drop down to 30 psi before doing anything more.
My problem is that while I can write code which will open the first solenoid, wait for 1 minute, and open the second solenoid, I don't know how to program "wait until the pressure reaches 50 before moving on." If I try and put the whole thing in a while loop I encounter the problem of having the 1 minute wait occurring more than once (I only need do this 1 minute wait once per cycle).
Any ideas or suggestions will be appreciated.
Thanks,
Mike
01-25-2010 05:24 PM
I so not know if you can have both operation running at the same time or not. I will assume it is possible.
I would create 2 loops within the application. One to fill the air pressure 50 and one to release the air. That way they will not hold the proces up. Next, I would have the timing loop faster than 1 minute, in your particuliar case every 10 second. This should give a finer degree of control to turning the pressure on or off. If you don't, you can be off by about a minute versus 10 seconds.
01-25-2010 06:49 PM
Thanks for the reply. I suppose I should clarify that I won't be direclty controlling the air pressures in the application, just reacting to the pressures.
I think I need to use a series of shift registers and case structures but just don't have that much experience with them. Here's another look at the logic I'm trying to code for:
While
if (pressureReading <30)&&(isAdsorberRunning==false){
openValve1();
wait60seconds();
openvalve2();
isAdsorberRunner==true;
}
if(pressureReading >50)&&(isAdsorverRunning==true){
closeValve2();
closeValve1();
isAdsorberRunning=false;
Once again any help is greatly appreciated.
Thanks,
Mike
01-26-2010 04:12 AM
Hi Mike,
What you are looking for is a State Machine. This is a very common LabVIEW design pattern.
There are tons of resources available on State Machines including many videos - which may be the fastest way to learn them. Do a google search on "labview state machine video". Of course also search the National site for more info.
> I think I need to use a series of shift registers and case structures
You are on the right track with this statement. A State Machine usually uses a shift register to keep track of the state and a series of case structures that contain the different state actions. You determine which state to go to next in each state (case).
For your application you would have an Initial State that checks your conditions (pressure reading, isAdsorberRunning). From there you decide which state to execute (or remain in the current state if no action needs to take place).
Check out the resources and give it a try. If you have trouble - ask questions. Posting your problem code often gets quicker and better answers.
steve
01-26-2010 05:29 AM
Hi mike,
Also rather than using the "wait" 1 minute function use the" elapsed time with a reset" express VI (or code your own once you see how it works). This will enable you to remain in the state and monitor pressures while the elapsed time is still running. When elapsed time has occured move onto next state etc. By doing it this way you avoid using the wait function which inhibits the monitoring capability of the state machine (moore Vs mealy maybey??)
Craig
01-26-2010 09:36 AM
Thanks for the replys. I'll look into State Machines this morning and I'll keep in mind that I should use the "elapsed time with a reset" expressVI. I'll let you know how it goes after I have some code.
Thanks again,
Mike