Specifications
Basic Concepts for Programming an S7-200 CPU
4-15
S7-200 Programmable Controller System Manual
C79000-G7076-C233-01
Selecting Between SIMATIC and IEC 1131-3 Programming Modes
Since IEC 1131-3 is strongly data typed, and SIMATIC is not strongly data typed,
STEP 7-Micro/WIN 32 does not allow you to move programs between the two
different editing modes. You must choose a preferred editing mode.
Overloaded Instructions
Overloaded instructions support a range of data types. Strong data type checking
is still applied since all of the operand data types must match before the instruction
compiles successfully. Table 4-7 shows an example of the IEC overloaded ADD
instruction.
Table 4-7 Example of IEC Overloaded ADD Instruction
Instruction
Allowed Data Types
(Strong Data Type Checking)
Allowed Data Types
(Data Type Checking)
Compiled Instruction
ADD INT WORD, INT ADD_I (Add Integer)
ADD DINT DWORD, DINT ADD_D (Add Double Integer)
ADD REAL REAL ADD_R (Add Real)
When all of the operands have the data type DINT, an Add Double Integer
instruction will be generated by the compiler. A compilation error occurs if data
types are mixed for the overloaded instruction. What is considered illegal depends
on the level of data type checking. The following example will generate a compiler
error under strong data type checking, but will pass compile for simple data type
checking.
ADD IN1 = INT, IN2 = WORD, IN3 = INT
Strong data type checking: compile error
Data type checking: compiles to ADD_I (Add Integer)
Like the relation contact comparison example, the simple data type checking will
not prevent common run-time programming errors from occurring. With simple
data type checking, the compiler will not catch the following common programming
errors: ADD 40000, 1 will be a negative number, not an unsigned 40,001.
Using Direct Addressing in IEC for Overloaded Instructions
IEC 1131-3 programming modes permit you to use directly represented memory
locations as a part of instruction parameter configuration. Both variables and
memory locations can be used within parameters. Remember that directly
represented memory locations do not contain explicit type information. Also, type
information cannot be determined from any of the overloaded IEC instructions,
because these instructions accept varying data types.