Both The Three Way And Two Way valves will look the same code vise. The difference is in how they operate, but for implementation they will look identical.

Lets start by identifying the required inputs and outputs:


INPUTS:

  • openCMD → BOOL
  • override → INT


OUTPUTS:

  • valveSignal → BOOL
  • valveState → INT


Here OpenCMD is the signal which the controllers are going to use for commanding a valve to be opened, while valveSignal is the actual signal which is sendt to the Valve. Since none of the valves has any feedback system, It will just be trusted that they valves work.

The override input is utilized for external control of the valves . Here the override function can take in three values. These values are 0, 1 and 2 which are mapped to the following,

Override ValueFunction
0Automatic
1Manual Off
2Manual On

While the valveState gives information about the current state of the valves, ie which mode is it inn. The output is mapped to four values as shown below,

ValveState ValueDescription
0Automatic Off
1Automatic On
2Manual Off
3Manual On


Coded Solution:

Variable Declerations:

Code:

Function Block Visual:

  • No labels