11-12-2024 07:32 AM
I am building a test setup where I need to change gas flow by operating a switch valve. I've been trying to write some code, the VI runs but doesn't really do what I want.
I have an NI 9185 chassis with an NI 9401 Digital I/O module. I have a Vici 4 port, 2 position valve (manual, p3 for configuration) that I want to be able to switch on and off. The test is run with the Vici valve in the "A" position and then after certain conditions have been met I want to switch to the "B" position.
The conditions to be met will either be determined by time or other experimental observations, so the code doesn't need to do that.
See the attached VI, I got stuck. It does seem that when I start with the valve in "B" position, I can get it to switch to "A." But I cannot get this program to switch to "B" after starting in the "A" positon like I want. Any advice would be appreciated!
11-12-2024 08:48 AM
Please attach your vi code, save it for Lv Version 2020 or older
11-12-2024 09:48 AM
It shouldn't be necessary to change anything since "Two Position With Stops" is the default mode, but double-check that your valve is configured this way. You can use the remote control to verify it by following the menu diagram on page 23 of the manual. Once set, it will be permanently saved to the actuator's memory.
You mentioned getting stuck when trying to switch from "A" to "B." Based on what you described, this might be a physical wiring or pin assignment issue. I'd suggest adding an indicator to your program to verify if there are any errors when reading the states of pins 4 and 6. You could also use the manual remote to monitor the valve's position. Make sure that you're energizing and de-energizing pins 3 and 1 correctly. It’s possible that pin 3 might still be energized, preventing the switch to "B."
I have experience with the same actuator, though I control it using an Arduino with the Hobbyist Toolkit. I’ve attached my code here in case it’s helpful.
11-12-2024 10:01 AM
Hey thanks for the reply, lets see if this works, having issues uploading my VIs at the moment
11-12-2024 10:37 AM - edited 11-12-2024 10:39 AM
There are no actions to execute in the case structure when the switch condition is False. That's probably when you need to go from B to A.
On a separate note, there's no need to read and compare the boolean state every time. Also, an event structure takes care of that. Not critical here, but more elegant and efficient for larger programs. Best to build the habit now.
11-12-2024 11:12 AM - edited 11-12-2024 11:14 AM
@drShredz7684 wrote:
Hey thanks for the reply, lets see if this works, having issues uploading my VIs at the moment
There are plenty of things wrong with this VI.
See if this can give you some ideas.... This will write the new value whenever the toggle changes state.
(definitely needs more work, for example you probably would want to write F when stop is pressed or ensure the correct output before the toggle is touched by the user, etc..)
I and not a "hardware guy", so there could be some omissions. I Strongly recommend to look at the shipping examples and the learning resources listed at the top of the forum.
11-13-2024 02:22 PM
Thats why I posted it here ha. I have been going through the CORE 1 courses and excercises they are really helpful but I still have a ways to go to get through all of it. I was attempting to use some AI my company developed to help with some of the LABView code writing initially, but I don't think it does this very well.
Its a lot cleaner, and got rid of some of the silly things like stopping the task each time. I still can only get it to switch from the "B" to "A" position, and not the other way.
I've taken what you put together, and after looking at what cyclotronist posted, it seems like I am not getting the pins to fire in correct sequence to do this. I'm trying to follow his Vici valve actuator VI since its the same hardware I have. If i am interpreting this correctly, he is initally writing the initial state of the output channels to initialize them, then reading the specific ones in question (within loop) and then writing the new updated values in the event structure.
11-13-2024 03:31 PM
You forgot the shift register I used. There is no reason to duplicate all that inner code. You only need to write the line when there is a new value, so the false case should be empty.
Also:
@drShredz7684 wrote:
it seems like I am not getting the pins to fire in correct sequence to do this.
You currently have only one pin (i.e. a boolean array with one element), so I am not sure what you mean by "pins in the right sequence"
@drShredz7684 wrote:
some of the LABView code writing initially,
After core 1, most people know that it is LabVIEW. Note the lettercase.