Table of Contents

Standard States

Applications that are developed with the Zeugwerk Framework are broken down into small, manageable units. A unit is a combination of hardware objects that can be used to do a repeatable sequence of actions to perform a partial job of a machines main objective, i.e. a handling unit that moves parts from A to B. While for small applications there may be only one Unit, for large-scale applications there may be numerous Units that are used in conjunction. The actual peculiarity of a unit is always application specific and one of the first tasks to design a new automation application.

Every Unit within the Zeugwerk Framework template by default comes with a standardized statemachine. This statemachine utilies five active states are linked to a Sequence.

  • Booting initial state that each unit is in after activating the PLC. This state is used for getting the unit's equipment ready to work. To be specific, the fieldbus parameters are written and stuff similar to this.
  • GoHome this state is used for referencing the unit, such that it is in a safe, definied state.
  • Automatic the unit is performing its main purpose, i.e. move something from A to B.
  • Stop this state stops the unit in a fast, controlled fashion. It is interrupting any state, even other active ones.
  • FaultReaction this state is used for a fast, controlled stop of the unit that is interrupting any state, even active states. In contrast to the Stop states, this state does should not wait for any subobject that is stopped while the unit is in this state. If the the sequence of this state is aborted, the unit directly transitions into Fault, this however should usually be avoided by ignoring potential errors that are popping up in this state.

If a sequence in a state has finished, it the statemachine performs a transition into one of the following non active states.

  • Init [non-active] state after the boot process has finished. Units, if not explicitly configured differently, wait in this state until the machine operator references the machine by hoping it.
  • Idle [non-active] this state indicated that the unit is read to work, but it is waiting for an instruction by the machine operator or another unit that controls this one.
  • Stopped [non-active] after the unit gets out of its Stop state, it directly transitions to the stop state. Indicating that the stop process has finished.
  • Fault [non-active] after the unit gets out of its FaultReaction state, it directly transitions to the Fault state. Indicating that the FaultReaction process has finished.

In addition to these predefined states, userdefined states can be configured that can be used in large applications to split up a very large automatic sequence into smaller parts like calibration, (...) - see Userdefined States for how to add one. Transition between states follow a state machine. While this statemachine has proofen its worth, it may actually be overwritten with a user-defined state machine (not recommended for standardization issues).

The following diagram shows all possible transitions, including a userdefined state (UserdefinedX):

sequenceDiagram
    participant Init
    participant GoHome
    participant Idle
    participant Automatic
    participant UserdefinedX
    participant Stop
    participant Stopped
    participant FaultReaction
    participant Fault
    
    alt Getting ready
      Init ->> GoHome: GoHome button pressed
      activate GoHome
        GoHome ->> Idle: done
      deactivate GoHome

    else Successful operation
      Idle ->> Automatic: start button pressed
      activate Automatic
        Automatic ->> Idle: done
      deactivate Automatic

      Idle ->> UserdefinedX: buttonX pressed
      activate UserdefinedX
        UserdefinedX ->> Idle: done
      deactivate UserdefinedX

    else Interrupt states by Stop

      GoHome ->> Stop: stop button pressed
      activate Stop
        Stop ->> Stopped: done
      deactivate Stop

      Idle ->> Stop: stop button pressed
      activate Stop
        Stop ->> Stopped: done
      deactivate Stop

      Automatic ->> Stop: stop button pressed
      activate Stop
        Stop ->> Stopped: done
      deactivate Stop

      UserdefinedX ->> Stop: stop button pressed
      activate Stop
        Stop ->> Stopped: done
      deactivate Stop

      Stopped ->> Stop: stop button pressed
      activate Stop
        Stop ->> Stopped: done      
      deactivate Stop
      
    else Error handling of Faults

      GoHome ->> FaultReaction: aborted
      activate FaultReaction
        FaultReaction ->> Fault: done
      deactivate FaultReaction

      Idle ->> FaultReaction: aborted
      activate FaultReaction
        FaultReaction ->> Fault: done
      deactivate FaultReaction

      Automatic ->> FaultReaction: aborted
      activate FaultReaction
        FaultReaction ->> Fault: done
      deactivate FaultReaction

      UserdefinedX ->> FaultReaction: aborted
      activate FaultReaction
        FaultReaction ->> Fault: done
      deactivate FaultReaction

      Stopped ->> FaultReaction: aborted
      activate FaultReaction
        FaultReaction ->> Fault: done
      deactivate FaultReaction      

    else Reference
      Idle ->> GoHome: GoHome button pressed
      activate GoHome
        GoHome ->> Idle: done
      deactivate GoHome
    
      Stopped ->> GoHome: gohome button pressed
      activate GoHome
        GoHome ->> Idle: done
      deactivate GoHome
      
      Fault ->> GoHome: gohome button pressed
      activate GoHome
        GoHome ->> Idle: done
      deactivate GoHome

    end

Practical example

To provide a clearer explanation of this state machine, let's work through a practical example of a production system.

  • When we switch on a production system, it is booting and this is done by the Boot State transition (booting sequence). Usually booting is done automatically, but the developer is able to add here some custom steps that have to be done (e.g. parameterizing equipment).
  • After booting is done, the production system is in the init state. From this state there is only one transition allowed which is to idle state by running Homing (homing sequence). This is usually initiated by a machine operator by pressing a homing button (of cource beforehand the safety environment has to be ok and all infrastructural components have to be ready). The Homing sequence brings the production system in a production ready state from which it can be started.
  • After homing is finished, the production system is in the idle state. Now we can start the production system by pressing a start button or something similar and we run the Automatic sequence which is doing the production process itself.

These are the first 3 steps which are pretty straight forward on a production system. Lets now assume there is a problem in the automatic sequence and the machine stops:

  • If an error occurs the machine has to stop to prevent damage on its components. So the automatic sequence gets interrupted and the FaultReaction sequence is started. There are all those tasks done like stopping axes, stopping actuators, reseting valves, error light is blinking and so on. After this sequence is finished we are in Fault state
  • If the problem is fixed by the operator, the production system is still in this aborted automatic state. To restart, usually there have to be some steps to be done. This is again done by the Homing sequence which is started by the operator and when finished, a transition to idle state is done.
  • Last but not least, the operator can start the production system again by pressing a start button which leads to a transition from idle state to automatic and running the Automatic sequence.

A third and last important step is, stopping the machine without any occuring error. This is similar to the fault reaction behavior, but here the Stop sequence is running and doing all this tasks like stopping axes, stopping actuators and so on. Again by starting homing we get back to idle and after that we can start the system again.

How to use standard states

The easiest way to learn how to use sequences of the standard states is to go through our pre implemented Quickstart Tutorial. Here we have the 4 major states (automatic, homing, stop and faultreaction) implemented. Try to implement some additional steps to the Quickstart Tutorial in automatic sequence to understand when and why these are executed.