The text of a manual · part 11 of 18
Simatic S5 to RSLogix 5000 Application Conversion Guide: Chapter 3: Software Conversions Instructions, pages 80 to 88
Pages 80 to 88 of 140, from Simatic S5 to RSLogix 5000 Application Conversion Guide
The original document is the PDF (3.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Siemens 6ES5-431-8MA11, Siemens 6ES5-451-8MA11 and Siemens 6ES5-452-8MR11
Page 80
Chapter 3
Software Conversions Instructions
Subtraction S5 uses three subtraction instructions depending on whether the operands are 16 bit integers, 32 bit integers or floating point numbers. RSLogix 5000 software has one subtraction instruction that can be used regardless of the format of the operands. Note that you can mix data types, but loss of accuracy and rounding error might occur and the instruction takes more time to execute. You can check the S:V bit to see whether the rest was truncated. Function
S5
RSLogix 5000
Operand 1 (16 bit)
FW18 data_word1
Operand 1 (32 bit)
FD30
Operand 1 (floating point)
FD42
Operand 2 (16 bit)
FW20
Operand 2 (32 bit)
FD34
Operand 2 (floating point)
FD46
Output (16 bit)
FW22
Output (32 bit)
FD38
Operand (floating point)
FD50
S5 Statement List 16 bit fixed point numbers data_word2 data_word3
RSLogix 5000 Structured Text
L FW18 L FW20 -F T FW22 S5 Statement List 32 bit fixed point numbers L FD30 L FD34 -D T FD38 data_word3 := data_word1 data_word2;
S5 Statement List 32 bit floating point numbers L FD42 L FD46 -G T FD50
80
Publication LOGIX-AP010B-EN-P - May 2010
Page 81
Software Conversions Instructions
Chapter 3
SIMATIC S5 - Ladder 16 bit fixed point numbers
RSLogix 5000 - Ladder
Publication LOGIX-AP010B-EN-P - May 2010
81
Page 82
Chapter 3
Software Conversions Instructions
Multiplication S5 uses two multiplication instructions depending on whether the operands are 16 bit integers or floating point numbers. RSLogix 5000 software has one multiplication instruction that can be used regardless of the format of the operands. Note that you can mix data types, but loss of accuracy and rounding error might occur and the instruction takes more time to execute. You can check the S:V bit to see whether the rest was truncated. Function
S5
RSLogix 5000
Operand 1 (16 bit)
FW18 data_word1
Operand 1 (floating point)
FD30
Operand 2 (16 bit)
FW20
Operand 2 (floating point)
FD34
Output (16 bit)
FW22
Operand (floating point)
FD48
S5 Statement List 16 bit fixed point numbers L L xF L L xF T
FW18 FW20 data_word2 data_word3 RSLogix 5000 Structured Text data_word3 := data_word1 + data_word2;
FW18 FW20 FW22 S5 Statement List 32 bit fixed point numbers
This function can not be performed in S5. Numbers must first be converted to floating point format. S5 Statement List 32 bit floating point numbers L L xG T
82 data_word3 := data_word1 * data_word2;
FD30 FD34 FD38
Publication LOGIX-AP010B-EN-P - May 2010
Page 83
Software Conversions Instructions
Chapter 3
SIMATIC S5 - Ladder 16 bit fixed point numbers
RSLogix 5000 - Ladder
Publication LOGIX-AP010B-EN-P - May 2010
83
Page 84
Chapter 3
Software Conversions Instructions
Division S5 uses two division instructions depending on whether the operands are 16 bit integers or floating point numbers. RSLogix 5000 software has one division instruction that can be used regardless of the format of the operands. Note that you can mix data types, but loss of accuracy and rounding error might occur and the instruction takes more time to execute. You can check the S:V bit to see whether the rest was truncated. Function
S5
RSLogix 5000
Operand 1 (16 bit)
FW18 data_word1
Operand 1 (floating point)
FD30
Operand 2 (16 bit)
FW20
Operand 2 (floating point)
FD34
Output (16 bit)
FW22
Operand (floating point)
FD38
S5 Statement List 16 bit fixed point numbers L L :F L T data_word2 data_word3 RSLogix 5000 Structured Text
FW18 FW20 FW18 FW22 S5 Statement List 32 bit fixed point numbers
This function can not be performed in S5. Numbers must first be converted to floating point format.
data_word3 := data_word1 / data_word2;
S5 Statement List 32 bit floating point numbers L L :G T
84
FD30 FD34 FD38
Publication LOGIX-AP010B-EN-P - May 2010
Page 85
Software Conversions Instructions
Chapter 3
SIMATIC S5 - Ladder 16 bit fixed point numbers
RSLogix 5000 - Ladder
Publication LOGIX-AP010B-EN-P - May 2010
85
Page 86
Chapter 3
Software Conversions Instructions
Block Call Operations
S5 refers to independent portions of code as blocks while RSLogix 5000 software refers to these as subroutines. S5 uses two block call instructions, Jump Conditional (JC) and Jump Unconditional (JU), to call other program blocks. RSLogix 5000 software has a similar JumpToSubroutine (JSR) instruction to implement this operation. Comparison or Boolean logic can be placed in front on the RSLogix 5000 JSR instructional to achieve the functionality of the S5 conditional block call function. At the end of each block S5 has the following instructions: • Block End (BE) -Identifying the end of a function/program block • Block End Conditional (BEC) - Causes the current program/function block to end if the proceeding conditions are true. • Block End Unconditional (BEU) - Causes the current program block to end unconditionally RSLogix 5000 software has a similar ReturnFromSubroutine (RET) instruction to implement this operation. Comparison or Boolean logic can be placed in front on the RSLogix 5000 RET instructional to achieve the functionality of the S5 Block End Conditional and Block End Unconditional function. It is not necessary to specify the end of an RSLogix 5000 program subroutine. If it is not specified then the code assumes that the routine ends when the last instruction in the routine has been executed.
86
Publication LOGIX-AP010B-EN-P - May 2010
Page 87
Software Conversions Instructions
Chapter 3
Block Calls Function
S5
Operand 1
F10.3 data_bit1
Operand 2
PB10
Alarms
S5 Statement List 16 bit fixed point numbers In the following example the code will jump to PB 10 if F10.3 =1. A F10.3 JC PB10
RSLogix
RSLogix 5000 Structured Text In the following example the code will jump to the Alarms routine if data_bit1 =1. if data_bit1 then JSR (Alarms); end_if;
In the following example the code will jump to PB 10 regardless of the state of F10.3 A F10.3 JU PB10
In the following example the code will jump to the Alarms routine unconditionally. JSR (Alarms);
SIMATIC S5 - Ladder Conditional Jump
Unconditional Jump
RSLogix 5000 - Ladder Conditional Jump
Unconditional Jump
Publication LOGIX-AP010B-EN-P - May 2010
87
Page 88
Chapter 3
Software Conversions Instructions
RSLogix 5000 software allows for the option of parameters to be passed to subroutines and also allows for the subroutine to return a result to the calling routine by using the RET function. The following RSLogix 5000 example illustrates how the JSR/SBR instructions can be used to pass parameters to the called subroutine and return a parameter from the subroutine to the main routine. In this example, the data_word1 value is passed to the parameter flow1 while the data_word2 value is passed to the parameter flow2. The called subroutine, Calculation, evaluates the parameter fault and this value is passed to the parameter out_bit1 in the calling routine. Instead of using a subroutine, another option is to use the Add-On Instruction functions as discussed in Chapter 2. RSLogix 5000 Parameter Passing
88
Publication LOGIX-AP010B-EN-P - May 2010