Assignment 1 Code

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Totally Integrated

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

Name Data type Default value Comment


Input
Initial_Call Bool Initial call of this OB
Remanence Bool =True, if remanent data are available
Temp
Constant

Network 1: Code for Linking Siemens TIA and Factory IO

%FC9000
"MHJ-PLC-Lab-Function-S71200"
EN ENO

Symbol Address Type Comment

Network 2:

%FC1
"Scaling"
EN ENO
%ID30 %QD38
"Tag_5" SENSOR Scaled_in cm "Tag_9"
%QD42
Scaled_Sensor "Tag_12"

Symbol Address Type Comment


"Tag_5" %ID30 Real
"Tag_9" %QD38 Real
"Tag_12" %QD42 Real

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

Symbol Address Type Comment


"Tag_5" %ID30 Real
"Tag_6" %QD34 Real
"Tag_7" %QD30 Real
"Tag_8" %ID34 Real
"Tag_11" %ID38 Real
Totally Integrated
Automation Portal

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

Name Data type Default value Comment


Input
Output
InOut
Temp
rdTimeReturn Int
outputTime DTL
YEAR UInt
MONTH USInt
DAY USInt
WEEKDAY USInt
HOUR USInt
MINUTE USInt
SECOND USInt
NANOSECOND UDInt
SyncVal Byte
forVal Int
forVal_2 Int
Value Byte
Constant
CompVal Byte 16#34
Value_01 Byte 16#11
Value_01_DW DWord 16#A165_D992
Value_02_DW DWord 16#58BE_4401
Return
MHJ-PLC-Lab-Function-S71200 Void

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

0046 value := B#16#0);


0047
0048
0049

Symbol Address Type Comment


#CompVal 16#34 Byte
#forVal Int
#forVal_2 Int
#outputTime DTL
#rdTimeReturn Int
#SyncVal Byte
#Value Byte
#Value_01_DW 16#A165_D992 DWord
#Value_02_DW 16#58BE_4401 DWord
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

Name Data type Default value Comment


Input
SENSOR Real
Output
Scaled_in cm DInt
Scaled_Sensor Real
InOut
Temp
Scaled_in_cm_real Real
Constant
Return
Scaling Void

0001 //Convert the range 0.0- 10.0 to Percentage 0-100%


0002 #Scaled_Sensor := 10.0 * #SENSOR;
0003
0004 //Convert the range 0.0- 10.0 to Height range 0-300 cm
0005 #Scaled_in_cm_real := #SENSOR * 30.0;
0006
0007 #"Scaled_in cm" := REAL_TO_INT(#Scaled_in_cm_real);

Symbol Address Type Comment


#"Scaled_in cm" DInt
#Scaled_in_cm_real Real
#Scaled_Sensor Real
#SENSOR Real
Totally Integrated
Automation Portal

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

Name Data type Default value Comment


Input
Level in Percentage Real
Drain Button Bool
Output
Fill Valve Real
Drain Valve Real
InOut
Temp
Constant
Return
Automation Control (ON/OFF) Void

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;

Symbol Address Type Comment


#"Drain Button" Bool
#"Drain Valve" Real
#"Fill Valve" Real
#"Level in Percentage" Real
Totally Integrated
Automation Portal

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

Name Data type Default value Comment


Input
Set Point Real
SENSOR Real
Kp Real Proportional Gain
Output
Drain Valve Real
Filling Valve Real
InOut
Temp
error Real
kpp Real proportional gain
u Real
Constant
Return
Proportional Control Logic Void

0001 // Input ID38 0-10.0 == 1 to 10


0002 // Scaling Formulae
0003 // Scaled Output = ((Output Max - Output Min)*(Input to be scaled - Input min.))/(Input max - Input min) +
Output Min.
0004 // In our case:
0005 // Input Min = 0, Input Max = 10, Output min = 1,
0006 // Output Max = 10 and Input to be scaled is Kp (Proportional gain from Pot)
0007 #kpp := (((10.0 - 1.0)/(10.0 - 0.0))*(#Kp - 0.0))+ 1.0;
0008
0009 //Error
0010 #error := #"Set Point" - #SENSOR;
0011
0012 //Proportional Control
0013 #u := #error * #kpp;
0014
0015 //Output
0016 #"Filling Valve" := #u;
0017 #"Drain Valve" := - #u; // SP = 50% and Level is 100%
0018
0019

Symbol Address Type Comment


#"Drain Valve" Real
#"Filling Valve" Real
#"Set Point" Real
#error Real
#Kp Real Proportional Gain
#kpp Real proportional gain
#SENSOR Real
#u Real
Totally Integrated
Automation Portal

Program blocks / System blocks


Program resources
This folder is empty.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy