12.07.2015 Views

Logix5000 Controllers General Instructions - SLAC Confluence

Logix5000 Controllers General Instructions - SLAC Confluence

Logix5000 Controllers General Instructions - SLAC Confluence

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Move/Logical <strong>Instructions</strong> (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) 303Example 1:The three SWPB instructions each reorder the bytes of DINT_1according to a different order mode. The display style is ASCII, andeach character represents one byte. Each instruction places the bytes,in the new order, in a different Destination.Relay LadderStructured TextSWPB(DINT_1,REVERSE,DINT_1_reverse);SWPB(DINT_1,WORD,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 theRSLogix 5000\Projects\Samples folder, Swap_Bytes_in_Array.ACD file.1. Initialize the tags. The SIZE instruction finds the number ofelements in array and stores that value in array_length. Asubsequent instruction uses this value to determine when theroutine 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 numberthat is indicated by the value of index. For example, when indexequals 0, the SWPB instruction acts on array[0].• The ADD instruction increments index. The next time theinstruction executes, the SWPB instruction acts on the nextelement in array.3. Determine when the SWPB instruction has acted on all theelements 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 theelements in the array.Publication 1756-RM003I-EN-P - January 2007

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!