Professional Documents
Culture Documents
Compiling a project
Compiling overview.......................................................................................................................1
How to compile a project.................................................................................................................2
Make.....................................................................................................................................2
Patch POU...........................................................................................................................3
Rules and restrictions for patching POUs..............................................................4
Memory reserve settings of a POU........................................................................7
Graphical illustration of the memory reserve usage while patching.......................8
Developing a project using 'Patch POU'................................................................9
IEC defined FUs and FBs which can be patched without previous usage...........12
Patching a POU when working with several resources.......................................18
Compile Worksheet............................................................................................................18
Rebuild Project...................................................................................................................19
Using the message window to display and correct errors and warnings............................20
Compiling overview
When the project is edited you have to compile the project. Compiling means translating and
transforming the contents of the worksheets in special code which can be executed by your PLC.
The compilation process is performed in several steps:
It starts with compiling (i.e. syntax checking) the different worksheets.
During the second main step the compiled worksheets are linked together and an
intermediate IEC code is generated.
The last step generates the PLC code which has to be downloaded to the PLC.
While compiling, the message window displays the compilation process. Any detected errors and
warnings (e.g. syntax errors, memory or file problems) and additional information are also
displayed in the appropriate message window sheet. You can use the message window to access
the suspected code body worksheet by double clicking on the error message.
After compiling you have to download the program to the PLC. The download procedure differs
according to the PLC type you are working with.
The details for downloading are described in the topic Downloading in the PLC specific help
(please refer to the related topics list below).
Make
Using the menu item/icon 'Make' or the shortcut <F9> the changed worksheets are compiled, linked
and the changed PLC code is going to be generated. After successful execution the changed
project is ready for downloading to the PLC.
Changed worksheets are marked with an asterisk in the project tree.
'Make' is the standard mode for compiling which should be used normally when you have finished
editing.
Patch POU
When starting the compilation the message window appears automatically if closed. This window
displays the compilation process, any detected errors and warnings and additional information to
the process.
How to 'make' a project:
Click on the icon 'Make' in the toolbar.
The compilation process is displayed in the sheet 'Build' of the message window. Errors
and warnings detected during compilation are logged in the corresponding sheets of the
message window.
How to stop the compiler:
Click on the icon 'Stop Compile' in the toolbar to abort the compilation process.
Patch POU
To patch a POU means that changes you have made in a project are compiled, the related code is
generated and downloaded automatically to the PLC in one step. During the patch process the PLC
keeps on running, i.e. the code execution on the PLC is not aborted while compiling and
downloading the changes.
The menu item 'Patch POU' is only available if you switch the corresponding worksheet in offline
mode by clicking on the icon 'Debug on/off' in the toolbar.
The 'Patch POU' command can be used for two main purposes:
Correcting detected errors.
If you have detected a programming error using the online mode and you have switched
to offline mode to remove the programming error you can use 'Patch POU' to compile
these changes.
Further developing a base project.
In some cases it may be more comfortable to develop a project using the command 'Patch
POU' instead of 'Make'. After 'Making' a base project the first time and downloading it, you
can replenish this raw program (i.e. program shell) by editing the various POU code
worksheets and patch them to the PLC program which is already running on the target.
In both cases
the changes are downloaded automatically while the PLC keeps on running so that you
can view them immediately after switching into online mode.
some rules and restrictions have to be observed.
The memory reserve settings must be defined accordingly. Please refer to the topic
Memory reserve settings and to the graphical illustration.
When working with several resources, each instance (i.e. resource) has to be patched separately
by switching the corresponding online worksheet offline, changing the code and executing the
'Patch POU' command.
Rules and restrictions for patching POUs
The following rules must be kept in all programming languages (i.e. graphical and textual
languages) in order to use the command Patch POU. (Please note also the restrictions listed at
the end of this topic.)
Use 'Make' after 'Patch POU' failed
If one of the following rules or restrictions is violated, the patch process is aborted and an
appropriate error message is displayed in the message window.
Once the 'Patch POU' command is aborted, you have to use 'Make' and initiate a new download
manually before you can patch the next time.
Rules concerning size and usage of the memory reserve:
Size of the memory reserve area:
The memory reserve for a POU you want to patch must be set accordingly. This means,
that you have to assign a data reserve area in the PLC memory which is large enough to
store the user data (not the executable code!) of the variables/instances to be patched.
For detailed information please refer to the topic Memory reserve settings of a POU and to
the graphical illustration.
Resource and POU settings concerning the usage of the reserve:
In the 'Use reserve' dialog area of the resource settings dialog either the radio button 'All
POUs' or 'Marked POUs' must be marked. In the second case ('Marked POUs') the
corresponding checkbox 'User reserve' in the POU properties dialog must be activated in
order to patch the POU.
Using the option 'Marked POUs' makes sense, if there is only less free memory left on the
PLC. In this case you can use this frre memory as reserve only for patching these POUs
which are actually changed.
For dialog descriptions please refer to the related topics list below.
Rules concerning variables:
A POU can be patched after
inserting new local variables.
inserting new global variables.
deleting variables which are not used in *.csv.
Rules concerning functions:
A POU can be patched after
inserting an IEC defined function.
In difference to user defined functions and library functions (see next two items) nearly all
IEC functions can be patched even if they are not already used in the resource. (See also
note below).
inserting an user defined function if the function has already been called in any POU of the
resource before (see also note below).
inserting a function contained in a firmware library or in an user library if the function has
already been called in any POU of the resource before (see also note below).
Patching a POU is only possible for the listed cases if the project has already been compiled using
'Make', was downloaded to the target and the system was already in Online Mode.
Rules concerning function blocks:
Concerning function blocks it must be distinguished between IEC function blocks and user defined
function blocks.
A POU can be patched after
inserting an user defined function block if an instance of this user FB has already been
declared before in the variables worksheet of any POU in the resource. It is sufficient if the
instance declaration is entered in the variables worksheet, i.e. the instance has not to be
used (called) in a code body (see also note below).
inserting an IEC defined function block. In difference to user defined FBs and library FBs,
it is not necessary that the IEC FB instance is declared in the resource before. (See also
note below).
When inserting a function block contained in a firmware library or user library the same
rules apply as for user defined FBs (see also note below).
Patching a POU is only possible for the listed cases if the project has already been compiled using
'Make', was downloaded to the target and the system was already in Online Mode.
Additionally the following rules apply to the different programming languages:
Language
each
IL
ST
FBD
LD
SFC
The default memory reserve size of each new inserted POU is defined in the dialog 'Data
Area'.
Using the POU properties dialog the default reserve size can be changed for each POU
individually. The equation for calculating the required size is shown at the bottom of the figure.
In our example the reserve is changed for the program POU 'Main', because two function
3
4
large enough. If there is not enough reserve available, an error message appears and the
patch process is aborted. If it is required to increase the reserve size, the command 'Patch
POU' can not be applied. In this case you have to use 'Make' to compile the changed
project.
If all conditions are met you can replenish the raw program (i.e. program shell) by editing the
various POU code worksheets and patch them to the PLC program which is already running on the
target.
This is possible due to the following features:
IEC FB instances can be patched with no restrictions.
An user FB call can be patched if an instance of this user FB is already declared in the
variables worksheet of any POU. It is not necessary to use the instance in a code
worksheet before patching.
How to insert and patch a new User FB into a project
Insert a new FB POU in the project tree but don't edit the code worksheet.
In the variables worksheet of the FB POU declare each input and output parameter, which
will be used within this FB later.
Note: Be careful when planning and declaring these FB parameters, because they can
not be changed later using the 'Patch POU' command.
(Instead of patching you then have to 'Make' the project, stop the PLC and start a new
download.)
Close both, the FB variables worksheet and the empty code worksheet.
Open the variables worksheet of the POU, in which the new FB should be called later.
Insert a new line and declare the new FB instance.
It is recommended to use the instance name 'FB_name_1', because this is the instance
name, which the system will later propose when inserting the FB instance in the code
worksheet.
Choose the type 'FB_name' and close the variables worksheet.
Make sure that the memory reserve of the POU which calls the user FB is large enough to
patch the FB user data.
For displaying the current reserve size you can use the tab 'POUs' of the dialog
'Resource: Resource_name' (for detailed information about this dialog please refer to the
related topics list below).
For changing the reserve size open the tab 'Type' of the POU properties dialog (context
menu item 'Properties..' of the POU icon in the project tree).
Note: When changing the reserve size afterwards, patching is no longer possible. After
each modification of the reserve size 'Make' must be used.
Compile the project using 'Make'. A warning appears in the message window for each new
declared input/output variable and FB instance declaration, because these
variables/instances are not yet used in the project.
10
11
IEC defined FUs and FBs which can be patched without previous usage
This topic provides a list of all IEC defined functions and function blocks, which can be patched,
even if they are not already used in the current project / resource.
Further information can be found in the sections Rules concerning functions and Rules
concerning FBs of the topic Rules and restrictions for patching POUs.
Type conversion functions
Function
REAL_TO_STRING
SINT_TO_STRING
INT_TO_STRING
DINT_TO_STRING
TIME_TO_STRING
BYTE_TO_STRING
WORD_TO_STRING
DWORD_TO_STRING
BOOL_TO_BYTE
BOOL_TO_WORD
BOOL_TO_DWORD
BOOL_TO_SINT
BOOL_TO_INT
BOOL_TO_DINT
BOOL_TO_USINT
BOOL_TO_UINT
BOOL_TO_UDINT
BOOL_TO_REAL
BYTE_TO_BOOL
BYTE_TO_WORD
BYTE_TO_DWORD
BYTE_TO_SINT
BYTE_TO_INT
BYTE_TO_DINT
BYTE_TO_USINT
BYTE_TO_UINT
BYTE_TO_UDINT
BYTE_TO_REAL
DINT_TO_BOOL
DINT_TO_BYTE
DINT_TO_WORD
DINT_TO_DWORD
DINT_TO_SINT
Short description
Converts REAL to STRING
Converts SINT to STRING
Converts INT to STRING
Converts DINT to STRING
Converts TIME to STRING
Converts BYTE to STRING
Converts WORD to STRING
Converts DWORD to STRING
Converts BOOL to BYTE
Converts BOOL to WORD
Converts BOOL to DWORD
Converts BOOL to SINT
Converts BOOL to INT
Converts BOOL to DINT
Converts BOOL to USINT
Converts BOOL to UINT
Converts BOOL to UDINT
Converts BOOL to REAL
Converts BYTE to BOOL
Converts BYTE to WORD
Converts BYTE to DWORD
Converts BYTE to SINT
Converts BYTE to INT
Converts BYTE to DINT
Converts BYTE to USINT
Converts BYTE to UINT
Converts BYTE to UDINT
Converts BYTE to REAL
Converts DINT to BOOL
Converts DINT to BYTE
Converts DINT to WORD
Converts DINT to DWORD
Converts DINT to SINT
12
DINT_TO_INT
DINT_TO_REAL
DINT_TO_TIME
DINT_TO_USINT
DINT_TO_UINT
DINT_TO_UDINT
DWORD_TO_BOOL
DWORD_TO_BYTE
DWORD_TO_WORD
DWORD_TO_SINT
DWORD_TO_INT
DWORD_TO_DINT
DWORD_TO_REAL
DWORD_TO_USINT
DWORD_TO_UINT
DWORD_TO_UDINT
INT_TO_BOOL
INT_TO_BYTE
INT_TO_WORD
INT_TO_DWORD
INT_TO_SINT
INT_TO_DINT
INT_TO_REAL
INT_TO_USINT
INT_TO_UINT
INT_TO_UDINT
REAL_TO_BOOL
REAL_TO_BYTE
REAL_TO_WORD
REAL_TO_DWORD
REAL_TO_SINT
REAL_TO_INT
REAL_TO_DINT
REAL_TO_USINT
REAL_TO_UINT
REAL_TO_UDINT
SINT_TO_BOOL
SINT_TO_BYTE
SINT_TO_WORD
SINT_TO_DWORD
SINT_TO_INT
SINT_TO_DINT
SINT_TO_REAL
13
SINT_TO_USINT
SINT_TO_UINT
SINT_TO_UDINT
STRING_TO_BYTE
STRING_TO_DINT
STRING_TO_DWORD
STRING_TO_INT
STRING_TO_REAL
STRING_TO_SINT
STRING_TO_TIME
STRING_TO_UDINT
STRING_TO_UINT
STRING_TO_USINT
STRING_TO_WORD
TIME_TO_DINT
TRUNC_INT
TRUNC_DINT
TRUNC_SINT
USINT_TO_BOOL
UINT_TO_BOOL
UDINT_TO_BOOL
USINT_TO_BYTE
UINT_TO_BYTE
UDINT_TO_BYTE
USINT_TO_DINT
UINT_TO_DINT
UDINT_TO_DINT
USINT_TO_DWORD
UINT_TO_DWORD
UDINT_TO_DWORD
USINT_TO_INT
UINT_TO_INT
UDINT_TO_INT
USINT_TO_REAL
UINT_TO_REAL
UDINT_TO_REAL
USINT_TO_SINT
UINT_TO_SINT
UDINT_TO_SINT
UDINT_TO_UINT
UDINT_TO_USINT
UINT_TO_UDINT
UINT_TO_USINT
14
USINT_TO_UDINT
UDINT_TO_STRING
UINT_TO_STRING
USINT_TO_STRING
USINT_TO_UINT
USINT_TO_WORD
UINT_TO_WORD
UDINT_TO_WORD
WORD_TO_BOOL
WORD_TO_BYTE
WORD_TO_DWORD
WORD_TO_SINT
WORD_TO_INT
WORD_TO_DINT
WORD_TO_REAL
WORD_TO_USINT
WORD_TO_UINT
WORD_TO_UDINT
Numerical functions
Function
ABS
ACOS
ASIN
ATAN
COS
EXP
LN
LOG
SIN
SQRT
TAN
Short description
Truncation of Sign
Arc Cosine
Arc Sine
Arc Tangent
Cosine
Exponent
Natural Logarithm
Base10 Logarithm
Sine
Square Root
Tangent
Arithmetic functions
Function
ADD
ADD_T_T
DIV
DIV_T_AI
DIV_T_AN
Short description
Addition
TIMEAddition
Division
TIME by ANY_INT Division
TIME by ANY_NUM Division
15
DIV_T_R
EXPT
MOD
MOVE
MUL
MUL_T_AN
MUL_T_AI
MUL_T_R
NEG
SUB
SUB_T_T
Short description
Bitwise AND
Complement
Bitwise OR
Bitwise Exclusive OR
Bitstring functions
Function
ROL
ROR
SHL
SHR
Short description
Rotate Left
Rotate Right
Shift Left
Shift Right
Selection functions
Function
LIMIT
MAX
MIN
SEL
Short description
Limit Selection
Maximum
Minimum
Binary Selection
Comparison functions
Function
EQ
GE
Short description
Equal: =
Greater Than Equal: >=
16
GT
LE
LT
NE
Short description
Concatenates Strings
Deletes Substring
Equal STRING: =
Searches Substring
Greater Than Equal STRING: >=
Greater Than STRING: >
Inserts Characters
Less Than Equal STRING: <=
Leftmost Characters
String Length
Limit Selection of Strings
Less Than STRING: <
Maximum of Strings
Middle Characters
Minimum of Strings
Not Equal STRING: <>
Replaces Characters
Rightmost Characters
Binary Selection of Strings
Short description
Set Dominant
Reset Dominant
Short description
Falling Edge Detection
Rising Edge Detection
17
Function block
CTU
CTD
CTUD
Short description
Counter Up
Counter Down
Counter Up/Down
Short description
Pulse
Timer OnDelay
Timer OffDelay
Compile Worksheet
Using the menu item/icon 'Compile Worksheet' can be used to compile a worksheet in order to
check the syntax during editing. Choosing this command means that syntax errors are going to be
detected by the compiler.
18
Rebuild Project
Rebuild Project
'Rebuild Project' is used to compile the whole project for the first time or if an announced user
library has been changed.
Using 'Rebuild Project' all worksheets are going to be compiled and linked. Detected errors and
warnings are displayed in the message window. After the syntax checking the IEC code as well as
the PLC specific code is generated automatically. The project is then ready for downloading to the
PLC.
The command 'Rebuild Project' should only be used if 'Make' generates compiling errors or you
have unzipped your project without the frontend code.
How to rebuild a project:
Select the menu item 'Rebuild Project' in the submenu 'Build'.
The compilation process is started and its progress is displayed in the message window.
Detected errors and warnings can be displayed in the corresponding sheets of the
message window.
How to stop the compiler:
Click on the icon 'Stop Compile' in the toolbar to abort the compilation process.
19
Using the message window to display and correct errors and warnings
Using the message window to display and correct errors and warnings
In most cases while compiling for a first time the different compilers detect programming errors,
such as a variable name which has been used twice or typing errors.
In those cases a message appears in the sheet 'Build' of the message window, announcing the
number of detected errors and warnings.
If the message window is closed when starting the compilation it appears automatically.
To display the detected errors, click on the tab 'Errors' in the message window. The error list is then
shown in the message window.
In order to display the list of warnings, just click on the tab 'Warnings'.
In most cases double clicking on a displayed error/warning will open directly the worksheet where
the programming error/the reason for the warning is occurred. The corresponding line or the object
is marked. You can also mark the error and press <F1> to get the corresponding help topic with
information about the cause of the error and what steps have to be done now.
Having corrected the first error you can press <CTRL> + <F12> to go directly to the worksheet with
the next error.
20