Bit Field Distribute with Target (BTDT)

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 BTDT instruction first copies the Target to the Destination. Then the instruction copies the specified bits from the Source, shifts the bits to the appropriate position, and writes the bits into the Destination. The Target and Source remain unchanged.
Available Languages
Ladder Diagram
This instruction is not available in a ladder diagram.
Function Block
BTDT_FBD_avail_v31
Structured Text
BTDT(BTDT_tag);
Operands
Function Block
Operand
Type
Format
Description
BTDT tag
FBD_BIT_FIELD_DISTRIBUTE
structure
BTDT structure
Structured Text
Input Parameter
Data Type
Description
EnableIn
BOOL
If cleared, the instruction does not execute and outputs are not updated. If set, the instruction executes.
Default is set.
Source
DINT
Input value containing the bits to move to Destination.
Valid = any integer
SourceBit
DINT
The bit position in Source (lowest bit number from where to start the move).
Valid = 0-31
Length
DINT
Number of bits to move.
Valid = 1-32
DestBit
DINT
The bit position in Dest (lowest bit number to start copying bits into).
Valid = 0-31
Target
DINT
Input value to move to Dest prior to moving bits from the Source.
Valid = any integer
Output Parameter
Data Type
Description
EnableOut
BOOL
Indicates if instruction is enabled.
Dest
DINT
Result of the bit move operation.
See
Structured Text Syntax
for information on the syntax of expressions within structured text.
Description
When true, the BTDT instruction first copies the Target to the Destination, and copies a group of bits from the Source to the Destination. The group of bits is identified by the Source bit (lowest bit number of the group) and the Length (number of bits to copy). The Destination bit identifies the lowest bit number bit to start with in the Destination. The Source and Target remains unchanged.
If the length of the bit field extends beyond the Destination, the instruction does not save the extra bits. Any extra bits do not wrap to the next word.
Affects Math Status Flags
Controllers
Affected Math Status Flag
CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers
Yes
CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers
No
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand-related faults.
Execution
Function Block
Condition/State
Action Taken
Prescan
EnableIn and EnableOut bits are cleared to false.
Tag.EnableIn is false
EnableIn and EnableOut bits are cleared to false.
Tag.EnableIn is true
EnableIn and EnableOut bits are set to true.
The instruction executes.
Instruction first run
N/A
Instruction first scan
N/A
Postscan
EnableIn and EnableOut bits are cleared to false.
Structured Text
Condition/State
Action Taken
Prescan
See Prescan in the Function Block table.
Normal Execution
See Tag.EnableIn is true in the Function Block table.
Postscan
See Postscan in the Function Block table.
Example
Step 1
The controller copies Target into Dest.
BTD value_1 before BTD
Step 2
The SourceBit and the Length specify which bits in Source to copy into Dest. Starting at DestBit, Source and Target remain unchanged.
BTD Value_1_2 before and after BTD instruction
Function Block
BTDT_FBD_ex_v31
Structured Text
BTDT_01.Source := sourceSTX;
BTDT_01.SourceBit := source_bitSTX;
BTDT_01.Length := LengthSTX;
BTDT_01.DestBit := dest_bitSTX;
BTDT_01.Target := TargetSTX;
BTDT(BTDT_01);
distributed_value := BTDT_01.Dest;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.