LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop and close serial connection question

I have 5 SubVIs. One is a basic serial open, one is a serial close. The three others are as follows

 

1. Sends a command via serial connection to start a vacuum pump

2. "             "                   "        "    "               to stop  the vacuum pump

3. Reads pressure from the vacuum pump.

 

The problem I am running into is that I want the VI that reads the pressure to be in a while loop so that it is reading continuously. However, I want to be able to start and stop the pump as I wish while that while loops is running. I am assuming I can use case structures but I am not exactly sure how to make this work. Any advice is appreciated. Also, I can't test my program because I am not sure how to close the serial connection when I have 3 sub VI's using it. If you could show me how to do that it would be great. My VI is attached and I have left the wires unconnected where I am not sure what to do. Thanks!

 

p.s. please dont tear into me for using tabs, and a carriage return instead of making and array. 🙂 I am already aware of this and it will be fixed.

0 Kudos
Message 1 of 4
(3,155 Views)

It looks to me like you should use a state machine for this application.  There is a good template that ships with labview located at New>>VI>>From Template>>Frameworks>>Design Patterns>>Standard State Machine.  You can create a state for each case ie, Initialize will hold basic serial open, Close will hold serial close...  

 

Feel free to ask questions if they come up. 

0 Kudos
Message 2 of 4
(3,148 Views)

Hey for(

 

I agree with jmcbee that a state machine would be the best option to use for this problem, but other things you could do with your code functionaly is to put each of the cases into one event structure. Therefore even if your switches are set to latch you don't get one case constinously running. However, if everything was wired correctly, such as the reference to each of the vi's, you should not be having that many problems with your code. Could you describe the problems that you are having?

 

Regards,

National Instruments
RIO Embedded Hardware PSE

CompactRIO Developers Guide
0 Kudos
Message 3 of 4
(3,102 Views)

I also try to open or close vacuum pump using labview. What vacuum pump do you use?I just have a regular pump, no serial connection..

 

 

0 Kudos
Message 4 of 4
(2,844 Views)