Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 37 of 55

Hand-Held Terminal (Catalog Number 1747-PT1) User Manual: 23 - Bit Shift, FIFO, and LIFO Instructions

Pages 313 to 322 of 486, from Hand-Held Terminal (Catalog Number 1747-PT1) User Manual

The original document is the PDF (1.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 Allen-Bradley 1747-PT1

Page 313

Chapter

A–B

23

Bit Shift, FIFO, and LIFO Instructions This chapter covers instructions for use with fixed, SLC 5/01, and SLC 5/02 processors:

• Bit Shift Left (BSL) • Bit Shift Right (BSR) These are output instructions that load data into a bit array one bit at a time. The data is shifted through the array, then unloaded one bit at a time. Bit shift instructions are useful in conveyor applications and product evaluation (pass/fail) applications. Instructions for use with SLC 5/02 processors only: • FIFO Load and Unload (FFL, FFU) • LIFO Load and Unload (LFL, LFU) FIFO instructions provide a method of loading words into a file and unloading them in the same order as they were loaded. First word in is the first word out. LIFO instructions provide a method of loading words into a file and unloading them in the opposite order as they were loaded. Last word in is the first word out. FIFO and LIFO instruction applications include assembly/transfer lines, inventory control, and system diagnostics. All application examples shown are in the HHT zoom display.

Bit Shift, FIFO, and LIFO Instructions Overview

The following general information applies to bit shift, FIFO, and LIFO instructions.

Effect on Index Register in SLC 5/02 Processors All of the instructions in this chapter alter the contents of the index register, S:24. Details appear with the specific instructions.

23–1

Page 314

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

Bit Shift Left (BSL), Bit Shift Right (BSR)

Bit Shift Left, Bit Shift Right

HHT Ladder Display:

HHT Zoom Display: (online monitor mode)

BSL, BSR

(BSL)

Output Instructions

(BSR)

ZOOM on BSL –(BSL)– 2.3.0.0.1 NAME: BIT SHIFT LEFT FILE: #B3:1 LENGTH: 50 CONTROL: R6:0 BIT ADDR: I1:1.0/0 EN DN ER UL 0 0 0 0 EDT_DAT F1

F2

F3

F4

F5

ZOOM on BSR –(BSR)– 2.3.0.0.1 NAME: BIT SHIFT RIGHT FILE: #B3:1 LENGTH: 50 CONTROL: R6:0 BIT ADDR: I1:1.0/0 EN DN ER UL 0 0 0 0 EDT_DAT F1

F2

F3

F4

Ladder Diagrams and APS Displays: BSL BIT SHIFT LEFT File #B3:1 Control R6:0 Bit Address I:1.0/0 Length 50

(EN) (DN)

BSR BIT SHIFT RIGHT File #B3:1 Control R6:0 Bit Address I:1.0/0 Length 50

23–2

(EN) (DN)

F5

Page 315

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

Entering Parameters • File – The address of the bit array you want to manipulate. You must use the file indicator # in the bit array address. The address must start on an element boundary (for example, B3:0/0, not B3:0/4). • Control – The instruction’s address and control (R data file) element that stores the status byte of the instruction, the length of the array (in number of bits), and the bit pointer (currently not used). Note: The control address cannot be used for any other instruction. The control element is shown below. 15

13

11 10

EN

DN

ER UL

00 Not used

Length of bit array (number of bits) Bit Pointer (currently not used)

Status bits of the control element: EN (bit 15) – The enable bit is set on a false-to-true transition of the rung and indicates the instruction is enabled. DN (bit 13) – The done bit, when set, indicates the bit array has shifted one position. ER (bit 11) – The error bit, when set, indicates the instruction detected an error such as entering a negative number for the length or position. Avoid using the unload bit when this bit is set. UL (bit 10) – The unload bit stores the status of the bit exited from the array each time the instruction is enabled. When the register shifts and input conditions go false, the enable, done, and error bits are reset.

• Bit Address – This is the address of the source bit that the instruction inserts in the first bit location of the BSL array, or the last bit location of the BSR array. • Length (size of bit array) (word 1) – This is the number of bits in the bit array, up to 2048 bits. A length value of 0 causes the input bit to be transferred to the UL bit. A length value that points past the end of the programmed file causes a runtime major error to occur. If you alter a length value with your ladder program, make certain that the altered value is valid. Do not use any of the bits beyond the last bit in the array up to the next word boundary. They are invalid.

Effect on Index Register in SLC 5/02 Processors The shift operation clears the index register S:24 to zero.

23–3

Page 316

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

Operation – Bit Shift Left When the rung goes from false–to–true, the enable bit (EN bit 15) is set and the data block is shifted to the left (to a higher bit number) one bit position. The specified bit at the Bit Address (source) is shifted into the first bit position. The last bit is shifted out of the array and stored in the unload bit (UL bit 10) in the status byte of the control element. The shift is completed in one scan. For wraparound operation, set the Bit Address equal to the address of the last bit of the array or to the UL bit, whichever applies. The figure below illustrates how the Bit Shift Left instruction functions. Bit Address (source) I:22/12

BSL BIT SHIFT LEFT File #B3:1 Control R6:53 Bit Address I:22/12 Length 58

(EN) (DN)

Data block is shifted one bit at a time from bit 16 to bit 73. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 DO NOT USE 73 72 71 70 69 68 67 66 65 64

58 bit array #B3:1

Unload Bit R6:53/10

Operation – Bit Shift Right When the rung goes from false–to–true, the enable bit (EN bit 15) is set and the data block is shifted to the right (to a lower bit number) one bit position. The specified bit at the Bit Address (source) is shifted into the last bit position. The first bit is shifted out of the array and stored in the unload bit (UL bit 10) in the status byte of the control element. The shift is completed in one scan. For wraparound operation, set the Bit Address equal to the address of the first bit of the array or to the UL bit, whichever applies. The figure below illustrates how the Bit Shift Right instruction functions. Unload Bit R6:54/10

BSR BIT SHIFT RIGHT File #B3:2 Control R6:54 Bit Address I:23/06 Length 38

(EN) (DN) 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 DO NOT USE 69 68 67 66 65 64

Data block is shifted one bit at a time from bit 69 to bit 32. Bit Address (source) I:23/06

23–4

38 bit array #B3:2

Page 317

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

If you wish to shift more than one bit per scan, you must create a loop using jump (JMP) and label (LBL) instructions.

FIFO Load (FFL), FIFO Unload (FFU)

SLC 5/02 Processors Only FIFO Load, FIFO Unload

HHT Ladder Display:

HHT Zoom Display: (online monitor mode)

FFL, FFU (FFL)

Output Instructions

(FFU)

ZOOM on FFL –(FFL)– 2.3.0.0.2 NAME: FIFO LOAD SOURCE: N7:10 LENGTH: 34 FIFO: #N7:12 POSITION:0 CONTROL: R6:0 EN EU DN EM 0 0 0 0 EDT_DAT F1

F2

F3

F4

F5

ZOOM on FFU –(FFU)– 2.4.0.0.2 NAME: FIFO UNLOAD FIFO: #N7:12 LENGTH: 34 DEST: N7:11 POSITION:0 CONTROL: R6:0 EN EU DN EM 0 0 0 0 EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: FFL FIFO LOAD Source FIFO Control Length Position

(EN) N7:10 #N7:12 R6:0 34 0

(DN) (EM)

FFU FIFO UNLOAD FIFO Dest Control Length Position

(EU) #N7:12 N7:11 R6:0 34 0

(DN) (EM)

FFL and FFU instructions are used in pairs. The FFL instruction loads words into a user-created file called a FIFO stack. The FFU instruction unloads words from the FIFO stack, in the same order as they were entered. FIFO and LIFO instruction applications include assembly/transfer lines, inventory control, and system diagnostics. 23–5

Page 318

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

Entering Parameters Enter the following parameters when programming these instructions: • Source – This word address stores the value to be entered next into the FIFO stack. The FFL instruction places this value into the next available element in the FIFO stack. SOURCE can be a word address or a program constant (–32768 to 32767). For I/O addresses, the HHT requires you to specify the slot and word number, for example I:3.0. • Destination (Dest) – This word address stores the value that exits from the FIFO stack. The FFU instruction unloads this value from the stack and places it in this word address. For I/O addresses, the HHT requires you to specify the slot and word number, for example O:3.0. • FIFO – This is the address of the stack. It must be an indexed word address in the input, output, status, bit, or integer file. The same address is programmed for the FFL and FFU instructions. • Control – This is a control file (R data file) address. The status bits, the stack length, and the position value are stored in this element. The same address is programmed for the FFL and FFU instructions. Do not use the control file address for any other instruction. The 3-word control element: 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 EN EU DN EM Length Position

Status Bits • EN (bit 15) – FFL instruction enable bit. The bit is set on a false-to-true • • • • •

23–6 transition of the FFL rung and is reset on a true-to-false transition. EU (bit 14) – FFU instruction enable bit. The bit is set on a false-to-true transition of the FFU rung and is reset on a true-to-false transition. DN (bit 13) – Done bit. It is set by the FFL instruction to indicate the stack is full. This inhibits loading the stack. EM (bit 12) – Empty bit. It is set by the FFU instruction to indicate the stack is empty. Length (word 1) – This is the length of the stack, the maximum number of elements in the stack, up to a maximum of 128 words. The same number is programmed for the FFL and FFU instructions. Position (word 2) – The next available location where the instruction loads data into the stack. This value changes after each load or unload operation. The same number is used for the FFL and FFU instructions.

Page 319

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

Operation Instruction parameters have been programmed in the FFL – FFU instruction pair shown below. FFL FIFO LOAD Source FIFO Control Length Position

(EN) N7:10 #N7:12 R6:0 34 9

(DN)

N7:11

(EM)

FFU FIFO UNLOAD FIFO Dest Control Length Position

(EU) #N7:12 N7:11 R6:0 34 9

FFU instruction unloads data from stack #N7:12 at position 0, N7:12.

(DN) (EM)

Destination

N7:12 N7:13 N7:14

FFL instruction loads data into stack #N7:12 at the next available position, 9 in this case. N7:10

Position 0 1 2 3 4 5 6 7 8 9

34 words are allocated for FIFO stack starting at N7:12, ending at N7:45.

Source FFL–FFU Instruction Pair

N7:45

33

Loading and Unloading of Stack #N7:12

FFL instruction operation – When rung conditions change from false–to–true, the FFL enable bit (EN) is set. This loads the contents of the Source, N7:10, into the stack element indicated by the Position number, 9. The position value then increments. The FFL instruction loads an element at each false–to–true transition of the rung, until the stack is filled (34 elements). The done bit (DN) is then set, which inhibits further loading. FFU instruction operation – When rung conditions change from false–to–true, the FFU enable bit (EU) is set. This unloads the contents of the element at stack position 0 into the Destination, N7:11. All data in the stack is shifted one element toward position zero, and the highest numbered element is zeroed. The position value then decrements. The FFU instruction unloads an element at each false–to–true transition of the rung, until the stack is empty. The empty bit (EM) is then set.

Effects on Index Register S:24 The value present in S:24 is overwritten with the position value when a false–to–true transition of the FFL or FFU rung occurs. For the FFL, the position value determined at instruction entry is placed in S:24. For the FFU, the position value determined at instruction exit is placed in S:24. When the DN bit is set, a false–to–true transition of the FFL rung does not change the position value or the index register value. When the EM bit is set, a false–to–true transition of the FFU rung does not change the position value or the index register value. 23–7

Page 320

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

LIFO Load (LFL), LIFO Unload (LFU)

SLC 5/02 Processors Only LIFO Load, LIFO Unload

HHT Ladder Display:

HHT Zoom Display: (online monitor mode)

(monitor mode)

LFL, LFU (LFL)

Output Instructions

(LFU)

ZOOM on LFL –(LFL)– 2.3.0.0.2 NAME: LIFO LOAD SOURCE: N7:10 LENGTH: 34 LIFO: #N7:12 POSITION:0 CONTROL: R6:0 EN EU DN EM 0 0 0 0 EDT_DAT F1

F2

F3

F4

F5

ZOOM on LFU –(LFU)– 2.4.0.0.2 NAME: LIFO UNLOAD LIFO: #N7:12 LENGTH: 34 DEST: N7:11 POSITION:0 CONTROL: R6:0 EN EU DN EM 0 0 0 0 EDT_DAT F1

F2

F3

F4

F5

Ladder Diagrams and APS Displays: LFL LIFO LOAD Source LIFO Control Length Position

(EN) N7:10 #N7:12 R6:0 34 0

(DN) (EM)

LFU LIFO UNLOAD LIFO Dest Control Length Position

(EU) #N7:12 N7:11 R6:0 34 0

(DN) (EM)

These instructions are the same as the FIFO load and unload instructions except that the last data loaded is the first data to be unloaded. FIFO and LIFO instruction applications include assembly/transfer lines, inventory control, and system diagnostics.

Entering Parameters The instruction parameter information on page 23–6 applies. Substitute instruction mnemonics LIFO for FIFO, LFL for FFL, and LFU for FFU. 23–8

Page 321

Chapter 23 Bit Shift, FIFO, and LIFO Instructions

Operation Instruction parameters have been programmed in the LFL – LFU instruction pair shown below. For purposes of comparison, the same parameters are used here as in the FFL – FFU example on page 23–7. LFL LIFO LOAD Source LIFO Control Length Position

(EN) N7:10 #N7:12 R6:0 34 9

(DN) (EM)

LFU LIFO UNLOAD LIFO Dest Control Length Position

(EU) #N7:12 N7:11 R6:0 34 9

(DN) (EM)

LFU instruction unloads data from stack #N7:12 at position 8. N7:11

Destination

N7:12 N7:13 N7:14

LFL instruction loads data into stack #N7:12 at the next available position, 9 in this case. N7:10

Position 0 1 2 3 4 5 6 7 8 9

34 words are allocated for LIFO stack starting at N7:12, ending at N7:45.

Source

LFL–LFU Instruction Pair

N7:45

33

Loading and Unloading of stack #N7:12

LFL instruction operation – When rung conditions change from false–to–true, the LFL enable bit (EN) is set. This loads the contents of the Source, N7:10, into the stack element indicated by the Position number, 9. The position value then increments. The LFL instruction loads an element at each false–to–true transition of the rung, until the stack is filled (34 elements). The done bit (DN) is then set, which inhibits further loading. LFU instruction operation – When rung conditions change from false–to–true, the LFU enable bit (EU) is set. This unloads data from the last element loaded into the stack (at the position value minus 1), placing it in the Destination, N7:11. The position value then decrements. The LFU instruction unloads one element at each false–to–true transition of the rung, until the stack is empty. The empty bit (EM) is then set.

Effects on Index Register S:24 The value present in S:24 is overwritten with the position value when a false–to-true transition of the LFL or LFU rung occurs. For the LFL, the position value determined at instruction entry is placed in S:24. For the LFU, the position value determined at instruction exit is placed in S:24. When the DN bit is set, a false-to–true transition of the LFL rung does not change the position value or the index register value. When the EM bit is set, a false-to–true transition of the LFU rung does not change the position value or the index register value. 23–9

Page 322

This page is a scan with no text; see it in the PDF.