The text of a manual · part 12 of 18
Simatic S5 to RSLogix 5000 Application Conversion Guide: Chapter 3: Software Conversions Instructions, pages 89 to 96
Pages 89 to 96 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 89
Software Conversions Instructions
Shift Operations
Chapter 3
S5 has the following instructions that will shift the contents of the accumulator to the left/right by the number of bits specified by the parameter. Instruction
Description
SLW
Shifts the contents of the accumulator ACCU1-L (word) to the left by the number of bits specified in the parameter.
SLD
Shifts the contents of the accumulator ACCU1 (double word) to the left by the number of bits specified in the parameter.
SRW
Shifts the contents of the accumulator ACCU1-L (word) to the right by the number of bits specified in the parameter.
SRD
Shifts the contents of the accumulator ACCU1 (double word) to the right by the number of bits specified in the parameter.
This functionality can be achieved in RSLogix 5000 Ladder by using the Bit Field Distribute (BFD) function. In this function the following parameters are specified. Parameter
Description
Source the register that contains the bit to be shifted
Source bit the number of the lowest bit to be moved
Destination the register that contains the bits after the shift is performed
Length number of bits to be shifted
The BFD function provides greater flexibility than the S5 shift instructions because with the S5 shift instructions it is only possible to shift the entire contents of a register while with the RSLogix 5000 BFD function it is possible to shift any specified subset of bits.
Publication LOGIX-AP010B-EN-P - May 2010
89
Page 90
Chapter 3
Software Conversions Instructions
This BFD function is not available in RSLogix 5000 Structured Text but a similar function called Bit Field Distribute with Target (BFDT) can produce the same results. Shift Left The following example shows how S5 shifts the bits in FW18 by 4 places to the left and how the equivalent functionality is achieved by using RSLogix software. S5 FW18 FW20
RSLogix 5000 data_word1 data_word2
S5 Statement List 16 bit fixed point numbers
RSLogix 5000 Structured Text BTDT_01.Source := data_word1;
L FW18 SLW 4 T FW20
BTDT_01.SourceBit := 0; BTDT_01.Length := 32; BTDT_01.DestBit := 4; BTDT_01.Target := data_word2; BTDT(BTDT_01); data_word3 := BTDT_01.Dest; SIMATIC S5 - Ladder
RSLogix 5000 - Ladder
90
Publication LOGIX-AP010B-EN-P - May 2010
Page 91
Software Conversions Instructions
Conversion Operations
Chapter 3
Siemens S5 uses the two’s complement system in which negative numbers are represented by the two’s complement of the absolute value. The following instructions change the sign of a 16 bit word and a 32 bit double word integer. S5 Instruction
Description
CSW
Form two’s complement of ACCU 1-L (bits 0 to 15)
CSD
Form two’s complement of ACCU1 (bits 0 to 31)
The RSLogix 5000 Negate (Neg) instruction performs the same function. Negate The following example shows how S5 changes the number sign in DW64 and places the result in DW78, and how the equivalent functionality is achieved by using RSLogix software. S5 DW64 DW78
RSLogix 5000 data_word1 data_word2
S5 Statement List 16 bit fixed point numbers L DW64 CSW T DW78
RSLogix 5000 Structured Text data_word2 := -data_word1; SIMATIC S5 - Ladder
RSLogix 5000 - Ladder
Publication LOGIX-AP010B-EN-P - May 2010
91
Page 92
Chapter 3
Software Conversions Instructions
S5 Instruction
Description
DEF
Convert a 16 bit fixed point from BCD into binary
DED
Convert a 16 bit fixed point from BCD into binary
The RSLogix 5000 Convert to Integer (FRD) instruction performs the same function. BCD to Integer S5 DW64 DW78
RSLogix 5000 data_word1 data_word2
S5 Statement List 16 bit fixed point numbers L DW64 DEF T DW78
RSLogix 5000 Structured Text
This instruction is not available in structured text format. SIMATIC S5 - Ladder
RSLogix 5000 - Ladder
92
Publication LOGIX-AP010B-EN-P - May 2010
Page 93
Software Conversions Instructions
S5 Instruction
Chapter 3
Description
DUF
Convert a 16 bit fixed point from binary to BCD
DUD
Convert a 32 bit fixed point from binary to BCD
The RSLogix 5000 Convert to BCD (TOD) instruction performs the same function. BCD to Integer S5 DW64 DW78
RSLogix 5000 data_word1 data_word2
S5 Statement List 16 bit fixed point numbers L DW64 DUF T DW78
RSLogix 5000 Structured Text
This instruction is not available in structured text format. SIMATIC S5 - Ladder
RSLogix 5000 - Ladder
Publication LOGIX-AP010B-EN-P - May 2010
93
Page 94
Chapter 3
Software Conversions Instructions
FDG- Convert a 16 bit fixed point from binary to BCD In RSLogix 5000 software, this functionality is achieved by defining a register as having floating point format and moving an integer into it by using the MOVE (MOV) instruction in Ladder or the := instruction in Structured Text. Integer to Floating Point S5 DD64 DD78
RSLogix 5000 data_word1 data_floatingpoint
S5 Statement List 16 bit fixed point numbers
RSLogix 5000 Structured Text
L DD64 FDG T DD78
SIMATIC S5 - Ladder
RSLogix 5000 - Ladder
94
Publication LOGIX-AP010B-EN-P - May 2010
Page 95
Software Conversions Instructions
Chapter 3
DUD - Convert a floating point number to a 32 bit fixed point format. In RSLogix 5000 software, this functionality is achieved by defining a tag with Data Type = REAL (as shown below) and transferring it to a tag with Data Type = DINT by using the MOVE (MOV) instruction in ladder or the := instruction in Structured Text.
Floating Point to Integer S5 DD64 DD78
RSLogix 5000 data_floatingpoint data_word2
S5 Statement List 16 bit fixed point numbers
RSLogix 5000 Structured Text
L DD64 DUD T DD78
SIMATIC S5 - Ladder
RSLogix 5000 - Ladder
Publication LOGIX-AP010B-EN-P - May 2010
95
Page 96
Chapter 3
Software Conversions Instructions
Notes:
96
Publication LOGIX-AP010B-EN-P - May 2010