Bit Field Distribute with Target (BTDT)

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.
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.
Available Languages
Ladder Diagram
This instruction is not available in a ladder diagram.
Structured Text
BTDT(BTDT_tag);
Operands
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.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand-related faults.
Execution
Structured Text
Condition/State
Action Taken
Prescan
EnableIn and EnableOut bits are cleared to false.
Normal Execution
EnableIn and EnableOut bits are set to true.
The instruction executes.
Postscan
EnableIn and EnableOut bits are cleared to false.
Example
Step 1
The controller copies Target into Dest.
Step 2
The SourceBit and the Length specify which bits in Source to copy into Dest. Starting at DestBit, Source and Target remain unchanged.
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.
Normal