christopher Posted May 24 Report Share Posted May 24 Hi, I'm working on a program for hydraulic controls, there are 6 valves with manual control (12 states). Whenever a switch is operated it set the control valve and start the pump (common for all valves). I have one ladder net for each valve and call a subroutine to start the pump, open main valve etc. This seems to work and using the subroutine code it is easy to fix and read. However I don't find a good solution to delay the pump stop when the manual switch is released. Haven't worked with PLC in many years, so I need a few tips. The pseudo code is something like: Push and hold Button1->Open valveA, open Valve1 and start pump Release Button1 -> Close valveA, close Valve1 and delay 10sec stop pump Quote Link to comment Share on other sites More sharing options...
MVP 2022 Ausman Posted May 25 MVP 2022 Report Share Posted May 25 Just FYI, have you read this? https://forum.unitronics.com/topic/8850-important-sub-routine-advice-updated/ Changing your usage of subs will likely make the delay much easier, and better operation all round. cheers, Aus Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted May 26 Report Share Posted May 26 Try this code: Quote Link to comment Share on other sites More sharing options...
MVP 2022 Ausman Posted May 26 MVP 2022 Report Share Posted May 26 This seems fine for one valve Gabriel, but I thought it had to allow for any or all of the 6 valves being in use, and only doing pump shutdown on all of them being off. 6 "master" call MBs inverted in series could start the timer, which is then linked to the pump control..... however that is done. But that's why I thought it might get a bit iffy if each valve works via a conditionally run sub. cheers, Aus 1 Quote Link to comment Share on other sites More sharing options...
christopher Posted May 26 Author Report Share Posted May 26 You are right Ausman, if any (or all ) of the 6 valves are in use the same main pump are running and the pump shutdown are delayed when the last of them are turned off. I've looked into the sub-routine advice, and also the examples from Unitronics, maybe I'm to OOP minded when I want the same net/routine to be re-used and only 1 timer to be used for the same task. The switches (S1, S2 etc) in thise case are also latched while beeing operated with spring return, so no self holding or set/reset for the valves A, B etc. Quote Link to comment Share on other sites More sharing options...
christopher Posted May 26 Author Report Share Posted May 26 Here is the valve program, the subroutine runs the pump as long as the input is high and works perfect (without the off-delay), and I need 1 net for each input/output. I assume a lot of you prefer using input buffer bits with subroutines, and maybe I'll rewrite for that, my code is based on the examples provided in the help section. 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted May 26 MVP 2022 Report Share Posted May 26 Use a TE (Extended Pulse) Timer. Activate the timer with a negative transition of the run bit or positive transition of the stop bit (depending on how you have your logic set up - looking above you would need the negative transition). Use the TE Timer output bit in parallel with whatever is activating the output. This will allow the output to continue to run for the preset time after stop signal occurs. 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 kratmel Posted May 27 MVP 2022 Report Share Posted May 27 One of possible solution for many valves and one pump control 1 Quote Link to comment Share on other sites More sharing options...
christopher Posted June 2 Author Report Share Posted June 2 Thanks for all suggestions, it looks like I have reconsider how I approach problems like these in the PLC coding. Instead of calling the delay function for each tasks it's need (in this case it looks like the delay is only needed for 6 valves) I probably need the have a complete sub routine for each of these main tasks. It kind of contradicts how I'd like to get "high coupling and low cohesion" programs to work, but I guess it's also depends on POV. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.