On the whole "should we or should we not use conditional subroutines" topic, I do have somewhat differing views to what I've read in the main here, but I will simply add my usual adage - it should be application dependant and not a user preference...
Skidood said:
...in my application the machine will run in several different modes which occur one after the other in a mostly fixed sequence...
I believe in using programming methods that best suit and keep the application relatively simple, while also being relatively efficient in execution. For ladder logic programming, and regardless of whichever methods we choose to use, adding detailed enough, yet clear and concise, ladder rung comments are a must as a good practice method of assisting the next programmer that may have to delve into your ladder logic code. Explain to them those "things" you feel may prove difficult for them to understand or fault find. But I do understand that for these more basic controllers the user may not always have an offline copy of the program with those precious comments to assist them. So yes, there are pros and cons. Proper training before using any specialised "tool" is also very important, whether that's a soldering iron or a PLC program. But that too is often lacking.
However, for the above application description, I think it actualy is more suited to applying a "State Machine", which could involve implementing exactly what you had begun with here. Based upon your input conditions, the "machine" will typically only ever be in one state at a time. Once the function of that state is complete it will step to the next required state, and so on. This method is common enough used and often does involve conditionally calling subroutines. If you are not familiar with this method of step sequencing, then you can look it up or ask more questions. But your initial method was essentially using this method so you are no novice to it, whether you realise it or not. But to dive right in you can go straight here (if you have a TechConnect Contract?) and access a working example application...
40854 - Using Subroutines to create a State Machine (Example)
Access Level: TechConnect
If you cannot access that for consideration then let us know and we may be able to help you further.
Another simple real World example I could give is selecting a different program mode for a heating system. Whichever mode is selected calls only the subroutine for that mode, where each subroutine may interact with common I/O points and programming flags. It should not be too difficult to inform a program reader that LAD 2 controls which, and which only subroutine is active at any one time.
When structured correctly, and well commented, I usually have no issue with this type of conditional subroutine control. Each to their own, and all that, but I never dismiss valid methods of programming, once they are implemented properly.
Regards,
George