I have a need for a VI that controls valves (8-port motor valves and solenoid valves) in a loop. I have produced a code (see the attachment) that works with he solenoid valves. The program turns on the solenoid valves for a certain time period and then closes them for other period. However, the problem is that the code sends the command to the valve each time the loop is iterated. This is "fine" with the solenoid valves. However, if I use the same code to control an 8-port motor valve, the valve just turns and turns as it get the command to change position (although the position is the same) each time the loop is iterated. I tried to remedy the situation with feedback loop and comparison function so that the command to the valve would be given only once even if the loop is iterated for n times. This did not solve the problem. Could anyone of you help me with this problem? I have tried to check the discussions on this forum for help, but with no luck.
to solve your problem is almost always helps to describe the desired algorithm in words as precise as possible!
- How do you want to run your sequence?
- When do you want to switch valves?
- How often do you want to switch valves?
- Are there conditions to monitor before switching?
Once you answered all those questions you surely have an idea of how to program your statemachine, which most probably solves your issue! 😄
As GerdW said you better use a state machine based program. Because switching valves is a considerably dangerous control in some scenarios. Thereby, you need to control them only when you need to. Besides, no need to increase the RAM and memory space consumption by considering a While Loop that does not have a 'time delay'.