This is the fifth episode of the Pilz PSS4000 introduction. In the last issue, we showed you how to build a simple ESTOP safety application using the Function Block FS_EmergencyStop of the Safety Pilz PSS4000.
Pilz PSS4000 has a Resource global variables feature, which is similar to the GVL feature in Codesys and TwinCAT, but with a few features. However, it is a bit different. In this article, we will introduce Resource global variables, VAR_TEMP, and Instruction list.
Let’s start!
Thanks!
The CPUs used in this article are equipment loaned to us by PILZ JAPAN.
PILZ
PILZ supports factory automation sites as a total solution supplier with solutions in safety and automation technology, guaranteeing the safety not only of people, but also of machines and the environment, and how safely machines and equipment can be operated. Pilz has 42 subsidiaries and branch offices worldwide and is active in various fields such as packaging, automotive industry, robotic applications, as well as wind power and railroad technology.
Office:
ピルツジャパン株式会社
〒222-0033
横浜市港北区新横浜3-17-5
いちご新横浜ビル 4階
HP
Reterence Link
Resource global Variables
Resource global variables are global variables that can be shared and read among POUs; if you want to use them within POUs, you must define the same variables as Resource global variables in VAR_EXTERNAL for each POUS.
But IEC61131 programming also said that Global variables should be used as little as possible, especially PI variables (so called Mapped to modules, etc.), if defined in Resource global variables, it will be troublesome when the program changes.
The following Attributes can be defined in VAR_GLOBAL.
- CONSTANT
- RETAIN PERSISTENT
- PERSISTENT RETAIN
VAR_EXTERNAL
Once a variable is declared in the VAR_GLOBAL area of Resource global variables, you can use the variable in Resource global variables by defining the same variable in the VAR_EXTERNAL area in the POU.
Note that variables defined in VAR_EXTERNAL and VAR_GLOBAL must also match 100% of the variable names and data types (including array length).
VAR_TEMP
Variables defined in the VAR_TEMP area return to their initial values each time they are called by POU, FB, FC, etc. Variables in VAR_TEMP should be given initial values before they are used in a program.
Instruction list?
For this article, we used Instruction list, a text-based programming language included in IEC61131, which is similar to assembly language.
Define Resource Global Variables
To define Resource global variables, click on Resource global variables from Tools.
The IDE has been activated.
Several variables are defined in this way.
Edit in POU2
Open POU_2 where the FS_EmergencyStop Function Block controlling the previous emergency stop is located.
Define the same variables as Resource global variables in VAR_EXTERNAL.
The next step is to transfer the output status of the FS_EmergencyStop Function Block directly to the variable VAR_EXTERNAL. This means that variables such as Device_0_ESTOP_Enable… can be used in another programme!
New POU
Create a new programme at IEC61131 programming>New>POU.
Enter the name of the programme, set Programming Language to IL (Instruction List) and Type to Program.
The Instruction list Editor is now displayed.
Define External
Define variables with the same variable names as Resource Global Variables in VAR_EXTERNAL in the declaration area of the programme.
The actual concept is shown in the diagram below: how many variables are defined from Resource Global Variables and then in POU_2 (FS_EmergencyStop) a variable with the same name as Resource Global Variables from the VAR_EXTERNAL area. Defined.
So the group of variables in VAR_EXTERNAL, updated in POU_3, is updated as Resource Global Variables.
Finally, POU_2 also defines a variable with the same name as Resource Global Variables from the VAR_EXTERNAL area and Resource Global Variables also reads the current value.
![](http://soup01.com/wp-content/uploads/2024/05/image-7.png)
It is an error if you put a variable in the VAR_EXTERNAL area that is not defined in Resource Global Variables.
Error messages are also generated if the relevant variable is not defined in Resource Global Variables.
Define VAR
The next step is to define the variables required in the VAR area.
Define VAR_TEMP
Create a TempCounter variable in VAR_TEMP to compare the differences between VAR and VAR_TEMP.
Program
This is a programme; IL doesn’t use it much at the moment, but once you get used to it, it’s quite useful.
The program here is just a simple AND circuit. For example, the current value of Device_0_ESTOP_Enable is transferred directly to ESTOP_Enable.
This one looks a bit more complicated, but in fact, if Device_0_Reset_Button_LAMP_OUTPUT is True, then jump to the LABEL_LAMPOUT Label location, set the RESET_BUTTON_LAMP_OUTPUT variable to True and NEXT1 Jump to the Label location.
If Device_0_Reset_Button_LAMP_OUTPUT is false, the RESET_Button_LAMP_OUTPUT variable is reset to false and Jump to the NEXT1 Label position.
This program adds VARCounter and TempCounter by Plus INT#1.
Trips1 Auto Refill
you can use Ctrl+Space to autocomplete.
Trips2 Show Line Numbers
Right-click on the IDE and use Show Line Numbers to display the number of lines.
This is how it operates.
Resource Assignment
The next step is to adjust the Resource so that POU_3 runs on the CPU.
Click Hardware Configuration>Your Device>ST Resource.
POU_3 is not even a safety programme, so I was wondering if it could be added to ST Resource as it is…
Error is shown. This means that the Resource global variables are also used for FS programs, so ST must be called into the FS resource as well.
Add POU_3 to FS_Resource.
Done!
Build
Build>Build All to compile Project.
Download
Download the project to the CPU using Target>Direct Project Download.
Start Download to begin with.
Check the I accept a change to the FS device projects options and click the Confirm Button.
Just a while..
Done!
Result
Check the results in the Dynamic programme Display.
It seems to be fine.
As mentioned at the beginning, the VARCounter is stored with the result of the operation in the POU, so the VARCounter gives are added all the time. Conversely, TempCounter in VAR_TEMP has an unknown value.