Discrete 3-State Device (D3SD)
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 3-State Device (D3SD) instruction controls a discrete device having three possible states, such as fast/slow/off or forward/stop/reverse.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram logic.
Function Block
Structured Text
D3SD(D3SD_tag)
Operands
Structured Text
Operand | Type | Format | Description |
D3SD tag | DISCRETE_3STATE | structure | D3SD structure |
See
Structured Text Syntax
for more information on the syntax of expressions within structured text.Function Block
Operand | Type | Format | Description |
D3SD tag | DISCRETE_3STATE | structure | D3SD structure |
DISCRETE_3STATE 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. |
Prog0Command | BOOL | Program state 0 command. This input determines the device state when the device is in Program control. If true, the device is commanded to the 0 state.
Default is false. |
Prog1Command | BOOL | Program state 1 command. This input determines the device state when the device is in Program control. If true, the device is commanded to the 1 state.
Default is false. |
Prog2Command | BOOL | Program state 2 command. This input determines the device state when the device is in Program control. If true, the device is commanded to the 2 state.
Default is false. |
Oper0Req | BOOL | Operator state 0 request. Set to true by the operator interface to place the device into the 0 state when the device is in Operator control.
Default is false. |
Oper1Req | BOOL | Operator state 1 request. Set true by the operator interface to place the device into the 1 state when the device is in Operator control.
Default is false. |
Oper2Req | BOOL | Operator state 2 request. Set to true by the operator interface to place the device into the 2 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 true for the device to enter the 0 state. This input has no effect if the device is already in the 0 state.
Default is true. |
State1Perm | BOOL | State 1 permissive. Unless in Hand or Override mode, this input must be true for the device to enter the 1 state. This input has no effect if the device is already in the 1 state.
Default is true. |
State2Perm | BOOL | State 2 permissive. Unless in Hand or Override mode, this input must be true for the device to enter the 2 state. This input has no effect if the device is already in the 2 state.
Default is true. |
FB0 | BOOL | The first feedback input available to the instruction.
Default is false. |
FB1 | BOOL | The second feedback input available to the instruction.
Default is false. |
FB2 | BOOL | The third feedback input available to the instruction.
Default is false. |
FB3 | BOOL | The fourth feedback input available to the instruction.
Default is false. |
HandFB0 | BOOL | Hand feedback state 0. This input from a field hand/off/auto station shows the requested state of the field device. True indicates the field device is being requested to enter the 0 state; false indicates the field device is being requested to enter some other state.
Default is false. |
HandFB1 | BOOL | Hand feedback state 1. This input from a field hand/off/auto station shows the requested state of the field device. True indicates the field device is being requested to enter the 1 state; false indicates the field device is being requested to enter some other state.
Default is false. |
HandFB2 | BOOL | Hand feedback state 2. This input from a field hand/off/auto station shows the requested state of the field device. True indicates the field device is being requested to enter the 2 state; false indicates the field device is being requested to enter some other 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 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 this input to true 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 instruction is placed in Operator control with Override true and Hand 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 this value to true if the device should go to Override mode and enter the Override State on a fault alarm. After the fault alarm is removed, the instruction is placed in Operator control.
Default is false. |
Out0State0 | BOOL | Output 0 state 0 input. This value determines the value of Output0 when the device is in the 0 state.
Default is false. |
Out0State1 | BOOL | Output 0 state 1 input. This value determines the value of Output0 when the device is in the 1 state.
Default is false. |
Out0State2 | BOOL | Output 0 state 2 input. This value determines the value of Output0 when the device is in the 2 state.
Default is false. |
Out1State0 | BOOL | Output 1 state 0 input. This value determines the value of Output1 when the device is in the 0 state.
Default is false. |
Out1State1 | BOOL | Output 1 state 1 input. This value determines the value of Output1 when the device is in the 1 state.
Default is false. |
Out1State2 | BOOL | Output 1 state 2 input. This value determines the value of Output1 when the device is in the 2 state.
Default is false. |
Out2State0 | BOOL | Output 2 state 0 input. This value determines the value of Output2 when the device is in the 0 state.
Default is false. |
Out2State1 | BOOL | Output 2 state 1 input. This value determines the value of Output2 when the device is in the 1 state.
Default is false. |
Out2State2 | BOOL | Output 2 state 2 input. This value determines the value of Output2 when the device is in the 2 state.
Default is false. |
OverrideState | DINT | Override state input. Set this input to indicate the state of the device when in Override mode. 2 = Device should go to the 2 state 1 = Device should go to the 1 state 0 = Device should go to the 0 state An invalid value sets the appropriate bit in Status.
Valid = 0 to 2
Default = 0 |
FB0State0 | BOOL | Feedback 0 state 0 input. This value determines the expected value of FB0 when the device is in the 0 state.
Default is false. |
FB0State1 | BOOL | Feedback 0 state 1 input. This value determines the expected value of FB0 when the device is in the 1 state.
Default is false. |
FB0State2 | BOOL | Feedback 0 state 2 input. This value determines the expected value of FB0 when the device is in the 2 state.
Default is false. |
FB1State0 | BOOL | Feedback 1 state 0 input. This value determines the expected value of FB1 when the device is in the 0 state.
Default is false. |
FB1State1 | BOOL | Feedback 1 state 1 input. This value determines the expected value of FB1 when the device is in the 1 state.
Default is false. |
FB1State2 | BOOL | Feedback 1 state 2 input. This value determines the expected value of FB1 when the device is in the 2 state.
Default is false. |
FB2State0 | BOOL | Feedback 2 state 0 input. This value determines the expected value of FB2 when the device is in the 0 state.
Default is false. |
FB2State1 | BOOL | Feedback 2 state 1 input. This value determines the expected value of FB2 when the device is in the 1 state.
Default is false. |
FB2State2 | BOOL | Feedback 2 state 2 input. This value determines the expected value of FB2 when the device is in the 2 state.
Default is false. |
FB3State0 | BOOL | Feedback 3 state 0 input. This value determines the expected value of FB3 when the device is in the 0 state.
Default is false. |
FB3State1 | BOOL | Feedback 3 state 1 input. This value determines the expected value of FB3 when the device is in the 1 state.
Default is false. |
FB3State2 | BOOL | Feedback 3 state 2 input. This value determines the expected value of FB3 when the device is in the 2 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 in 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 in 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. |
Out0 | BOOL | The first output of the instruction. |
Out1 | BOOL | The second output of the instruction. |
Out2 | BOOL | The third output of the instruction. |
Device0State | BOOL | Device state 0 output. True when the device is commanded to the 0 state and the feedback indicates the device really is in the 0 state. |
Device1State | BOOL | Device state 1 output. True when the device is commanded to the 1 state and the feedback indicates the device really is in the 1 state. |
Device2State | BOOL | Device state 2 output. True when the device is commanded to the 2 state and the feedback indicates the device really is in the 2 state. |
Command0Status | BOOL | Device state 0 command status. True when the device is being commanded to the 0 state; false when the device is being commanded to some other state. |
Command1Status | BOOL | Device state 1 command status. True when the device is being commanded to the 1 state; false when the device is being commanded to some other state. |
Command2Status | BOOL | Device state 2 command status. True when the device is being commanded to the 2 state; false when the device is being commanded to some other state. |
FaultAlarm | BOOL | Fault alarm output. True if the device has been commanded to a new state, and the FaultTime has expired without the feedback 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. True if the device is in operator control and a ProgxCommand input requests 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. |
OverrideStateInv (Status.2) | BOOL | The Override value is out of range. It prevents the instruction from entering the Override state. |
ProgCommandInv (Status.3) | BOOL | Multiple program state command bits are set at the same time. Refer to Commanded State in Program Control section. |
OperReqInv (Status.4) | BOOL | Multiple operator state request bits are set at the same time. Refer to Commanded State in Program Control section. |
HandCommandInv (Status.5) | BOOL | Multiple hand feedback state request bits are set at the same time. |
Description
The D3SD instruction controls a discrete device having three possible states, such as fast/slow/off or forward/stop/reverse. Typical discrete devices of this nature include feeder systems, and reversible motors.
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 Command0Status to True.
Set Command1Status to False.
Set Command2Status to False. |
Instruction first scan | The fault timer is cleared. ModeAlarm is cleared to false. All the 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 false and OverrideOnInit is true, Hand is cleared to false and Override is set to true (Override mode). If ProgHandReq is true, Hand is set to true and Override is cleared to false(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
The D3SD instruction is typically used to control 3-state devices such as high/low/off feed systems. In this example, the D3SD instruction controls a feed system consisting of a pair of solenoid valves adding vegetable oil to a batch tank. One of the valves is on a large diameter feed pipe into the batch tank, and the other valve is plumbed in parallel on a small diameter feed pipe. When oil is first added, the D3SD instruction is commanded to the fast feed state (state 2) where both valves are opened. When the oil added approaches the target amount, the D3SD instruction is commanded to the slow feed state (state 1) where the "large valve" is closed and the "small valve" is kept open. When the target is reached, the D3SD instruction is commanded to go to the off state (state 0) and both valves are closed. As long as the D3SD instruction is in Program control, the valves open according to the CloseOilFeed, SlowOilFeed, and FastOilFeed inputs. The operator can also take Operator control of the feed system if necessary. The solenoid valves in this example have limit switches which indicate when the valves are fully closed or opened. These switches are wired into the FB0, FB1, FB2, and FB3 feedback inputs. This allows the D3SD instruction to generate a FaultAlarm if the solenoid valves do not reach their commanded states within the configured FaultTime.
Function Block
Structured Text
OilFeedController.Prog0Command := ClosedOilFeed;
OilFeedController.Prog1Command := SlowOilFeed;
OilFeedController.Prog2Command := FastOilFeed;
OilFeedController.FB0 := SmallOilValveClosed;
OilFeedController.FB1 := SmallOilValveOpened;
OilFeedController.FB2 := LargeOilValveClosed;
OilFeedController.FB3 := LargeOilValveOpened;
D3SD(OilFeedController);
SmallOilValve := OilFeedController.Out0;
LargeOilValve := OilFeedController.Out1;
Switch Between Program Control and Operator Control
The following diagram shows how the D3SD instruction changes between Program control and Operator control.
(1) The instruction remains in Operator control mode when ProgOperReq is true.
Commanded State in Program Control
The following table shows how the D3SD instruction operates when in Program control.
Prog0 Command | Prog1 Command | Prog2 Command | State0
Perm | State1
Perm | State2
Perm | Description |
---|---|---|---|---|---|---|
false | false | true | either | either | true | Command0Status is cleared to false
Command1Status is cleared to false
Command2Status is set to true |
false | true | false | either | true | either | Command0Status is cleared to false
Command1Status is set to true
Command2Status is cleared to false |
true | false | false | true | either | either | Command0Status is set to true
Command1Status is cleared to false
Command2Status is cleared to false |
If more than one program command input is true:
- The instruction sets the appropriate bit in Status
- If Override and Hand are cleared to false, the instruction holds the previous state
Commanded State in Operator Control
The following table shows how the D3SD instruction operates when in Operator control.
Oper0Req | Oper1Req | Oper2Req | State0 Perm | State1 Perm | State2 Perm | Description |
---|---|---|---|---|---|---|
false | false | true | either | either | true | Command0Status is cleared to false
Command1Status is cleared to false
Command2Status is set to true |
false | true | false | either | true | either | Command0Status is cleared to false
Command1Status is set to true
Command2Status is cleared to false |
true | false | false | true | either | either | Command0Status is set to true
Command1Status is cleared to false
Command2Status is cleared to false |
If more than one operator command input is true:
- The instruction sets the appropriate bit in Status
- If Override and Hand are cleared to false, the instruction holds the previous state
After every instruction execution, the instruction:
- Clears all the operator request inputs
- If ProgValueReset is true, clears all the program request inputs to false
Hand Mode or Override Mode
The following table describes how the D3SD 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 Override is set, it takes precedence over Program and Operator control. The following table describes how the Override mode affects the commanded state.
Override | Override State | Description |
---|---|---|
true | 2 | Command0Status is cleared to false
Command1Status is cleared to false
Command2Status is set to true |
true | 1 | Command0Status is cleared to false
Command1Status is set to true
Command2Status is cleared to false |
true | 0 | Command0Status is set to true
Command1Status is cleared to false
Command2Status is cleared to false |
If OverrideState is invalid, the instruction sets the appropriate bit in Status and does not enter the override state.
When Hand is true, it takes precedence over Program and Operator control. The following table describes how the Hand mode affects the commanded state.
Hand | HandFB0 | HandFB1 | HandFB2 | Description |
---|---|---|---|---|
true | false | false | true | Command0Status is cleared to false
Command1Status is cleared to false
Command2Status is set to true |
true | false | true | false | Command0Status is cleared to false
Command1Status is set to true
Command2Status is cleared to false |
true | true | false | false | Command0Status is set to true
Command1Status is cleared to false
Command2Status is cleared to false |
If more than one HandFB input is true, the instruction sets the appropriate bit in Status and, if Hand is true, the instruction holds the previous state.
Output State
The D3SD output state is based on the state of the command status.
CommandStatus | Output State |
---|---|
Command0Status is true | Out0 = Out0State0
Out1 = Out1State0
Out2 = Out2State0 |
Command0Status is true and
FB0 = FB0State0 and
FB1 = FB1State0 and
FB2 = FB2State0 and
FB3 = FB3State0 | Stop and clear the fault timer.
Device0State is set to true |
Command1Status is true | Out0 = Out0State1
Out1 = Out1State1
Out2 = Out2State1 |
Command1Status is true and FB0 = FB0State1 and FB1 = FB1State1 and FB2 = FB2State1 and FB3 = FB3State1 | Stop and clear the fault timer.
Device1State is set to true |
Command2Status is true | Out0 = Out0State2
Out1 = Out1State2
Out2 = Out2State2 |
Command2Status is true and FB0 = FB0State2 and FB1 = FB1State2 and FB2 = FB2State2 and FB3 = FB3State2 | Stop and clear the fault timer.
Device2State is set to true |
Fault Alarm Conditions
The D3SD 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 Command0Status n n-1 or Command1Statusn Command1Statusn-1 or Command2Statusn Command2Statusn-1 Set FaultAlarm when the fault timer 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: Command0Status is true and Device0State is false Command1Status is true and Device1State is false Command2Status is true and Device2State is false |
If there is no fault present, FaultAlarm is cleared to false if one of the following conditions is met:
- Command0Status is true and Device0State is true
- Command1Status is true and Device1State is true
- Command2Status is true and Device2State is true
- FaultTime 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 D3SD instruction checks for mode alarm conditions, using these rules.
ModeAlarm is | When |
---|---|
true | Prog2Command Prog2Command n-1 and
Prog2Command Command2Status or Prog1Command Prog1Command n-1 and Prog1Command Command1Status or Prog0Command Prog1Command n-1 and Prog0Command Command0Status |
false | Prog2Command = Command2Status and
Prog1Command = Command1Status and
Prog0Command = Command0Status or
The device is in Override, Hand, or Program control mode |
Provide Feedback