christopher Posted May 24, 2023 Report Share Posted May 24, 2023 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 Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted May 25, 2023 MVP 2023 Report Share Posted May 25, 2023 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 Link to comment Share on other sites More sharing options...
Gabriel Franco Posted May 26, 2023 Report Share Posted May 26, 2023 Try this code: Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted May 26, 2023 MVP 2023 Report Share Posted May 26, 2023 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 Link to comment Share on other sites More sharing options...
christopher Posted May 26, 2023 Author Report Share Posted May 26, 2023 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. Link to comment Share on other sites More sharing options...
christopher Posted May 26, 2023 Author Report Share Posted May 26, 2023 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 Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted May 26, 2023 MVP 2023 Report Share Posted May 26, 2023 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 Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted May 27, 2023 MVP 2023 Report Share Posted May 27, 2023 One of possible solution for many valves and one pump control 1 Link to comment Share on other sites More sharing options...
christopher Posted June 2, 2023 Author Report Share Posted June 2, 2023 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now