05-16-2015 10:30 AM
Newbie here.
I am writting a vi to control the open/close of a solenoid valve to pressurize a bottle.
The code is to activate the valve (5V) to pressurize the bottle to 20psi, and then deactivate the valve (1V) to depressurize the bottle pressure until its drops down to 10psi. The first channel is connected to a physical switch to start/stop collecting data. The second channel is the input from the pressure sensor.
The attached code is doing what I ask. BUT now I wanted to control the number of pressurize and depressurize cycle, and I con't figure out how to do that!
Any suggestion is greatly appreciated.
05-16-2015 11:23 AM
05-16-2015 04:37 PM
Unfortunately, because LabVIEW "looks so easy" (with pictures and wires instead of lines of words and "interesting" punctuation), beginners often assume that they don't need to think carefully about what they want to do, and jump in with "spaghetti code" (but with wires!) to put down how they want to do it. It almost always ends up a mess.
So here's a question -- if you were writing your task in, say, C++, would you write it as one big While loop, with no functions or sub-programs? Or would you think before coding, and write something like "
05-16-2015 04:56 PM
Oops, pushed wrong button in previous post ...
What I was saying (I think) is your program should look something like "Pressurize (pressure parameter); Depressurize (pressure parameter);" and if you want to control how many times you do this, you'd wrap it in a For loop.
Same with LabVIEW. Break your task down into easily-coded sub-tasks. I recommend making them sub-VIs (it greatly reduces screen clutter, and lets you see the overall logic much better).
When you do write what you want to do, I strongly advise you to not use the DAQ Assistant, and especially do not use Dynamic Data wires. Both obscure what you are doing, and don't allow you the kind of control you might want to use. There is an excellent Tutorial on DAQmx that shows you how easy it is to do 80% of what you need to do by using only 10 DAQmx functions (and you mainly need about half that) -- read it here.
Bob Schor