Discrete 2-State Device (D2SD)

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.
The Discrete 2-State Device (D2SD) instruction controls a discrete device which has only two possible states (such as on/off or open/closed).
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram logic.
Function Block
D2SD_FB_avail_v31
Structured Text
D2SD(D2SD_tag)
Operands
There are data conversion rules for mixed data types within an instruction. See
Data Conversion
.
Structured Text
Operand
Type
Format
Description
D2SD tag
DISCRETE_2STATE
Structure
D2SD structure
See
Structured Text Syntax
for more information on the syntax of expressions within structured text.
Function Block
Operand
Type
Format
Description
D2SD tag
DISCRETE_2STATE
Structure
D2SD structure
DISCRETE_2STATE Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If false, the instruction does not execute and outputs are not updated.
Default is true.
ProgCommand
BOOL
Used to determine CommandStatus when the device is in Program control. When true, the device is commanded to the 1 state; when false, the device is commanded to the 0 state.
Default is false.
Oper0Req
BOOL
Operator state 0 request. Set by the operator interface to place the device in the 0 state when the device is in Operator control.
Default is false.
Oper1Req
BOOL
Operator state 1 request. Set by the operator interface to place the device in the 1 state when the device is in Operator control.
Default is false.
State0Perm
BOOL
State 0 permissive. Unless in Hand or Override mode, this input must be set for the device to enter the 0 state. This input has no effect for a device already in the 0 state.
Default is true.
State1Perm
BOOL
State 1 permissive. Unless in the Hand or Override mode, this input must be set for the device to enter the 1 state. This input has no effect for a device already in the 1 state.
Default is true.
FB0
BOOL
The first feedback input available to the D2SD instruction.
Default is false.
FB1
BOOL
The second feedback input available to the D2SD instruction.
Default is false.
HandFB
BOOL
Hand feedback input. This input is from a field hand/off/auto station and it shows the requested state of the field device. When true, the field device is being requested to enter the 1 state; when false, the field device is being requested to enter the 0 state.
Default is false.
FaultTime
REAL
Fault time value. Configure the value in seconds of the time to allow the device to reach a newly commanded state. Set FaultTime = 0 to disable the fault timer. If this value is invalid, the instruction assumes a value of zero and sets the appropriate bit in Status.
Valid = any float Greater than or equal to 0.0
Default = 0.0
FaultAlarmLatch
BOOL
Fault alarm latch input. When true and FaultAlarm is true, latch FaultAlarm. To unlatch FaultAlarm set FaultAlmUnlatch to true or clear FaultAlarmLatch to false.
Default is false.
FaultAlmUnLatch
BOOL
Fault alarm unlatch input. Set FaultAlmUnLatch when FaultAlarmLatch is set to unlatch FaultAlarm. The instruction clears this input to false.
Default is false.
OverrideOnInit
BOOL
Override on initialization request. If this bit is true, then during instruction first scan, the 2-state device is placed in Operator control, Override is set to true, and Hand is cleared to false. If ProgHandReq is true, then Override is cleared to false and Hand is set to true.
Default is false.
OverrideOnFault
BOOL
Override on fault request. Set OverrideOnFault to true if the device should go to Override mode and enter the OverrideState on a fault alarm. After the fault alarm is removed, the 2-state device is placed in Operator control.
Default is false.
OutReverse
BOOL
Reverse default out state. The default state of Out is cleared to false when commanded to state 0, and set to true when commanded to state 1. When OutReverse is true, Out is set to true when commanded to state 0, and cleared to false when commanded to state 1.
Default is false.
OverrideState
BOOL
Override state input. Configure this value to specify the state of the device when the device is in Override mode. True indicates the device should go to the 1 state; false indicates the device should go to the 0 state.
Default is false.
FB0State0
BOOL
Feedback 0 state 0 input. Configure the state of the FB0 when the device is in the 0 state.
Default is false.
FB0State1
BOOL
Feedback 0 state 1 input. Configure the state of the FB0 when the device is in the 1 state.
Default is false.
FB1State0
BOOL
Feedback 1 state 0 input. Configure the state of the FB1 when the device is in the 0 state.
Default is false.
FB1State1
BOOL
Feedback 1 state 1 input. Configure the state of the FB1 when the device is in the 1 state.
Default is false.
ProgProgReq
BOOL
Program program request. Set to true by the user program to request Program control. Ignored if ProgOperReq is true. Holding this true and ProgOperReq false locks the instruction into Program control.
Default is false.
ProgOperReq
BOOL
Program operator request. Set to true by the user program to request Operator control. Holding this true locks the instruction into Operator control.
Default is false.
ProgOverrideReq
BOOL
Program override request. Set to true by the user program to request the device to enter Override mode. Ignored if ProgHandReq is true.
Default is false.
ProgHandReq
BOOL
Program hand request. Set to true by the user program to request the device to enter Hand mode.
Default is false.
OperProgReq
BOOL
Operator program request. Set to true by the operator interface to request Program control. The instruction clears this input to false.
Default is false.
OperOperReq
BOOL
Operator operator request. Set to true by the operator interface to request Operator control. The instruction clears this input to false.
Default is false.
ProgValueReset
BOOL
Reset program control values. When true, all the program request inputs are cleared to false at each execution of the instruction.
Default is false.
Output Parameter
Data Type
Description
EnableOut
BOOL
Indicates if instruction is enabled.
Out
BOOL
The output of the 2-state instruction.
Device0State
BOOL
Device 0 state output. Set to true when the device is commanded to the 0 state and the feedbacks indicate the device really is in the 0 state.
Device1State
BOOL
Device 1 state output. Set to true when the device is commanded to the 1 state and the feedbacks indicate the device really is in the 1 state.
CommandStatus
BOOL
Command status output. Set to true when the device is being commanded to the 1 state and cleared when the device is being commanded to the 0 state.
FaultAlarm
BOOL
Fault alarm output. Set to true if the device was commanded to a new state and the FaultTime has expired without the feedbacks indicating that the new state has actually been reached. Also set to true if, after reaching a commanded state, the feedbacks suddenly indicate that the device is no longer in the commanded state.
ModeAlarm
BOOL
Mode alarm output. Set to true if the device is in Operator control and a program command changes to a state which is different from the state currently commanded by the operator. This alarm is intended as a reminder that a device was left in Operator control.
ProgOper
BOOL
Program/Operator control indicator. True when in Program control. False when in Operator control.
Override
BOOL
Override mode. True when the device is in the Override mode.
Hand
BOOL
Hand mode. True when the device is in the Hand mode.
Status
DINT
Status of the function block.
InstructFault (Status.0)
BOOL
The instruction detected one of the following execution errors. This is not a minor or major controller error. Check the remaining status bits to determine what occurred.
FaultTimeInv (Status.1)
BOOL
Invalid FaultTime value. The instruction sets FaultTime = 0.
OperReqInv (Status.2)
BOOL
Both operator state request bits are true.
Description
The D2SD instruction controls a discrete device which has only two possible states (such as on/off or open/closed). Typical discrete devices of this nature include motors, pumps, and solenoid valves.
Monitoring the D2SD Instruction
There is an operator faceplate available for the D2SD instruction.
Affects Math Status Flags
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
Set ProgOper to Operator Mode. Set CommandStatus to False.
Instruction first scan
Set EnableOut to true.
ModeAlarm and operator request inputs are cleared to false,
If ProgValueReset is true, all the program request inputs are cleared to false.
When OverrideOnInit is true, ProgOper is cleared to false (Operator control).
If ProgHandReq is cleared and OverrideOnInit is set, clear Hand and set Override (Override mode).
If ProgHandReq is set, set Hand and clear Override (Hand mode).
Postscan
EnableIn and EnableOut bits are cleared to false.
Structured Text
In Structured Text, EnableIn is always true during normal scan. Therefore, if the instruction is in the control path activated by the logic it will execute.
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.
Examples
SD instruction is typically used to control on-off or open-close devices such as pumps or solenoid valves. In this example, the D2SD instruction controls a solenoid valve adding corn syrup to a batch tank. As long as the D2SD instruction is in Program control, the valve opens when the AddSyrup input is set. The operator can also take Operator control of the valve to open or close it if necessary The solenoid valve in this example has limit switches that indicate when the valve is fully closed or opened. These switches are wired into the FB0 and FB1 feedback inputs. This allows the D2SD instruction to generate a FaultAlarm if the solenoid valve does not reach the commanded state within the configured FaultTime.
Function Block
D2SD_FB_ex_v31
Structured Text
SyrupController.ProgCommand := AddSyrup;
SyrupController.FB0 := SyrupValveClosedLimitSwitch;
SyrupController.FB1 := SyrupValveOpenedLimitSwitch;
D2SD(SyrupController);
SyrupValve := SyrupController.Out;
Switch Between Program Control and Operator Control
The following diagram shows how the D2SD instruction changes between Program control and Operator control.
D2SD_program_operator control
(1) The instruction remains in Operator control mode when ProgOperReq is true.
Commanded State in Program Control
The following diagram shows how the D2SD instruction operates when in Program control.
D2SD_program_operator control 2
Commanded State in Operator Control
The following diagram shows how the D2SD instruction operates when in Operator control.
D2SD_program_operator control 3
If both Oper0Req and Oper1Req are true:
  • The instruction sets the appropriate bit in Status to true
  • If Override and Hand are false, the instruction holds the previous state.
