ni.com is currently experiencing slowness.

Support teams are actively working on the resolution.

Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Individual Timing of Two Valves?

Solved!
Go to solution

Hello! I'm new to LabVIEW and have gone through some tutorials and have used some examples to get started on making a VI for what I need. I am controlling two solenoid valves that both have their own open/closed times, which are user specified. I am using an Arduino and already have a circuit set up with a MOSFET that is capable of safely powering/controlling the valves. I wrote an Arduino sketch that does what I need, but the experimental setup requires control through LabVIEW.

 

Basically, I need to have each valve initially open for a set amount of time (ex: valve0 for 500 ms, valve1 for 700 ms), then immediately after the specified time each valve needs to start cycling at its own rate (ex: valve0 open for 150 ms then closed for 250 ms, valve1 with different timing).

 

So far, I've successfully been able to control a single valve in the way I want to using LINX (image attached). I can tell the valve to start open for a time, then begin cycling at my specified rate. My struggle now is figuring out how to properly extend this control to two outputs, ensuring that the uneven timing between valves doesn't mess things up.

 

Any help would be greatly appreciated!

0 Kudos
Message 1 of 8
(2,426 Views)

I would look into using a State Machine architecture and since you are a beginner I would look into the JKI State Machine.  This can be installed through VIPM.  There any many examples and training available on this type of architecture to get you started.

 

Basically I would define a loop rate, your timeout in the JKI State Machine, and every loop look at the current time compared to the last change time of each valve.  If the delta time is greater then your cycle time for that value then transition to a case to trigger the value and store the current time to be used for determining the next cycle.  In this way you could extend it to as may valves as you want with as many different durations that you want.

David Wilt
The New Standard LLC
Message 2 of 8
(2,413 Views)

Following the previous state machine suggestion, you may want to try the DVR timer to cleanly handle the two timers :  https://www.vipm.io/package/ni_lib_simple_dvr_timer_api/

 

How tights does you valve timing need to be? Can it drift a little?

 

L.

 

PS: State machine: you can use a basic state machine also as found in the LV examples. "State Machine.lvproj"  under C:\Program Files (x86)\National Instruments\LabVIEW 20XX\examples\Design Patterns\State Machine

Message 3 of 8
(2,409 Views)

Thank you both for the responses and feedback! I will spend some time with this now and report back with any questions or issues.

 

L: The timing can vary by +/- 10% roughly and still be fine.

 

-Peter

0 Kudos
Message 4 of 8
(2,390 Views)
Solution
Accepted by topic author PThreePO

I wouldn't use state machine for 2 valves (2 digital output signals) which are independent after start action. See attachment.

 

Message 5 of 8
(2,349 Views)

Thanks for all the help everyone! Splitting the LINX resource and duplicating what I had ended up working, though I understand that the timing may not be exact and it can't be easily scaled. Also learned a bit in the process 🙂 

0 Kudos
Message 6 of 8
(2,328 Views)