Data Transition (DTR)
The DTR instruction passes the Source value through a Mask and compares the result with the Reference value.
The DTR instruction also writes the masked Source value into the Reference value for the next comparison. The Source remains unchanged.
A "1" in the mask means the data bit is passed. A "0" in the mask means the data bit is blocked.
When enabled, the Mask passes data when the Mask bits are set; the Mask blocks data when the Mask bits are cleared.
When the masked Source differs from the Reference, the EnableOut goes true for one scan. When the masked Source is the same as the Reference, the EnableOut is false.
IMPORTANT:
Online programming with this instruction can be dangerous. If the Reference value is different than the Source value, the EnableOut goes true. Use caution if you insert this instruction when the processor is in Run or Remote Run mode.
Available Languages
Ladder Diagram
Operands
Ladder Diagram
Operand | Type | Format | Description |
---|---|---|---|
Source | DINT | immediate tag | array to compare to the reference |
Mask | DINT | immediate tag | which bits to block or pass |
Reference | DINT | tag | array to compare to the source |
Entering an immediate mask value
When you enter a mask, the programming software defaults to decimal values. If you want to enter a mask using another format, precede the value with the correct prefix.
Prefix | Description |
---|---|
16# | hexadecimal (e.g., 16#0F0F) |
8# | octal (e.g., 8#16) |
2# | binary (e.g., 2#00110011) |
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand-related faults.
Execution
Ladder Diagram
Condition | Action |
---|---|
Prescan | The Reference = Source AND Mask. |
Rung-condition-in is false | The Reference = Source AND Mask. |
Rung-condition-in is true | See DTR Flow Chart (True) |
Postscan | N/A |
DTR Flow Chart (True)
Example
Ladder Diagram
When enabled, the DTR instruction masks value_1. If there is a difference in the two masked values, the EnableOut is set to true.
In example 1, since reference value is equal to sourcevalue_1 AND mask, so the EnableOut will always set to false. In example 2, for some reason, the source value is changed, then reference_value is not equal to source_value AND mask, so in case of this, the EnableOut will be set to TRUE and the referencevalue will be updated based on the sourceValue and mask. That’s why you see in previous scan the reference value is 183, but in current scan it is 187. The rung remains true only for one scan when a change is detected because in the next scan as long as source is not changed, the rung will remains false because the reference value will be equal to source value AND mask again.
Provide Feedback