Learning phase 6: Macro Steps

Learning Aim

It is not so easy to maintain the overview, particularly in the case of more complex GRAFCET charts. Macro steps can be very helpful here. Macro steps allow you to summarise and transfer steps. These transferred steps can then be addressed with the help of a superordinate term (the macro step). A macro step has an input step and an output step. Furthermore, the GRAFCET structure located in the macro step should be processed in full.

This learning phase introduces and applies macro steps.

Learning steps:

  • Creation of a macro step and its expansion (realisation)
  • Designation and use of the input and output step

Things you should know

In , macro step M2 is used within a sequence. As with every step, you need to define a label for the step in the symbol for the macro step. However, the prefix M is required in the label for the macro step.

Fig. 3.107 Macro step M2

Macro step M2 can be addressed as a step variable with the label XM2. Macro step M2 represents the steps shown within the border "M2" (expansion). This realisation of the macro step must exist.

Note

The expansion (or implementation) of the macro step always begins with the initial step, indicated by the prefix E Entrée = Input) and the macro step label. The end of the macro step is prefixed with S (Sortie = Output) and represents the output step. In Grafcet-Studio, the border containing the expansion must be labelled the same as the macro step. In the example above, the border is therefore labelled with the value "M2".

Important

We recommend that you use the label for the macro step for the step labels for the input step and the output step, preceded by the appropriate prefix. Accordingly, the realisation of the macro step M12 would start with the input step E12 and end with the output step S12.

To be able to exit the macro step, its realisation must have been fully processed. This means that the output step must be active and then the transition following the macro call can induce the transfer. In other words, the transition after the macro step is only released once the output step is active.

In the example above, step S2 must therefore be active first, after which the transition to the initial step 1 can take place over the transition following M2 with S1 = False.

In principle, a macro is nothing more than an extension of the GRAFCET structure called up by the user.

An action can also be assigned to a macro step. In the example, a continuing action was attached to M2 which writes the operand Y1.

Fig. 3.108 Macro step M2 with an attached continuing action

Use

PLC-Lab Filename Grafcet-Studio Filename
MuldenBeladen.plclab MuldenBeladen.grafcet

A tilting container with weigh station is fed by a mill following the start signal S1Start until the weigh station reports S3ContainerLoaded. Beforehand, the container to be loaded is to be conveyed along a belt to limit switch S2. Realisation is to take place with macro step M2.

Below, the functionality to be realised in the macro step: The "Start" button S1Start is pressed to activate macro step M2 along with its input step E2, which moves the container to be loaded into the position S2ContainerInPos. The mill motor M2Mill then is switched on until the tilting container reports the full signal S3ContainerLoaded with the value False.

The tilting container is then tilted with M3TiltContainer and on reaching the limit switch S5ContainerIsTilted, a delay of two seconds begins. During this time, the material falls from the container into the container to be loaded. In the next step, the tilting container is returned to its starting position S4ContainerLoadingPos by the action M4TiltBack.

In the output step S2, the loaded container is carried away on the belt (M1Belt := 1) until the transition condition after the macro call S2ContainerInPos returns False again in the main GRAFCET chart. This means that another empty container has reached the filling position. In the main GRAFCET chart, the belt motor is switched off (M1Belt:= 0) with step 5 and then the transition to the initial step takes place.

Fig. 3.109 Diagram of the technology for the tilting container with weigh station

Definition of the operands:

Symbol Description
S1Start "Start" button, value = True if pressed
S2ContainerInPos "Container in position" sensor, value = True if pressed
S3ContainerLoaded "Tilting container is filled" sensor, value = False when filled
S4ContainerLoadingPos "Tilting container is in loading position" sensor, value = True if pressed
S5ContainerIsTilted "Tilting container is in tilted position" sensor, value = True if pressed
M1Belt Belt motor
M2Mill Mill motor
M3TiltContainer Motor for tilting the container
M4TiltBack Motor for moving the tilting container into the loading position

The main GRAFCET is shown in the left-hand figure below. The main functionality is realised in the expansion of macro step M2.

