FillATank
CJ1M
LD P_First_Cycle
MOV(021) #ABBA D19998
// This is the PLC Validation Code for this project
^^^
' Main Switch Monitoring and Manual Modes Management
^^^
LD P_Off
@LD Valve_1_mode
@OR Pump_1_mode
@OR Valve_2_mode
@OR Pump_2_mode
KEEP(011) Run_Stop
^^^
LD P_Off
LD Run_Stop
KEEP(011) Valve_1_mode
^^^
LD P_Off
LD Run_Stop
KEEP(011) Pump_1_mode
^^^
LD P_Off
LD Run_Stop
KEEP(011) Valve_2_mode
^^^
LD P_Off
LD Run_Stop
KEEP(011) Pump_2_mode
^^^
' Filling Circuit 1
^^^
LDNOT Min
LD Mid
OR Max
ORNOT Run_Stop
KEEP(011) Fill_1
^^^
LD Fill_1
LD T_OffPump_1
KEEP(011) Valve_1_aut
^^^
LD T_Valve_1
LDNOT Fill_1
KEEP(011) Pump_1_aut
^^^
LD Fill_1
AND Valve_1_open
TIMX(550) 0021 &40
^^^
LDNOT Fill_1
AND Valve_1_open
ANDNOT Pump_1
TIMX(550) 0020 &40
^^^
LD Valve_1_aut
ANDNOT Valve_1_mode
OR Valve_1_mode
OUT Valve_1_open
OUTNOT Valve_1_closed
^^^
LD Pump_1_aut
ANDNOT Pump_1_mode
OR Pump_1_mode
OUT Pump_1
^^^
' Filling Circuit 2
^^^
LDNOT Min
ORNOT Mid
LD Max
ORNOT Run_Stop
KEEP(011) Fill_2
^^^
LD Fill_2
LD T_OffPump_2
KEEP(011) Valve_2_aut
^^^
LD T_Valve_2
LDNOT Fill_2
KEEP(011) Pump_2_aut
^^^
LD Fill_2
AND Valve_2_open
TIMX(550) 0023 &40
^^^
LDNOT Fill_2
AND Valve_2_open
ANDNOT Pump_2
TIMX(550) 0022 &40
^^^
LD Valve_2_aut
ANDNOT Valve_2_mode
OR Valve_2_mode
OUT Valve_2_open
OUTNOT Valve_2_closed
^^^
LD Pump_2_aut
ANDNOT Pump_2_mode
OR Pump_2_mode
OUT Pump_2
^^^
' Level Simulation
^^^
LD P_On
FLT(452) +0 Pump_1_Flow
FLT(452) +0 Pump_2_Flow
FLT(452) +0 Output_Flow
^^^
LD P_On
OUT TR0
AND Pump_1
AND Valve_1_open
MOVL(498) Sim_Pump_1_Flow Pump_1_Flow
LD TR0
AND Pump_2
AND Valve_2_open
MOVL(498) Sim_Pump_2_Flow Pump_2_Flow
LD TR0
AND>F(333) Tank_Level +0
MOVL(498) Sim_Output_Flow Output_Flow
^^^
@LD P_1s
+F(454) Tank_Level Pump_1_Flow Tank_Level
^^^
@LD P_1s
+F(454) Tank_Level Pump_2_Flow Tank_Level
^^^
@LD P_1s
-F(455) Tank_Level Output_Flow Tank_Level
^^^
LD>F(333) Tank_Level +1000
FLTL(453) +1000 Tank_Level
^^^
LDF(333) Tank_Level Max_Level
OUT Max
^^^
LD>F(333) Tank_Level Mid_Level
OUT Mid
^^^
LD>F(333) Tank_Level Min_Level
OUT Min
Valve_1_mode BOOL H1.00 ord:=3030 ; section:="VALVE 1" ; label:="Man/Auto" ; comment:="Manual Open (will stop process!)" ; access:=4 ; write_access:=5 ; 0
Pump_1_mode BOOL H1.01 ord:=4030 ; section:="PUMP 1" ; label:="Man/Auto" ; comment:="Manual Run (will stop process!)" ; access:=4 ; write_access:=5 ; 0
Valve_2_mode BOOL H2.00 ord:=5030 ; section:="VALVE 2" ; label:="Man/Auto" ; comment:="Manual Open (will stop process!)" ; access:=4 ; write_access:=5 ; 0
Pump_2_mode BOOL H2.01 ord:=6030 ; section:="PUMP 2" ; label:="Man/Auto" ; comment:="Manual Run (will stop process!)" ; access:=4 ; write_access:=5 ; 0
Run_Stop BOOL W20.00 ord:=1000 ; section:="GENERAL" ; label:="Main Run/Stop Switch" ; Comment:="Main Process Start/Stop" ; access:=3 ; write_access:=3 ; 0
Min BOOL W20.01 local_port:=9600; remote_port:=9600; local_ip:="192.168.1.40";remote_host:="remote.hostname.com";ssl:=false; 0
Mid BOOL W20.02 0
Max BOOL W20.03 0
Fill_1 BOOL W21.07 0
T_OffPump_1 BOOL T0020 0
Valve_1_aut BOOL W21.05 0
T_Valve_1 BOOL T0021 0
Pump_1_aut BOOL W21.06 0
Valve_1_open BOOL W21.00 ord:=3000 ; section:="VALVE 1" ; label:="Limit Switch" ; comment:="Valve 1 Completely Open" ; on_label:="OPEN"; off_label:="OFF"; access:=3 ; 0
Pump_1 BOOL W21.03 ord:=4010 ; section:="PUMP 1" ; label:="State" ; comment:="Pump 1 Run state" ; on_label:="RUN"; off_label:="STOP"; access:=3 ; 0
Valve_1_closed BOOL W21.01 ord:=3010 ; section:="VALVE 1" ; label:="Limit Switch" ; comment:="Valve 1 Completely Closed" ; on_label:="CLOSE"; off_label:="OFF"; access:=3 ; 0
Fill_2 BOOL W22.07 0
T_OffPump_2 BOOL T0022 0
Valve_2_aut BOOL W22.05 0
T_Valve_2 BOOL T0023 0
Pump_2_aut BOOL W22.06 0
Valve_2_open BOOL W22.00 ord:=5000 ; section:="VALVE 2" ; label:="Limit Switch" ; comment:="Valve 2 Completely Open" ; on_label:="OPEN"; off_label:="OFF"; access:=3 ; 0
Pump_2 BOOL W22.03 ord:=6010 ; section:="PUMP 2" ; label:="State" ; comment:="Pump 2 Run state" ; on_label:="RUN"; off_label:="STOP"; access:=3 ; 0
Valve_2_closed BOOL W22.01 ord:=5010 ; section:="VALVE 2" ; label:="Limit Switch" ; comment:="Valve 2 Completely Closed" ; on_label:="CLOSE"; off_label:="OFF"; access:=3 ; 0
Pump_1_Flow REAL D12 ord:=4000 ; section:="PUMP 1" ; label:="Input Flow 1 (L/s)" ; comment:="Current Input Flow 1" ; access:=3 ; 0
Pump_2_Flow REAL D14 ord:=6000 ; section:="PUMP 2" ; label:="Input Flow 2 (L/s)" ; comment:="Current Input Flow 2" ; access:=3 ; 0
Output_Flow REAL D22 ord:=2001 ; section:="WATER TANK" ; label:="Output Flow (L/s) " ; comment:="Current Output Flow from Tank" ; access:=3 ; 0
Sim_Pump_1_Flow REAL D18 ord:=7010 ; section:="DEVELOPER" ; label:="Input Flow 1 (L/s)" ; comment:="Input Flow 1 for simulation" ; access:=6 ; write_access:=6 ; 0
Sim_Pump_2_Flow REAL D20 ord:=7020 ; section:="DEVELOPER" ; label:="Input Flow 2 (L/s)" ; comment:="Input Flow 2 for simulation" ; access:=6 ; write_access:=6 ; 0
Tank_Level REAL D4 ord:=2000 ; section:="WATER TANK" ; label:="Tank Level (L)" ; comment:="Water Tank Current Level" ; access:=0 ; 0
Sim_Output_Flow REAL D16 ord:=7000 ; section:="DEVELOPER" ; label:="Output Flow (L/s)" ; comment:="Output Flow for simulation" ; access:=6 ; write_access:=6 ; 0
Max_Level REAL D10 ord:=2010 ; section:="WATER TANK" ; label:="High Level Set Point (L)" ; comment:="Level at which pumps stop" ; access:=4 ; write_access:=4 ; 0
Mid_Level REAL D8 ord:=2020 ; section:="WATER TANK" ; label:="Mid Level Set Point (L)" ; comment:="Level at which pump 1 stops" ; access:=4 ; write_access:=4 ; 0
Min_Level REAL D6 ord:=2030 ; section:="WATER TANK" ; label:="Low Level Set Point (L)" ; comment:="Level at which pumps start" ; access:=4 ; write_access:=4 ; 0
This example program is designed to simulate a process to be monitored by ScadaMobile.
Basicaly it simulates a water tank that is filled by two valve-pump sets running on/off depending on tank levels
The tank is emptied by a continuous flow.