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

The text of a manual · part 4 of 7

Encoder/Counter Modules User Manual (Cat. Nos. 1771-IJ and 1771-IK), pages 31 to 40

Pages 31 to 40 of 68

The original document is the PDF (388 KB). 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 1771-IK

Page 31

Chapter

5

Single Transfer Programming General

Single transfer programming is one method for coordinating and controlling bidirectional module/processor communication. This method can only be used when the module is in a local I/O chassis. Single transfer may be the recommended method even where block transfer capability is available. Specifically, single transfer programming is suggested whenever preset #1 words and #2 are not used. When one or both preset words are used, block transfer methods may be more efficient, depending on the application. The material for single transfer programming is organized as follows:

• Section titled Output Words - Single Transfer describes the configuration of output words when using single transfer methods. • Section titled Single Transfer Description gives a general description of how single transfer programming works and an example for applications where no preset words are required. • Section titled Multiplexing shows how multiple words of output data are multiplexed in single transfer. • Section titled Example Program - Single Transfer gives a sample program for single transfer programming.

Output Words Ć Single Transfer

The output control and preset words have a unique configuration when single transfer programming has been selected. Initially, the program must set the bits in these words to the desired combination for the application. Then, using single transfer techniques, the program sends these output words to the module.

Output Control Word Figure 5.1 shows the configuration of the output control word for single transfer. By setting bits in this word, you set up the initial mode of module operation and change it as required during operation.

Publication 1771-UM006B-EN-P - June 2002

Page 32

5–2

Single Transfer Programming

Figure 5.1 Control Word Ć Single Transfer Function Control Bits BIT 11

BIT 10

0

0

Count

0

1

Reset, and hold the accumulated count at 000.

1

0

Return the accumulated count to 000 and begin counting immediately.

1

1

Invalid, module executes previously programmed function.

FUNCTION

Bits 10-11, Function Control (see table) Bits 14-17, Word Select Bits. Must have this pattern for control word.

Bit 06, Not Used

AC > PR #1 AC = PR #1 AC < PR #1

Bits 00-02, Comparison Parameters for Preset #1 1 = True 0 = False

AC < PR #2 AC = PR #2 AC > PR #2

Bits 03-05, Comparison Parameters for Preset #2 1 = True 0 = False

17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 1 0 0 0 (Counter Mode Only ) Bit 13, Up/Down 1 = Count Up 0 = Count Down Bit 12, Enable Outputs 1 = Enable 0 = Disable

Bit 07, Home Latch Enable 1 = Enable 0 = Disable

15952

Bits 14-17 of this word are word select bits. These bits must have the setting shown in Figure 5.1 to identify the word as the output control word. Bit 13 of this word is the up/down bit. This bit is significant only when the module is used in the counter mode. The state of this bit controls module function as follows: 1 -The module increments its accumulated count with each count received on channel A. 0 -The module decrements its accumulated count with each received on channel A.

Publication 1771-UM006B-EN-P - June 2002

Page 33

Single Transfer Programming

5–3

Note that if a device is wired to channel B for external control of count direction, the up/down bit must be set to 1. Count direction can be externally controlled by using a transistor switch, as described in chapters 2 and 3. Bit 12 is the enable outputs bit. The state of this bit controls module outputs as follows: 1 -Outputs enabled. This means that the output module can be energized based on logical operations performed by the module. 0 -Outputs disabled. This means that the outputs of the module cannot be energized. With bit 12 set to 1, the module can energize its output terminals based on a comparison of its accumulated count and preset values set by the program. Bits 10 and 11 are termed function control bits. These bits control module function in both encoder and counter modes. They permit the counting operation of the module to be enabled or reset by the program. The table in Figure 5.1 shows the bit settings for each function. Bit 07 is the home latch enable bit. The module resets the count to zero only when all three of these conditions are true:

• Home latch enable bit (bit 07) is set to 1. • Marker input is high. • Home limit switch is closed (limit switch LED is on). The count remains at zero until one or more of these conditions go false. Then module operation follows the function control bits described in Figure 5.1. The module indicates it has reset its count to zero by setting the home bit (bit 17 in the input status word). It resets this bit when the home latch enable bit (bit 07) is reset. (Refer to Figure 4.2, Input Status Word). The system can bring the machine back to a repeatable starting position, and the module count can be reset to zero by toggling either the marker input or home limit switch rather than changing bits 11 and 10 in the control word as long as the three conditions are met. Carry and borrow bits are not affected by resetting the module count. The home limit switch LED turns on whenever the home limit switch is closed.

Publication 1771-UM006B-EN-P - June 2002

Page 34

5–4

Single Transfer Programming

