1772-6.5.2, 3 - file search instruction, File search instruction – Rockwell Automation 1772-AF3,D17726.5.2 User Manual AUX FUNCT PROM User Manual

Page 9

Advertising
background image

Chapter

3

3Ć1

File Search Instruction

The auxiliary file search instruction is an output instruction. It searches a file
looking for a match of data contained in any file word with data of a specified
match word. The instruction starts at the beginning of the file and searches
from lowest to highest word address (lowest to highest position number) and
from lowest to highest bit number. When the instruction finds a match, it
simultaneously stores the position of the file word (3-digit BCD number) and
sets the true bit. The true bit signals that the instruction found a match. Your
program logic can detect the setting of the true bit and perform the application
logic associated with the match.

Your program must cycle the instruction’s enable bit through a false-to-true
transition for each match of file data, until the instruction sets its done bit. The
instruction sets a done bit after it finds the last match in the file or if it finds no
match in the file. In the next false-to-true transition of the enable bit,
instruction clears the stored position number, and resets the instruction’s control
bits. If your program has cycled the enable bit, the instruction will immediately
begin the search again from the beginning of the file.

Generally, a minimum of two scans is required to detect each match. In the first
scan the instruction is enabled, it finds the match, stores the position number of
the matched word, and sets the true bit. In the next scan, the instruction resets
the true bit, and your program can reset the enable bit. Later in this chapter we
will describe a program that detects a match on each scan.

You enter the file search instruction into program logic by pressing the key
sequence [SHIFT][EAF] 21 on the industrial terminal keyboard (series B or
later), or [SHIFT][SCT] 21 on the keyboard of an earlier model that does not
contain the [EAF] key. The instruction will appear as shown in Figure 3.1.

Enter the data address and result address into the instruction block as octal
(BCD) numbers from 0020 thru 3577. Typically, choose addresses from middle
to upper sections of the data table. A data address of 0400 and result address of
0406 are typical (Figure 3.2).

General

Programming the File Search

Instruction

Advertising