Welcome back! The chart I posted was kind of a general way to utilize timers and “state” for controlling a process. This would all be wrapped in a loop - that is the part that probably caused some misunderstanding.
This code will need to be called in a loop over and over again - say every 500ms or so. Since we are calling it over and over, we need to remember the state of our process, so I keep that in a mode variable.
Now my flow chart is not complete in anyway - just wanted to get a quick example out to show you how I would utilize timers to control a process.
I’ll try to explain more with each of your questions.
The way I was thinking about this is I would have mode normally set to “shut down”. If I want the process to start, then I would set this to “startup” - this would be somewhere else in my strategy. The code I posted would continue to run over and over, checking the mode.
On startup it will keep checking for flow, and if there is no flow, it checks if the timer expired or not - if not, then we know we are okay and just have to wait a little while to detect flow, so we exit. This happens over and over until we either detect flow or the timer expires. If the timer expires, then we know the startup failed for some reason and we can report that and shutdown or do whatever your process needs.
No, it will check the flow immediately after it commands the valve to open - we don’t care, the code will move on, start the timer on the first time through and exit. Some time later (in 500ms if that’s what we choose), the code will need called again and the flow will be checked again, and over and over again.
The safeties will be checked as often as the code is called. Since we are keeping track of the “state” and are using timers, we can start from the top of the code and know where we are in our process. So the safeties will get checked as often as we go through our loop - so 500ms in our example.
To build on to what I wrote above (the chart) - say for shutdown, I would have two modes - “Shutting Down” and “Shut Down”. So when I am done with the process, I would set the mode to “Shutting Down” - this could be somewhere else in the strategy outside our loop, or in response to a safety in this logic. Shutting down could then command the valve closed, and start a timer and stay in that mode until we detect flow has stopped. Once we detect flow has stopped, then we change our mode to “Shut down”. We then would add a condition for “Shut Down” that will exit - it can still be called over and over, but since we are in mode “shut down”, we simply exit.
I could write more - ha ha. Hopefully I haven’t caused you too much confusion, let me know if I need to explain any of this better.