Note: After the macro step has carried the container away, the belt with M1Belt:= 0 is switched off again in step 5. Since the transition to the initial step should take place immediately afterwards and this is not possible without a transition, the transition following step 5 is assigned the constant transition condition '1'. Since this is always True, the step enabling condition is always present.

The complete solution including the expansion of macro step M2:

Fig. 3.110 Solution to the application with macro step M2

Testing the application

represents the situation after macro step M2 has been performed in full. Initial step S2 is active and remains so until the transition condition S2ContainerInPos = False is fulfilled in the main GRAFCET.

Fig. 3.111 Tilting container with weigh station in test mode

Summary

  • A macro step is prefixed with M and the step label. Example: M2.
  • The expansion (or implementation) of the macro step always starts with an input step, which is prefixed with E and the step label for the macro step (e.g. E3).
  • The expansion (or implementation) of the macro step always ends with an output step, which is prefixed with S and the step label for the macro step (e.g. S3).
  • In Grafcet-Studio, the expansion of the macro step needs to be assigned a border which has the label for the macro step (e.g. M3).
  • Implementation of the macro step must be completed in full, i.e., be at the initial step. Only then is the transition released after the macro step and the transition can be initiated on the transition condition being fulfilled. If the transition takes place, the output step is deactivated.
  • Macro steps are used to structure a GRAFCET. This stylistic device can significantly improve the readability of the GRAFCET, particularly in the case of larger sequences.
  • Actions can be attached to the macro step. So long as a step is active within the realisation of the macro step, the step prefixed with M also remains active.
  • As with a 'normal' step, the step variable for a macro step is formed from the prefix X and the label for the macro step (e.g. XM5).

Training

PLC-Lab Filename Grafcet-Studio Filename
PumpeEinschalten.plclab PumpeEinschalten.grafcet

Recurrent step chains can also be realised as macro steps. The process of switching on a pump usually requires a valve to be opened. The pump is to be switched on with a delay vs. the opening of the valve. This function is to be programmed as a macro step. In the sequence, a total of two pumps with one valve each should be switched on via one macro step (M2, M3), respectively. After pressing S1, valve Y1 opens and 2 seconds later M1 is switched on. Along with M1, Y2 is also opened and yet again two seconds later the pump M2. The "Stop" button switches both pumps off and closes the two valves with S2Stop = False.

Fig. 3.112 Diagram of the technology for training: Switching on pumps via macro steps

Definition of the operands:

Symbol Description
S1Start "Start" button, returns True when pressed
S2Stop "Stop" button, returns False when pressed
Y1 Valve Y1, True = Valve opens
M1Pump Pump M1
M2Pump Pump M2
Y2 Valve Y2, True = Valve opens

Solution

Fig. 3.113 Switching on macro step applications for the pump

Step 1:

Initial step 1 remains active until transition condition S1Start = True is fulfilled and therefore the transition to the macro step M2 is being carried out.

Step M2:

Macro step M2 becomes active and therefore so does its input step E2, which opens the valve Y1 with a storing action on activation. Pump 1 is switched on after two seconds with a storing action on activation of step S2. Now the transition after the macro step M2 can initiate the transition to macro step M3.

Step M3:

If macro step M3 is active, its input step E3 is also activated. The storing action on activation at step E3 causes the assignation of Y2:= 1 which results in valve Y2 opening. Pump 2 is also switched on after a delay of two seconds. This process is initiated from step S3 here. Macro step M3 has therefore been processed in full and the transition to step 3 would occur as soon as the transition condition after M3 is fulfilled. This would be the case if the "Stop" button is pressed and the operand S2Stop therefore has the value False.

The pumps and the valves are switched off by storing actions as soon as step 3 is activated. If both valves are switched off, the transition condition is fulfilled and the transition to initial step 1 follows. You could also have stated the complete condition at the transition.

Fig. 3.114 Macro step application for switching on pump. View in Run mode

Review Questions

  • Which prefix does a macro step have?
  • What prefix should you use to identify the input step within the expansion of a macro step?
  • What prefix should you use to identify the output step within the expansion of a macro step?
  • What preconditions must be given so the transition after the macro step can initiate the transition?
  • What advantage do macro steps offer?