You are on page 1of 2

KronoTech RSLogix 5000 Ladder Logic Structured Text HMI Search Contact us

Ladder Logic Swap Function


KronoTech
PLC
Ladder Logic
Basic
Counters
Timer
Arithmetic
Comparison
Functions
ABS
CLR
CPT
SCL
SCP
SQR
SWP
XPY
Trig Functions
RSLogix 5000
Structured Text
HMI
Instruments
SWP - Swap
Swaps the low and high bytes of a specified number of words in a bit,
integer, ASCII, or string file.
Example
Swap (aBcDeF) = BaDcFe
Ladder Logic Solution
Before /After Swap
Example
The next 3 words of N7:140
Ladder Logic Solution
Before/After Swap

Note
Values of N7:140 are in Hexadecimal
Example
Let's say N7:145 contain ABCD (hexadecimal) and we want to separate high
byte and the low byte of this word and put them into 2 separate word.
Ladder Logic Solution
Execute an AND instruction on the N7: 145 with FF (Hex) this will result in
getting the low byte from N7: 145, and put it in N7: 146.
Now that we got the low byte, we have to swap the word N7:145.
Quick Links
PLC Languages
Ladder Logic
Function Block
Structure Text
SFC
Mnemonic
Ladder Logic
Basic
Counters
Timer
Arithmetic
Comparison
Functions
Trig Functions
Instruments
Switches
HMI
Advantages
Alarms
Trends
Other
Bottle Application
Page 1 of 2 Ladder Logic Square Root Function
11-Nov-13 http://www.kronotech.com/LadderLogic/function/ex-swp.htm
Now we can do another AND instruction with FF (Hex) to get the low byte of the
swapped word, and put it in words N7: 147
N7:145 = ABCD (Hex)
N7:146 = AB
N7:147 = CD
Note
The source can only be an indexed word address.
Bit length (1-128)
Integer length (1-128)
String length (1-41) (one string only)
ASCII length (1-128)
Page 2 of 2 Ladder Logic Square Root Function
11-Nov-13 http://www.kronotech.com/LadderLogic/function/ex-swp.htm

You might also like