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

The text of a manual · part 17 of 39

Series 90-30/20/Micro PLC CPU Instruction Set Reference Manual: Chapter 8 - Bit Operation Functions, pages 136 to 143

Pages 136 to 143 of 337, from Series 90-30/20/Micro PLC CPU Instruction Set Reference Manual

The original document is the PDF (4.4 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 GE Fanuc IC692CPU211D / IC692MDR541C, Fanuc IC692CPU211D / IC692MDR541C, GE IC692CPU211D / IC692MDR541C and GE Fanuc IC693CPU311X

Page 136

8 Parameters Parameter

Description enable IN N B1 B2 Q LEN

When enable is logic 1, the shift is performed. IN contains the address of the first word to be shifted. N contains the number of places (bit positions) that the array is to be shifted. B1 contains the bit value (0 or 1) to be shifted into the array. B2 contains the bit value (0 or 1) of the last bit shifted out of the array. Output Q contains the first word of the shifted array. LEN is the number of words (1 – 256) in the array to be shifted.

Valid Memory Types Parameter flow enable IN N B1 B2 Q

•

• †

%I

%Q

%M

%T

%S

%G

%R

• •

• •

• •

• •

•

• •

• •

%AI %AQ const • •

• • none

•

• •

• •

•

•

•

•†

•

•

•

•

Valid reference or place where power may flow through the function. %SA, %SB, or %SC only; %S cannot be used.

Example In the following example, when input %M0001 is on, the SHL makes a copy of the bit string at IN (nicknamed WORD1). Then, in the copy, it shifts all bits to the left by 8 bit positions (specified by the value at N). The bits from bit positions 9-16 are shifted out (discarded), and the bits that were in positions 1-8 now occupy bit positions 9-16. Bit positions 1-8, which were “vacated” when bits 1-8 were shifted, are filled with ones because, for this example, contact %M0002 is closed, making the B1 input equal to logic 1. Finally, the shifted/filled word is written to the address at output Q (nicknamed WORD2). The original WORD1 at IN is not changed. Output B2 equals zero since the last bit shifted out was logic zero (the bit that occupied bit position 9), and coil %M0003 is on because the function worked correctly and therefore produced power flow at its OK output. %M0003

%M0001 SHL_ WORD WORD1

LENGTH +00008 %M0002

IN

B2

OK

OUTBIT

LEN 00001 N

Q

Bit Pos. 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 WORD2

B1

GFK-0467M

Chapter 8 Bit Operation Functions

WORD1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 WORD2 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1

8-9

Page 137

8

ROL and ROR (WORD) The Rotate Left (ROL) function rotates all the bits in a string a specified number of places to the left. When rotation occurs, the specified number of bits is rotated out of the input string to the left and back into the string on the right. The Rotate Right (ROR) function rotates all bits in a string a specified number of places to the right. When rotation occurs, the specified number of bits is rotated out of the input string to the right and back into the string on the left. A string length of 1 to 256 words can be selected for either function. The number of places specified for rotation at input N must be more than zero and less than the number of bits in the string. Otherwise, no movement occurs and no power flow is generated. The rotation result is placed in output string Q. If you want the input string to be rotated, the output parameter Q must use the same memory location as the input parameter IN. The rotate function executes each scan that the enable input is on. _____ | | (enable), | ROL_| - (ok) | | | WORD| | | (word to be rotated), |IN Q| - (output parameter Q) | | | LEN | |00001| | | (number of bits), |N | |_____|

Parameters Parameter enable

8-10

Description When the enable input is on, the rotation is performed.

IN

IN contains the address of the first word to be rotated.

N

N contains the number of places (bit positions) that the array is to be rotated.

ok

The ok output is energized when the rotation function is enabled and the rotation length (at N) is greater than zero but is not greater than the array size.

Q

Output Q contains the first word of the rotated array.

LEN

LEN is the number of words (1 – 256) in the array to be rotated.

Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002

GFK-0467M

Page 138

8

Valid Memory Types Parameter flow

%I

%Q

%M

%T

%S

%G

%R enable

•

IN

•

•

•

•

•

•

•

•

•

N

•

•

•

•

•

•

•

•

•

•

•

•

•

•

•

• ok

• none

• •

Q • †

%AI %AQ const

•†

Valid reference or place where power may flow through the function. %SA, %SB, or %SC only; %S cannot be used.

Example In the following example, whenever enable input %I0001 is on, the ROL makes a copy of the input string at IN. Then, in the copy, it rotates the input bit string 3 bits (specified by the value of input N) and places the result in %R0002. After execution of this function, the input bit string %R0001 is unchanged. However, if you wish to rotate the input string, use the same reference address for IN and Q. | _____ |%I0001 | | | - - | | - - - | ROL_| - | | WORD| | | | | %R0001 - |IN Q| - %R0002 | | | | | LEN | | |00001| | | | | CONST, |N | | +00003 |_____| |

%R0001: MSB 1

1

LSB 1

1

1

0

0

0

0

0

0

0

0

0

0

←

0 ←

%R0002 (after rotation occurs): MSB 1

GFK-0467M

1

LSB 0

0

0

Chapter 8 Bit Operation Functions

0

0

0

0

0

0

0

0

1

1

1

8-11

Page 139

8

BTST (WORD) The Bit Test (BTST) function is used to test a bit within a bit string to determine whether that bit is currently 1 or 0. The result of the test is placed in output Q. Each sweep power is received, the BTST function sets its output Q to the same state as the specified bit. If a register rather than a constant is used to specify the bit number, the same function block can test different bits on successive sweeps. If the value of BIT is outside the range specified by the following formula, then Q is set OFF. Formula: 1 ≤ BIT ≤ (16 * LEN) A string length of 1 to 256 words can be selected. _____ | | (enable), | BIT_| | | |TEST_| | WORD| | | (first word to be tested), |IN Q| - (output parameter Q) | LEN | |00001| | | (bit number of IN), |BIT | |_____|

Parameters Parameter

Description enable

When the function is enabled, the bit test is performed.

IN

IN contains the first word of the data to be operated on.

BIT

BIT contains the bit number of IN that should be tested. Valid range is (1 ≤ BIT ≤ (16 * LEN) ).

Q

Output Q is energized if the bit tested was a 1.

LEN

LEN is the number of words in the string to be tested.

Note When using the Bit Test, Bit Set, Bit Clear or Bit Position function, the bits are numbered 1 through 16, NOT 0 through 15.

8-12

Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002

GFK-0467M

Page 140

8

Valid Memory Types Parameter flow

%I

%Q

%M

%T

%S

%G

%R enable

•

IN

•

•

•

•

•

•

•

•

•

BIT

•

•

•

•

•

•

•

•

Q •

%AI %AQ const none

•

•

•

Valid reference or place where power may flow through the function.

Example In the following example, whenever enable input %M0001 is on, bit 14 in word %R0001 is tested (bit 14 is specified by the value in %R0002). Since bit 14 is zero in the value shown for %R0001 (5C7C), output Q does not turn on. Note that this function can only be a WORD type; therefore, any memory address used at IN will appear on a Logicmaster screen in hexadecimal format. However, the value at BIT will appear in integer format regardless of whether a constant or memory address is used.

%M0001

%R0001 5C7C %R0002 +00014

GFK-0467M

BIT_ TEST_ WORD IN Q

%M0003

LEN 00001

Bit Number

16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

BIT

%R0001

0 1 0 1 1 1 0 0 0 1 1 1 1 1 0 0

Chapter 8 Bit Operation Functions

8-13

Page 141

8

BSET and BCLR (WORD) The Bit Set (BSET) function is used to set a bit in a bit string to 1. The Bit Clear (BCLR) function is used to clear a bit within a string by setting that bit to 0. Each sweep that power is received, the function sets the specified bit to 1 for the BSET function or to 0 for the BCLR function. If a variable (register) rather than a constant is used to specify the bit number, the same function block can set different bits on successive sweeps. A string length of 1 to 256 words can be selected. The function passes power flow to the right, unless the value for BIT is outside the range (1 ≤ BIT ≤ (16 * LEN) ). Then, ok is set OFF. For example, if LEN is set to 1, then the length of the bit string to be tested is 16. If, in this case, the number at BIT was 17 or higher, it would be out of range, so the ok output would not come on. _____ | | (enable), | BIT_| - (ok) | | | SET_| | WORD| | | (first word), |IN | | | | LEN | |00001| | | (bit number of IN), |BIT | |_____|

Parameters Parameter enable

Description When the enable input is on, the bit operation is performed.

IN

IN contains the address of the first word of the bit string to be operated on.

BIT

BIT contains the bit number of IN that should be set or cleared. Valid range is (1 ≤ BIT ≤ (16 * LEN) ).

ok

The ok output is energized whenever enable is energized, unless the value at the BIT input is outside the valid range.

LEN

LEN is the number of words in the bit string whose starting address is configured at IN..

Note When using the Bit Test, Bit Set, Bit Clear or Bit Position function, the bits are numbered 1 through 16, NOT 0 through 15.

8-14

Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002

GFK-0467M

Page 142

8

Valid Memory Types Parameter flow

%I

%Q

%M

%T

%S

%G

%R enable

•

IN

•

•

•

•

†

•

•

•

•

BIT

•

•

•

•

•

•

•

• ok • †

%AI %AQ const none

•

•

•

Valid reference or place where power may flow through the function. %SA, %SB, or %SC only; %S cannot be used.

Examples Note that the Bit Set and Bit Clear functions can only be WORD types; therefore, any memory address used at IN will appear on a Logicmaster screen in hexadecimal format. However, the value at BIT will appear in integer format whether a constant or memory address is used. In the following example, when input %M0001 is on, bit 12 (specified by the BIT input) of the string beginning at reference %R0001 (the address at the IN input) is set to 1 (set). %M0003

%M0001

%R0001 0800 %R0002 +00012

BIT_ SET_ WORD IN LEN 00001

Bit Number

16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

BIT

%R0001

0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0

In the next example, when input %M0001 is on, bit 5 (the value of the BIT input) of the string beginning at reference %R0001 (the address at the IN input) is set to 0 (cleared). %M0003

%M0001

%R0001 7FEF %R0002 +00005

GFK-0467M

BIT_ CLR_ WORD IN LEN 00001

Bit Number

16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

BIT

%R0001

0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1

Chapter 8 Bit Operation Functions

8-15

Page 143

8

BPOS (WORD) The Bit Position (BPOS) function is used to locate in a bit string, a bit whose value is logic 1. Each sweep that the function is enabled, it scans the bit string starting at IN. When the function stops scanning, either a bit equal to 1 has been found or the entire length of the string has been scanned. POS is set to the position within the bit string of the first non-zero bit; POS is set to zero if no nonzero bit is found. A string length of 1 to 256 words can be selected. The function passes power flow to the right whenever enable is ON. _____ | | (enable), | BIT_| - (ok) | POS | | WORD| | | | | (first word), |IN | | | | LEN | |00001| | POS| - (position of non-zero bit or 0) |_____|

Parameters Parameter enable

Description When the enable input is on, a bit search operation is performed.

IN

IN contains the first word of the bit string to be operated on.

ok

The ok output is energized whenever enable is energized.

POS

The position of the first non-zero bit found, or zero if a non-zero bit is not found.

LEN

LEN is the number of words in the bit string.

Note When using the Bit Test, Bit Set, Bit Clear or Bit Position function, the bits are numbered 1 through 16, NOT 0 through 15.

8-16

Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002

GFK-0467M