Assignment 1 Code
Assignment 1 Code
Assignment 1 Code
Automation Portal
Program blocks
Main [OB1]
Main Properties
General
Name Main Number 1 Type OB Language LAD
Numbering automatic
Information
Title "Main Program Sweep (Cy‐ Author Comment Family
cle)"
Version 0.1 User-defined
ID
%FC9000
"MHJ-PLC-Lab-Function-S71200"
EN ENO
Network 2:
%FC1
"Scaling"
EN ENO
%ID30 %QD38
"Tag_5" SENSOR Scaled_in cm "Tag_9"
%QD42
Scaled_Sensor "Tag_12"
Network 3:
%FC3
"Proportional Control Logic"
EN ENO
%ID34 %QD34
"Tag_8" Set Point Drain Valve "Tag_6"
%ID30 %QD30
"Tag_5" SENSOR Filling Valve "Tag_7"
%ID38
"Tag_11" Kp
Program blocks
MHJ-PLC-Lab-Function-S71200 [FC9000]
MHJ-PLC-Lab-Function-S71200 Properties
General
Name MHJ-PLC-Lab-Function- Number 9000 Type FC Language SCL
S71200
Numbering manual
Information
Title Author Comment Family
Version 0.1 User-defined
ID
0001
0002 #Value:=PEEK(area := 16#82,
0003 dbNumber := 0,
0004 byteOffset := 511);
0005 #Value := #Value + 1;
0006
0007 POKE(area := 16#82,
0008 dbNumber := 0,
0009 byteOffset := 511,
0010 value := #Value);
0011
0012 POKE(area:=16#81,
0013 dbNumber:=0,
0014 byteOffset:=1016,
0015 value:=#Value_01_DW);
0016 POKE(area := 16#81,
0017 dbNumber := 0,
0018 byteOffset := 1020,
0019 value := #Value_02_DW);
0020
0021 POKE(area := 16#81,
0022 dbNumber := 0,
0023 byteOffset := 511,
0024 value := B#16#00);
0025
0026 FOR #forVal := 0 TO 120 DO
0027 FOR #forVal_2:=0 TO 10 DO
0028 #rdTimeReturn:=RD_SYS_T(#outputTime);
0029 #rdTimeReturn := WR_SYS_T(#outputTime);
0030 #rdTimeReturn := RD_SYS_T(#outputTime);
0031 #rdTimeReturn := WR_SYS_T(#outputTime);
0032 END_FOR;
0033 #SyncVal:= PEEK(area := 16#81,
0034 dbNumber := 0,
0035 byteOffset := 511);
0036 IF #SyncVal = #CompVal THEN
0037 GOTO M_1;
0038 END_IF;
0039 END_FOR;
0040 RETURN;
0041
0042 M_1:
0043 POKE(area := 16#81,
0044 dbNumber := 0,
0045 byteOffset := 511,
Totally Integrated
Automation Portal
Program blocks
Scaling [FC1]
Scaling Properties
General
Name Scaling Number 1 Type FC Language SCL
Numbering automatic
Information
Title Author Comment Family
Version 0.1 User-defined
ID
Program blocks
Automation Control (ON/OFF) [FC2]
Automation Control (ON/OFF) Properties
General
Name Automation Control (ON/ Number 2 Type FC Language SCL
OFF)
Numbering automatic
Information
Title Author Comment Family
Version 0.1 User-defined
ID
0001 //IF tank level is < 40% = Fill Valve Opening 100%
0002 //IF tank level is > 40% AND < 80% = Fill Valve Opening 50%
0003 //IF tank level is > 80% = Fill Valve Opening 0%
0004
0005 IF #"Level in Percentage" < 40.0 THEN
0006 #"Fill Valve" := 10.0; // Statement section IF
0007
0008 ELSIF #"Level in Percentage" > 40.0 AND #"Level in Percentage" < 80.0 THEN
0009 #"Fill Valve" := 5.0; // Statement section ELSIF
0010
0011 ELSIF #"Level in Percentage" > 80.0 THEN
0012 #"Fill Valve" := 0.0;// Statement section ELSE
0013
0014 END_IF;
0015
0016 //Use Toggle button TO drain the level (at 50% flow rate)
0017 IF #"Drain Button" = 1 THEN
0018 #"Drain Valve" := 5.0;
0019 END_IF;
Program blocks
Proportional Control Logic [FC3]
Proportional Control Logic Properties
General
Name Proportional Control Logic Number 3 Type FC Language SCL
Numbering automatic
Information
Title Author Comment Family
Version 0.1 User-defined
ID