LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie Advice

I pretty much have my first full VI that I have written for work done. I am a student doing undergrad work so I have just been teaching myself Labview. I thought a good thing to do would be to post my code and get it critiqued because I know it could help me a lot. Feel free to give me criticism and advice because I want to get much better/more efficient at this, especially because Labview on my resume got me an interview this week. Essentially my code takes pressure and temperature readings from serial/GPIB connections and records it along with elapsed time to a spreadsheet file. I am going to make a state machine to compact my code and eliminate local variables but I didn't know about these until recently when my code was almost finished so i havent gotten around to doing that yet.
0 Kudos
Message 1 of 5
(3,165 Views)

For some reason you use two event structures in the same while loop, forcing you to make them "transparent" via a timeout case. It would seem more logical to use a single events tructure with multiple cases and the "reading" done in the timeout case.

 

The booleans (e.g. "stop VI" and "start/stop turbo pump" should be inside their respective event frame. I assume that "stop VI is latch action, and placing it inside the frame esures that is resets when read. Having "start/stop turbo pump" outside the event frame is a disaster waiting to happen. You cannot guarantee that the small case structure receives the new value. The terminal gets read with each iteration fo the big loop and the value placed into the input tunnel of the event structure. When you fire the event, it will read the (possibly stale) boolean from the input tunnel, while the "new value" has not traveled there yet. Another option would be to tap into the "new value" event terminal. This also ensures fresh data.

 

Writing TRUE to the "program running" LED, needs to be done only once before the loop, and not every 50ms.

 

You are writing a lot of value properties after the loop has finished. Unfortunately, you don't show the label so it is impossible to tell from a picture what you are doing. If you want to reset all to default, you can do that with a single property node.

Message 2 of 5
(3,151 Views)
I made those changes you recommended. Thanks. One additional question. I see how to reset all values to default with one property node but that clears my graphs. Is there any way just to reset the booleans to their original value without having to use multiple property nodes? If so, how?
0 Kudos
Message 3 of 5
(3,104 Views)

Hello,

 

I'm not aware of any way to reinitialize the values of only booleans or only strings, etc.. to default programmatically. You could have an initialization portion of your program like you would in text-based programming, and then wire those values in to the terminals where they should be.

 

Does that help at all?

 

Thanks,

 

Dan Richards 

 

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 4 of 5
(3,072 Views)

I would use local variables instead of vlaue properties. For correct execution order place a single-frame flat sequence around the final "stop pump" an place the locals also in it. This will postpone the reset until the big loop has finished.

 

Also note that one boolean FALSE is sufficient for all three, you can branch the wire.

There is no need to create three instances of the same diagram constant. 🙂

0 Kudos
Message 5 of 5
(3,066 Views)