How do you install block protection for the S7-GRAPH blocks?
STEP 7 provides the KNOW_HOW_PROTECT function for protecting the program code. If you open a block with the KNOW_HOW_PROTECT property, then you can only view the block interface (IN, OUT and IN/OUT parameters) and the block comment. The program code, the temporary and static tags and the network comments are not displayed.
Unlike the STEP 7 blocks (creation language: STL, LAD and FBD) two sources must be generated for installing the KNOW_HOW_PROTECT for each S7-GRAPH block:
- one source (type: GRAPH source) that is generated from the S7-GRAPH editor and
- one source (type: STL source) that is generated from the LAD/STL/FBD editor.
You can only install the block protection in an STL source. After saving the S7-GRAPH FB in the LAD/STL/FBD editor, the block created in S7-GRAPH receives a new language code and can then no longer be edited in the original S7-GRAPH language (not even after removing the block protection). However, if the block created in S7-GRAPH is to be edited again in the original S7-GRAPH language, you must recompile the GRAPH source. This GRAPH source then serves to save the S7-GRAPH FB.
- Open the S7-GRAPH FB and create a GRAPH source via "File > Generate Source File...".
- In the dialog that opens you enter an object name, "Source_FB", for example.
- Save with OK and the GRAPH source is generated. Then close the S7-GRAPH FB again.
- In the Windows operating system you open the LAD/STL/FBD editor. This can be found in Windows 7 via "Start > All Programs > Siemens Automation > SIMATIC > STEP 7 > LAD, STL, FBD - Program S7 blocks".
- In the LAD/STL/FBD editor you select your STEP 7 project via "File > Open..." .
- Mark the relevant block folder and then open the block created in S7-GRAPH.
The function block created in S7-GRAPH is opened in the STL language.
Save the block either via the floppy disk symbol or via "File > Save". Now you get a message indicating that this block has been created in a different programming language and that upon saving it will no longer be possible to edit the block in the language in which it was originally created (GRAPH). Click the "Yes" button. The function block created in S7-GRAPH now receives the STL language code.
In the LAD/STL/FBD editor you generate a source via "File > Generate source...".
In the dialog that opens you enter an object name,"Protect_FB", for example.
The "Source < Name > Generate" dialog opens. Here in the left window you mark the block for which the STL source is to be generated and use the arrow key to move this block into the "Blocks Selected" window on the right.
Confirm with OK and the STL source is generated. Close the LAD/STL/FBD editor again.
Now you have two sources in your "Sources" folder:
the STL source (Protect_FB),
for the KOW_HOW_PROTECT of the block with the STL language code.
the GRAPH source (Source_FB),
for deactivating the KNOW_HOW_PROTECT and returning to the original S7-GRAPH language.
Open the STL source "Protect_FB" and insert a line with the command "KNOW_HOW_PROTECT" in the declaration section of the block under "TITLE".
Save and compile the STL source via "File > Save" and "File > Compile". The S7-GRAPH FB is now block protected.
Now, if you want to remove the block protection for the S7-GRAPH FB, proceed as follows.
- In the block folder of your STEP 7 project you delete the block-protected function block.
- In the Sources folder you open the GRAPH source "Source-FB". The source is opened in the GRAPH language in which it was created.
- Compile the S7-GRAPH source via "File > Compile".
- The "Select Instance DB" dialog opens. You can accept the instance DB from the presetting or enter a new instance DB. Then confirm with "OK". After compilation of the source, the function block is once again available in the GRAPH language and you can edit it again with S7-GRAPH.
The screens in this FAQ response were created with STEP 7 V5.5 and STEP 7 V5.3.