Bitwise Inclusive Or (OR)
This information applies to the
CompactLogix
5370, ControlLogix
5570, Compact GuardLogix
5370, GuardLogix
5570, Compact GuardLogix
5380, CompactLogix
5380, CompactLogix
5480, ControlLogix
5580, and GuardLogix
5580 controllers. Controller differences are noted where applicable.The OR instruction performs a bitwise OR operation using the bits in Source A and Source B and places the result in Dest.
Available Languages
Ladder Diagram
Function Block Diagram
Function Block Diagram supports these elements:
FBD Block
FBD Function
TIP:
FBD Function is applicable to CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers only.
Structured Text
This instruction is not available in structured text.
TIP:
Use OR as an operator in an expression to compute the same result. Refer to Structured Text Syntax for more information on the syntax of expressions and assignments within structured text.
Operands
IMPORTANT:
Unexpected operation may occur if:
- Output tag operands are overwritten.
- Members of a structure operand are overwritten.
- Except when specified, structure operands are shared by multiple instructions.
There are data conversion rules for mixing numeric data types within an instruction. See Data Conversions.
Ladder Diagram
Operand | Data Type CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers | Data Type CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers | Format | Description |
---|---|---|---|---|
Source A | SINT INT DINT REAL | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | immediate tag | Value to OR with Source B. //Float includes REAL and LREAL data types. Tip: Float inputs are converted to integer which may cause an overflow. |
Source B | SINT INT DINT REAL | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | immediate tag | Value to OR with Source A. Tip: Float inputs are converted to integer which may cause an overflow. |
Dest | SINT INT DINT REAL | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | tag | Tag to store result of the instruction. Tip: If the destination type is Float, the resultant value will be converted to Float. |
TIP:
When integer promotion is required for the inputs, the smaller type is converted to the larger type using zero extension.
Function Block
Operand | Type | Format | Description |
---|---|---|---|
OR | FBD_LOGICAL | tag | OR structure |
FBD_LOGICAL Structure
Input Members | Data Type | Description |
---|---|---|
EnableIn | BOOL | Enable input. If false, the instruction does not execute and outputs are not updated.
Default is true. |
SourceA | DINT | Value to OR with SourceB. |
SourceB | DINT | Value to OR with SourceA. |
Output Members | Data Type | Description |
---|---|---|
EnableOut | BOOL | Indicates if the instruction executed successfully when it was enabled. |
Dest | DINT | Result of the instruction. |
FBD Function
TIP:
FBD Function is applicable to CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers only.
Input Operands (Left Pins) | Data Type CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers | Description |
---|---|---|
SourceA (top) | SINT USINT INT UINT DINT UDINT LINT ULINT REAL LREAL | Value to OR with Source B. |
SourceB (bottom) | SINT USINT INT UINT DINT UDINT LINT ULINT REAL LREAL | Value to OR with Source A. |
Output Operand (Right Pin) | Data Type CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers | Description |
---|---|---|
Dest | DINT UDINT LINT ULINT | Result of the function. |
See
FBD Functions
.Description
When enabled, the instruction evaluates the bitwise OR operation:
Dest = Source A OR Source B
If the bit in
Source A is: | And the bit in
Source B is: | The bit in
Dest is: |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Affects Math Status Flags
Controllers | Affects Math Status Flag |
---|---|
CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers | Conditional |
CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers | Yes |
See Math Status Flags.
Major/Minor Faults
None specific to this instruction. See Index Through Arrays for array-indexing faults.
Execution
Ladder Diagram
Condition/State | Action Taken |
---|---|
Prescan | N/A |
Rung-condition-in is false | Set Rung-condition-out to Rung-condition-in |
Rung-condition-in is true | Set Rung-condition-out to Rung-condition-in Dest is set as described in the Description section. |
Postscan | N/A |
Function Block
Condition/State | Action Taken |
---|---|
Prescan | N/A |
EnableIn is false | Set EnableOut to EnableIn |
EnableIn is true | Set EnableOut to EnableIn Dest is set as described in the Description section. |
Instruction first run | N/A |
Instruction first scan | N/A |
Postscan | N/A |
FBD Function
TIP:
FBD Function is applicable to CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers only.
Condition/State | Action Taken |
---|---|
Prescan | N/A |
Normal Scan | Dest = SourceA OR SourceB |
Instruction first run | N/A |
Instruction first scan | N/A |
Postscan | N/A |
Examples
Ladder Diagram
Function Block
FBD Function
Structured Text
value_result_or := value_1 OR value_2;
Provide Feedback