D Flip-Flop (DFF)

The DFF instruction sets the Q output to the state of the D input on a cleared to set transition of the Clock input. The QNot output is set to the opposite state of the Q output.
When Clear is set, the instructions clears Q and sets QNot. Otherwise, if Clock is set and Clockn-1 is cleared, the instruction sets Q=D and sets QNot = NOT (D).
The instruction sets Clockn-1 = Clock state every scan.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram logic.
Structured Text
DFF(DFF_tag);
Operands
FLIP_FLOP_D Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
D
BOOL
The input to the instruction.
Default is cleared.
Clear
BOOL
Clear input to the instruction. If set, the instruction clears Q and sets QNot.
Clock
BOOL
Clock input to the instruction.
Default is cleared.
Output Parameter
Data Type
Description
EnableOut
BOOL
Indicates if instruction is enabled.
Q
BOOL
The output of the instruction.
QNot
BOOL
The complement of the Q output.
Structured Text
Operand
Type
Format
Description
DFF tag
FLIP_FLOP_D
structure
DFF structure
See Structured Text syntax for more 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
When Clock goes from cleared to set, the DFF instruction sets Q = D. When Clear is set, Q is cleared. The DFF instruction sets QNot to the opposite state of Q.
Structured Text
DFF_03.D := d_input;
DFF_03.Clear := clear_input;
DFF_03.Clock := clock_input;
DFF(DFF_03);
q_output := DFF_03.Q;
qNot_output := DFF_03.QNot;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal