
wz2b (Customer) asked a question.
I'm building an app that uses a mix of SFC and ST. There's one thing about the SFC that I haven't figured out yet: can you externally observe the state (from an ST program) without coding that yourself? I'm trying to accomplish two things
- Externally reset the SFC to its initial state, based on an externally calculated reset signal. This is in part so that every single state in the SFC doesn't have to have a transition to observe that signal - I want it to be asynchronous.
- Observe the current state
What I expected was that the SFC would have a state variable that could be in the 'global' var space but that's either not the case or I just haven't figured out how.
Another way I thought to do this would be if there could be something like an action in the SFC that runs on every scan, regardless of what state you're in. I think if that existed then I could GOTO the initial state based on my external condition. But I haven't found that yet, either, and it kind of defeats (at least part of) the purpose of having an initial state. I think I'm really looking for some kind of external SFC reset strategy.
There doesn't appear to be a way to reset the SFC externally without adding a transition to the states. It might make sense to do a state machine in ST with CASE statement. Then you can reset the variable used in the case statement to the beginning state.
For Observing state:
Double click a step. Check the Step variable box. Then assign a global variable. The external ST program can monitor/control those step variables.