From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to keep that valve open for certain period of time and shut off automatically

Hi everyone,

 

The objective of the VI is to measure pH and then open acid or base valve based on pH valve. Below is my UNFINISHED VI

 

My question is:  if, for example, the  pH is 10, then, the program will open acidic valve for 5 seconds and then shut off automatically. After that, wait for 5 second. this process will go on and on as I use while loop, but I just dont know how to control the valve on for 5sec and off and then wait for 5sec.

 

Anyone can help me out?  🙂  Thank you very much

 

In the picture, please enter those values before running

 

P.S The VI is based on previously posted vi by someone who made it 1 yrs ago.

 

Download All
0 Kudos
Message 1 of 26
(4,989 Views)

While the community gives this a look, check out NI.com's section on debugging and fixing incorrect behavior at the following link.

 

http://www.ni.com/gettingstarted/labviewbasics/debug.htm#Fixing Incorrect Behavior

 

Highlight execution and tools such as "step over" and "step into" can give you deeper insight as to how your code is really working.

Daniel G.
Semiconductor & Wireless
National Instruments
0 Kudos
Message 2 of 26
(4,953 Views)

Thank you

 

I tried my best and made the IV work but still have two major bugs...for example, if pH is 10, then the HCL valve is open/close, open/close very quickly.....

 

Basically I dont know how to let HCL valve or NaOH opens for a while and then close for a while. I tried 'wait' but that doesnt work.

 

So, could anyone help me figure out?

 

===============================================================================================================

 

Also, another big question is: I will connect the VI to USB-6008, but before, that, how do I know my VI is good enough to connect to real world?

 

This VI is just my trial for the project, the main issue is to use PID control. Well, there are tons of PID video tutorials but all I watched were  just wired analog input and analog output. I didnt see anyone discussed about how PID acquires analog input and generate DIGITAL output to control relay to turn on/off device..... I  went through this forum a little bit, and found someone mentioning PWM, square wave form something like that.  If anyone have suggestion or experience, please instruct me, I am eager to learn more!!

 

thank you very much!!

 

 

0 Kudos
Message 3 of 26
(4,929 Views)

1. The reason the valves close immediately is that the Elapsed Time VI does not cause any wait, it only measures the time. So the valves closed within a small fraction of a second of the time they opened.

2. I modified your VI to wait until the Elapsed Time has ended.  See the "wait" state.  I probably modified some of your other functionality in the process, but this shows one way you could do the timing. 

3. You do not need any Value property nodes.  They should never be used if the value can be wired directly.

4. You do not need any sequence structures. Dataflow will determine the order of things occurring.

5. If you use an enum for the state machine (and it is a good way to name and select states), you should make it a type def. Then when you need to change it as I did to add several states, you only need to change the Type Def in one place and the changes propagate through to every place you used the control or constants derived from it.

6. I added a Halt state which will close both valves before stopping the program.  When you are controlling a real world process, it is important to consider the start up and shutdown requirements. For example the digital outputs of the USB-6008 default to inputs when the device is first powered up. And, the inputs are pulled high by a 4700 ohm resistor (at least I think I recall that value). Will this open your valves before the program starts running and sets the I/O lines to outputs and forces them low?

 

The USB-6008 has rather limited drive on the digital lines. You will probably need a buffer between it and the valve coils.

 

PID and PWM are more complicated than I want to get into here.  First, are your valves proportional or on/off? Second, (assuming that they are on/off) how fast can you open and close them without destroying them in the first week? What is their expected lifetime in terms of the number of operations? How fast do you need to be able to change them to keep your pH where you want it?  Are these values compatible?

 

Lynn

Download All
0 Kudos
Message 4 of 26
(4,915 Views)

1. Thank you for pointing out my inappropriate Vi programming.

 

2. For the valve selection, the valve has 10ms response time; and it is on/off operation.

 

3. Regarding the USB 6008, yes, many people say its digital output has low current and low voltage, we have to use relay and we already ordered  6008 actually.

 

4. You mentioned PID and PWM are more complicated, what's the place to start with? a book that talks about control and labview regarding this issue? Some people mentioned counter and they said if DAQ device had other 'functions' (i really dont remember).. the VI code complexity can be reduced?

 

Best,

 

 

0 Kudos
Message 5 of 26
(4,901 Views)

Your really need to start with the system specifications.

 

Get the information about your valve.  Until you know what kind of valve you have and what it takes to control it, you cannot begin to design the software and hardware to control it.

 

The reponse time of the valve is only a small part of what you need to know. How fast do the reagents flow? What is the smallest amount of reagent you need to dispense at at a time? How many operations is the expected lifetime of the valve?

 

After you have that you can determine whether your approach even makes sense.  Then you can decide what kind of control algorithm should be used.

 

Lynn

0 Kudos
Message 6 of 26
(4,891 Views)

The valve is on/off and we have to use relay to drive it.

 

For the valve life expectancy, its about 5 yrs,, but since we are just starting building the code, life exptetancy can be resolved later

 

the flow of the system is very slowwww.....  500mL/hr, the project requirements says the pH adjustment is 24 hours..but you know, when we present what we have, we cannot wait the fluid to flow 24 hr to see pH change.When it is time to measure pH and find the value is too basic, then, NaOH valve should open to let NaOH to come out slowly from a dripping chamber. The flowing work is done by gravity...

 

So for the prototype, we want to adjust pH as soon as we can. Is my idea decent or wrong?

 

 

Best,

Yi

0 Kudos
Message 7 of 26
(4,888 Views)

Yi,

 

OK, we are making some progress.

 

The concern I had with life expectancy is that many relays and valves have life expectancies of 10,000 to 100,000 operations. An operation is opening or closing the valve one time.  If you were to try to open and close the valve about 1 time per second, it would wear out in a day.  When people talk about PWM, they are often thinking of rates from microseconds to seconds and these are just not compatible with most valves and relays.  In your project it sounds as though operating the valve a few times per hour may be all that is required.  In that case your approach should work.

 

The biggest issue you may find with the controller is the long delay between actuating a valve and seeing a pH change. Long delays in the "plant" often result in unstable control systems.

 

For your prototype will the pH change faster than in the final system?

 

Lynn

0 Kudos
Message 8 of 26
(4,875 Views)

Lynn

 

The relay we are going to use will be toggle on/toggle off; meaning we will send a pulse to open it, and another to close. According to the manfacuturer of the valves and relays, life expectancy shouldn't be an issue. The valve will open for probably less than 5 seconds, and it won't be activating for more than once an hour.

 

The main concern as far as using the PID controller is that the measurements and corrections are not happening simulataneously; we will correct (open the valve for a calculated amount of time), and then we will measure afterwards. I know that PID controllers have real-time feedback. I was hoping there was a way to alter the PID controller to work the way we want it to rather than creating a brand new VI.

 

 

0 Kudos
Message 9 of 26
(4,859 Views)

Do you understand how a PID controller works? Why do you think PID control is appropriate for your application?

 

A PID controller takes in analog values and outputs an analog value. That's the nature of how it works. A digital output can never be proportional (the P in PID) to another value - it can only be on or off. In order for PID to control a digital output, it most do so indirectly, by controlling some analog value. Most often that value is time. PWM means sending an alternating on/off signal to the digital output, usually at high frequency, where the PID determines the amount of time that the output is ON versus OFF. This is why Lynn was asking about lifetime and number of cycles - because when you mention PWM it implies cycling the valve on and off quickly. It sounds like that's not what you want to do, however.

0 Kudos
Message 10 of 26
(4,849 Views)