Relay Ladder; Structured Text - Allen-Bradley Logix5000 Reference Manual

1756 controllogix, 1768 compactlogix, 1769 compactlogix, 1789 softlogix, 1794 flexlogix, powerflex 700s with drivelogix
Hide thumbs Also See for Logix5000:
Table of Contents

Advertisement

Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT)
Example 1:
The three SWPB instructions each reorder the bytes of DINT_1 according to a different
order mode. The display style is ASCII, and each character represents one byte. Each
instruction places the bytes, in the new order, in a different Destination.

Relay Ladder

Structured Text

SWPB(DINT_1,REVERSE,DINT_1_reverse);
SWPB(DINT_1, W ORD,DINT_1_swap_word);
SWPB(DINT_1,HIGHLOW,DINT_1_swap_high_low);
Example 2:
The following example reverses the bytes in each element of an array. For an
RSLogix 5000 project that contains this example, open the
RSLogix 5000\Projects\Samples folder, Swap_Bytes_in_Array.ACD file.
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
1. Initialize the tags. The SIZE instruction finds the number of elements in
array and stores that value in array_length. A subsequent instruction uses
this value to determine when the routine has acted on all the elements in
the array.
2. Reverse the bytes in one element of array.
· The SWPB instruction reverses the bytes of the element number that is
indicated by the value of index. For example, when index equals 0, the
SWPB instruction acts on array[0].
· The ADD instruction increments index. The next time the instruction
executes, the SWPB instruction acts on the next element in array.
3. Determine when the SWPB instruction has acted on all the elements in
the array.
· If index is less then the number of elements in the array (array_length),
then continue with the next element in the array.
· If index equals array_length, then the SWPB has acted on all the elements
in the array.
Chapter 7
313

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents