Safety is a top priority feature in every manufacturing solution. With industrial devices it is often the case that safety buttons are used to prevent injury or undesired effects on the production. When pushed the button causes the device to stop immediately (usually by interrupting the power supply). It can also trigger an alarm, take preventive measures or create an incident record.
In Process Simulate the behavior of such a button can be easily modeled using a script.
The script is responsible for monitoring the button state and if pressed triggering proper actions. Sounds simple isn't it? Let's take a closer look then.
The use-case that we try to cover is stopping a conveyor in case of an emergency. As we already know driving conveyors is possible with SCL. A slight modification however is needed in order to get the safety button working. In the conveyor's script you need an additional BOOL input for the button state (eStop):
FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_INPUT
eStop : BOOL; // true if the button is pressed
END_VAR
VAR
pos : LREAL;
END_VAR
BEGIN
IF NOT #eStop THEN // button not pressed?
DRIVE_CONVEYOR(POS:=#pos); // move the conveyor to the target position
END_IF;
END_FUNCTION_BLOCK
The script of the button may look like this:
FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_OUTPUT
Out : BOOL; // true if the button is pressed
END_VAR
VAR
LowLimit : REAL := 0; // joint value when released
HighLimit : REAL := 30; // joint value when pressed
Move : MOVE_TO_POSE;
END_VAR
VAR_TEMP
jds : LREAL;
END_VAR
BEGIN
IF SIM_TIME()=0 THEN
// go to "Release" pose at time zero
#Move(DURATION:=0.5,NAME:='Release');
#Out:=FALSE;
END_IF;
IF IS_PICKED(NAME:='cylinder3') THEN // button face picked ?
#jds := JDS('j1'); // get the button's joint value
IF (ABS(#jds - #LowLimit) <= 0.01) THEN
#Move(DURATION:=0.5,NAME:='Stop'); // go to "Stop" pose
#Out:=TRUE; // raise the output
ELSIF (ABS(#jds - #HighLimit) <= 0.01) THEN
#Move(DURATION:=0.5,NAME:='Release'); // go to "Release" pose
#Out:=FALSE; // lower the output
END_IF;
END_IF;
END_FUNCTION_BLOCK
The logic in this code relies on study specific data like:
entity names
predefined poses and joint values
You should make these inputs and define them (default values) on the instance level (not in modeling) if you need to reuse the code for different buttons. You can also make this a scriptlet and call it with proper arguments in your main block.
To operate this button you need to use entity pick level in the graphic viewer. The IS_PICKED function takes the name of the entity and checks if the user has clicked on it with the mouse. If you need to work on the resource level simply skip the argument.
Don't forget to wire the two scripts together with a Boolean signal.
Thank you for your time and see you in the next post!
Comentarii