After every instruction execution, the instruction:
  • Clears all the operator request inputs to false
  • If ProgValueReset is true, clears all the program request inputs to false
Hand Mode or Override Mode
The following table describes how the D2SD instruction determines whether to operate in Hand or Override mode.
ProgHandReq
ProgOverrideReq
FaultAlarm and OverrideOnFault
Description
true
either
either
Hand mode
Hand is set to true
Override is cleared to false
false
true
either
Override mode
Hand is cleared to false
Override is set to true
false
either
true
Override mode
Hand is cleared to false
Override is set to true
When the instruction is in Override mode, CommandStatus = OverrideState.
When the instruction is in Hand mode, CommandStatus = HandFB.
Output State
The D2SD output state is based on the state of the command status.
CommandStatus
Output State
false
If OutReverse is false, Out is cleared to false
If OutReverse is true, Out is set to true
true
If OutReverse is false, Out is set to rue
If OutReverse is true, Out is cleared to false
false and
FB0 = FB0State0 and
FB1 = FB1State0
The fault timer is stopped and cleared to 0
Device0State is set to true
true and
FB0 = FB0State1 and
FB1 = FB1State1
The fault timer is stopped and cleared to 0
Device1State is set to true
Fault Alarm Conditions
The D2SD instruction checks for these fault alarm conditions.
Fault alarm condition
resulting from
Rules
Device state was commanded to change, but the feedback did not indicate that the desired state was actually reached within the FaultTime
Start the fault timer when CommandStatus
n
Not equal to sign CommandStatus
n-1
Set FaultAlarm when faulttimer is done and FaultTime > 0.0
The device unexpectedly left a state (according to the feedback) without being commanded to
Set FaultAlarm to true when the fault timer is not timing and one of the following conditions is satisfied:
CommandStatus is false and Device0State is false
CommandStatus is true and Device1State is false
FaultAlarm is cleared to false if one of the following conditions is met:
  • CommandStatus is false and Device0State is true
  • CommandStatus is true and Device1State is true
  • FaultTime Less than or equal to 0
FaultAlarm cannot be cleared to false when FaultAlarmLatch is true, unless FaultAlmUnlatch is true and no fault is present.
Mode Alarm Conditions
The mode alarm reminds an operator that a device has been left in Operator control. The mode alarm only turns on when, in Operator control mode, the program tries to change the state of the device from the operator’s commanded state. The alarm does not turn on if an operator places a device in Operator control mode and changes the state. The D2SD instruction checks for mode alarm conditions, using these rules.
ModeAlarm
When
True
ProgCommand
n
Not equal to sign ProgCommandn-1 and
ProgCommand
n
Not equal to sign CommandStatus
False
ProgCommand = CommandStatus or
the device is in Override, Hand, or Program control mode
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.