Bits 00-05 are significant only when one or both preset words are used. These bits establish the comparison conditions for module control of its outputs. As Figure 5.1 shows, bits 00-02 set up parameters for comparison with preset word #1; bits 03-05 set up parameters for comparison with preset word #2. The module then controls its output #1 or #2 based on the true or false comparison of its accumulated count with these presets. When any of these bits is set to 1, the indicated condition is considered by the module as true (that is, as a true condition enabling the module to turn on its output). As Figure 5.1 shows, one bit is used for each comparison parameter: less than, equal to, or greater than. Note that more than one of these bits can be set to 1 for each preset, allowing such combinations as less than or equal to, greater than or equal to, or not equal to.

Preset Words In single transfer communication, the preset words have the format of Figure 5.2 and Figure 5.3. In this format, bits 00-13 store the preset value. When BCD operation has been selected, these bits may represent a 3-digit value from 000-999. When 12-bit binary operation has been selected, the value may range from 0 to 1111 1111 1111 binary (4095 decimal). A module switch selection, made during installation, selects either BCD or binary mode. Figure 5.2 Preset Word #1 Ć Single Transfer Bits 14-17 = Word Select Bits, must have this pattern for Preset Word #1..

Preset Value

17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 0 1 0 0 Most Significant BCD Digit (0-9) 1

Middle BCD Digit (0-9) 1

Least Significant BCD Digit (0-9) 1

1 or, 12-bit binary value 1

Module switch selection determines whether bits 00-13 are of binalry or BCD format 15953

Publication 1771-UM006B-EN-P - June 2002

Page 35

Single Transfer Programming

5–5

Figure 5.3 Preset Word #2 Ć Single Transfer Bits 14-17 = Word Select Bits, must have this pattern for Preset Word #2..

Preset Value

17 16 15 14 13 12 11 10 07 06 05 04 03 02 01 00 0 0 1 0 Most Significant BCD Digit (0-9) 1

Middle BCD Digit (0-9) 1 or, 12-bit binary value

Least Significant BCD Digit (0-9) 1

1

1

Module switch selection determines whether bits 00-13 are of binalry or BCD format 15954

Note that bits 14-17 have a unique coding to identify each preset word. Note: If BCD operation has been switch selected, only BCD digits should be entered in the data table word output to the module. If non-BCD digits are entered in a preset value, the module sets its default preset value to 000 for the word.

Single Transfer Description

Single transfer programming uses the I/O scan for bidirectional module/processor communication. The I/O scan is an automatic function of the processor during which it performs two operations: it writes output image table data to I/O modules and reads I/O module data into the input image table. The write cycle of the I/O scan must be manipulated by the program for communication with the encoder/counter module. By this manipulation, up to three 16-bit words are sent to the module by using one output image table word. The read cycle of the I/O scan is also used, but is not manipulated by the program since only a single input status word is read from the module.

Publication 1771-UM006B-EN-P - June 2002

Page 36

5–6

Single Transfer Programming

Bidirectional single transfer programming, then, requires both an input image table and an output image table word. The addresses of these image table words depend on the location of the I/O module in the chassis. For example, for modules in I/O rack 1, module group 6, the corresponding output image table word is 016; the input image table word is 116. Because the encoder/counter module occupies one module group in the I/O chassis, the processor writes one complete 16-bit output image table word to the module and reads one complete 16-bit input image table word from the module during each I/O scan. Figure 5.4 shows the relationship of module slot placement to image table location in memory. Figure 5.4 Example Module Position/Image Table Word Relationship Output Word Written to Module (16 bits) Encoder/Counter Module in I/O Rack No. 1 Module Group No. 6

1

2

3

4

5

6

7

8

Output Word 016 Input Word 116

Input Word Read from Module (16 Bits)

15955

The input image table word, the means for reading data from the module, is updated automatically by the processor each I/O scan. To examine the input status word from the module, the program only needs to examine the word stored at the input image table location corresponding to the placement of the encoder/counter module. The output image table word, the means for writing data to the module, is sent by the processor automatically, each I/O scan. In applications where only the output control word is used, this word can be stored directly in the output image table location corresponding to the placement of the encoder/count module. Section titled Example Rungs-No Preset Words Used shows the type of program needed for this type of communication.

Publication 1771-UM006B-EN-P - June 2002

Page 37

Single Transfer Programming

5–7

However, in some applications, one or both preset words must be used. Here, the complication involving the output image table word is readily apparent: it must be used to serve multiple purposes; not only will this word send the output control word, it is also needed to send one or both preset words to the module. The use of this word for more than one purpose is termed multiplexing. For multiplexing, program manipulation and coordination of the control of the output image table word are necessary. Sections titled Multiplexing and Example Program - Single Transfer describe multiplexing for single transfer communication.

Example Rungs Ć No Preset Words Used Figure 5.5 illustrates a typical example in which bidirectional single transfer occurs, assuming that no preset words are used. This example assumes the module placement shown in Figure 5.4. There is no manipulation of intermediate storage words when only the output control word is needed. Thus, in this instance, the bits in the output image table word corresponding to the module are set directly to determine the module’s control function. In the example of Figure 5.5, rungs 1-3 turn on various bits in the output word. Bits are 0 unless set to 1 by a program instruction. Here, it is assumed that no other use is made of word 016. Figure 5.5 Example Rungs Ć Single Transfer (No Preset Words used) Rung No.

01617

1 01613

2

01607

3

4

116

Set Control Word Bits as Desired, Word 016 Used Directly For Control Word Function

020

G

<

000

056 Examine Input Status Word Accumulated Value

15956

Publication 1771-UM006B-EN-P - June 2002

Page 38

5–8

Single Transfer Programming

Rung 4 shows the input status word examined in the user program. Note that this word is automatically in the input image table when single transfer is selected. The processor automatically updates this word each I/O scan. In summary, when you are not using preset words, you need only set bits of the output image table word which corresponds to the module. This word then serves as the output control word. However, when using one or both preset words, the output image table word is used for multiple purposes and intermediate storage word addresses must be used for output control and preset word storage. The following sections outline methods for multiplexing the output words in such applications.

Multiplexing

The processor writes a single word - the output image table word - to the encoder/counter module each I/O scan. Multiplexing is a programming technique by which the processor can share this single output image table word and use it to send multiple words to the module, one word at a time. Multiplexing, therefore, is useful when one or more preset words are needed. Multiplexing requires an orderly sequencing of events in the program. The program must coordinate control of the output image table word such Multiplexing requires an orderly sequencing of events in the program. The program must coordinate control of the output image table work such that it sends the intended output word, whether control or preset, to the module. In this publication, a scan counter is used for this coordination. While it is not the only method of control for multiplexing, the scan counter is a direct and easily understood method and can be used with any PLC or PLC-2 family processor. To understand the scan counter’s function, consider how information must be transferred to the module. In one program scan, the processor stores the word that is to be sent to the module in the output image table word for the module. During the very next I/O scan, the processor automatically outputs the image table word to the module. Table 5.A lists a sequence of operation for single transfer in a typical application, showing what must happen at each value of the scan counter. This example assumes that both preset words are used. If only one of the preset words is needed, only counts 1 and 2 of the scan counter are necessary.

Publication 1771-UM006B-EN-P - June 2002

Page 39

Single Transfer Programming

5–9

Table 5.A Scan Count Sequencing At Count: [1]

Program Executes Command To:

1

PUT Control word into output word

Sends output word

2

PUT Preset word #1 into output word

Sends output word

3

PUT Preset word #2 into output word

Sends output word

I/O Scan:

[1]This count is the scan counter Accumulated value for PLC-2, PLC-2/15, PLC-2/20, and

Mini-PLC-2 Controllers. For the PLC Controller, these values would be doubled: 2, 4, and 6 respectively.

The scan counter must indicate that both an I/O scan and a program scan have occurred. For PLC-2, PLC-2/15, PLC-2/20 and PLC-2/30 Processors and the Mini-Processor Module, the I/O scan and program scan, because they are sequential, are synchronous: one program scan occurs for each I/O scan. This means the scan counter can simply be incremented each program scan. Section titled Scan Counter - PLC-2 Family Processors describes a suitable scan counter for these processors. With the PLC processor, however, the I/O scan and program scan are asynchronous; this means that the scan counter must be programmed to increment based on the longer of the two scans. Section titled Scan Counter - PLC Processor describes a suitable scan counter for these processors. With the sample program following, note that the scan counter is programmed to run continuously; it resets itself when the accumulated value equals the preset value, and begins to count again. This arrangement is normally preferred because it allows subsequent programmed changes in bits of the output control word to be sent to the module as soon as possible after the change is made.

Scan Counter Ć PLC-2 Family Processors Figure 5.6 shows an example scan counter that can be used for any PLC-2 family processor. This type of scan counter increments with each program scan. Because the I/O and program scans of these processors are synchronous, each increment of this scan counter indicates that both an I/O scan and a program scan have occurred.

Publication 1771-UM006B-EN-P - June 2002

Page 40

5–10

Single Transfer Programming

Figure 5.6 Scan Counter Ć PLC-2 Processors 030 CTU PR003 AC000 030 CTU PR003 AC000

Branch End Instruction

15957

The output instruction of both rungs in Figure 5.6 is an up-counter (CTU) instruction. The first rung, since it is unconditional, is always true. The second rung, since a branch end instruction by itself is always false, sets the conditions for the counter as false. Because an up-counter (CTU) increments for each false to true transition, CTU 030 registers one count each time the program scan occurs.

Scan Counter Ć PLC Processor Figure 5.7 shows an example scan counter that can be used for a PLC processor. Because the I/O and program scans of this processor are asynchronous, this scan counter differs in form and operation from the scan counter for PLC-2 processors. Figure 5.7 Scan Counter Ć PLC Processor Rung No. 1

11111 /

200 CTU PR006 AC000

2

20017

11111 L 20017

3

/ 15958

Publication 1771-UM006B-EN-P - June 2002