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

|| Seetaram ||

NOV-08 :
● New Project: IOT_OPC
● Device type: Siemens S7-1515-2 PN
● Defining Ethernet Address
● Protection and Security(Full Access)
● Connection Mechanisms: Enable
Permit access with PUTGET
communication from remote partner.
● Add New Block: Data Block: Global DB
(ex: To_OPC)
○ I_Start_PB - Bool
○ I_Stop_PB - Bool
○ I_RPM - Int
○ O_Motor_Run - Bool
● To_OPC > Properties > Optimised
block access > Compile the block
● Create a Logic into Main (OB1) using
already created data block.
○ DB1 . DBX0.0 - Single bit
○ DB1.DBB10 - While byte
○ DB1.DBW20 - Byte 20, Byte 21
(Word, Int, UInt)
○ DB1.DBD30 - Byte 30, Byte 31,
Byte 32, Byte 33 (Real, DInt,
UDInt)
● Net2PLC Sim: Add Server (Select
active adapter) > Start PLC > Start
Server
● Network Address: ex: 192.168.29.238
(PLC Server) will be use for further
applications.
● KEPWare ServerEX 6: Entire feature
will be installed.
● SQL Express Advanced 2016 >>
Express Advanced
● SQL Server Management Studio
(SSMS 2016)
● KEPAware: > Connectivity >> Add a
channel >> Siemens TCP/IP Ethernet
>> Give Name >> Select Active
Adapter >> Add
○ Add a static Tag into the create
channel.
◆ ex: start_pb > Address >
DB1.DBX0.0 (Refer to the
PLC Logic) > Ok
◆ ex: stop_pb > Address >
DB1.DBX0.1 (Refer to the
PLC Logic) > Ok
◆ ex: motor_state > Address
> DB1.DBX0.2 (Refer to
the PLC Logic) > Ok
◆ ex: motor_rpm > Address
> DB1.DBW2 (Refer to the
PLC Logic) > Ok
○ Reinitialise, Check for errors
○ Click on “Quick Connect” >
Check the Tag Status > Quality
should be “Good”
○ Right Click on any Tag using
Quick Connect(QC) (ex:
start_pb)> Synchronous Write….
> Write Value > 1
○ When value changing from the
KEPServerEX > QC: It should
change the value inside PLC
○ This way we can connect the
multiple PLC into the KEPWare
and can manipulate them.
○ From here Data Acquisition part
has been started.
● TIA >> PLC Data Types >> Add New
Data Type >> User Data Type >> This
will be custom data type containing
whole structure/parameters related to
the Structure
● User Data Type: Name of the
DataType: Ex: Motor
○ I_Start - Bool
○ I_Stop - Bool
○ I_RPM - Int
○ O_Motor_Run - Bool
● Here we defined a custom data type
named “motor” containing a structure
of various parameters related to the
motor itself.
● Now since we created a new Data type
names “motor” we can call it inside the
Data Block > Create a new variable
with data type “Motor”
● Replace all the tags of the previous
logic from the newly created User Data
Type parameters.
● PLC >> Right click >> Call Structure of
PLC_01 >> Left to Right and Top to
Bottom
● Call Function Block with newly created
logic using UDT.
● If in case of Function Block we need to
expose the variable to the user: We
need to use the local variables inside
the function
● But in that case input UDT and Output
UDT should be different.
● We need to create state chart, need
to break the whole operations logic
into pieces .
○ Improve Algorithm, concept.
○ Check all the separate
operations errors through
SCADA, HMI manually before
automating. Do error proofing
manually. Then create a new FC
Block at last. Write whole
operation in here and where are
added the manual trigger, add a
bit below that and call them
state,
○ ex.
○ State 1 = Component present
○ State 2 = Conveyer ready for run
○ State 3 = Conveyer Running
○ State should be based on closed
feedback.
○ Visio: for creating State Chart
● For Full Project Execution:
○ First you have proper RFP. You
study it.
○ For controls:
○ Mechanical designs should be
ready.
○ Ex. Conveyer pick and place.
○ Infra design should exist or
should freeze atleast.
○ See the electrical components
○ Sensors
○ Field devices and then controls:
○ What I/o disk is required.
○ Which PLC need to be used
○ How many input
○ How many outputs
○ How many analogue
○ SLD
○ Drawing
○ Then we go to programming.
⸻⸻⸻⸻

NOV-09 :
● There are following Three methods to
do communication between PLC to
PLC:
. PN-PN Coupler: It completely
isolates both PLCs. Network
Isolation:YES + Logic
Isolation:YES
. GET PUT: Network Isolation:NO
but Logical Isolation: YES
. Master / Slave: No Type of
Isolation (If we defined I0.0 in
one then we can’t define the I0.0
into another PLC)
Ex: Seimens PLC of both Vendor
◆ But different IP series:
(172.92.XX and 192.
168.X.X)
◆ Then we match ICD on
both
◆ We put PN-PN Coupler
between them
◆ Both are completely
isolated with each other.
◆ You shared some bits. Ex.
You have a Motor
◆ We will give the run
command. You tell that
your motor ran.
⸻⸺
● CNC Acquisition:
○ Fanuq, Siemens
⸻⸺
● Data Type: Default Value (Start Value)
==> When DB initialise then Start
Value automatically put the Start Value
into the Variable. If We will not
reinitialise then It will not pick the old
value.

● In each 2 hour:
– Services.msc ⸺> KEPSERVER
EX Key Services : Restart
service in order to keep using
the OPC

⸻—

● If we want to derive the UnSigned and


Signed Values of no of bits then:
Ex: 1 1 1 1 1 1 1 1 : 255 (Unsigned)
0 1 1 1 1 1 1 1 : 128 (Signed)
( -127 to 127 )
Remove First 1 and then find the decimal
value that will be the Signed

● (In Case of INTEGER)


Ex: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1: 65,535 (Unsigned)
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1: 32,767 (Signed) ( -32,767 to 32,767 )
Remove First 1 and then find the decimal
value that will be the Signed

● Analogue Input Card 12 Bit (It will only


take till 4095): If you will take 16 Bit
Value it will be reduced to 12 Bit, which
will lead to the garbage value
⸻⸻
● SQL EXPR ADV 64 bit : Installation >>
Install SQL Server Management Tools
>> Disable Firewall >> Disable R
Services >> Enable Local DB >>
Default Instance >> Mixed Mode (SQL
Server Authentication and Windows
Authentication )
○ Enter Password: Microsoft#1234
>> Install and Configure
○ Install SSMS 2016 :
SSMS_Setup_ENU >> Microsoft
SQL Server Management Studio
>> Install
○ Open SSMS for creating the
Database and Tables
○ Open ODBC and create >> Add
>> SQL Server >> Finish >>
ODBC_Name
○ With SQL Server authentication
using a Login ID and password
entered by the user.
○ Connect to SQL Server to obtain
default settings for the
additional configuration options.
○ Login ID:
○ Password:
○ Change the default database:
Select the database >> Next >>
Finish >> Test
○ In the KEPWare Configuration
software:
◆ Data Logger >> Add Log
Group >> Add DSN
(ODB01) into Data Source
(You can also browse the
same)
◆ Add Username and
Password
◆ Table Selection >> Create
a New Table and always
append to this table
◆ Add New Table Name
◆ Narrow Table
◆ New Log Item :
◆ Add New : Item ID
(Select using the
browser)
◆ Triggers: Double
click on the trigger
>> Always Trigger.
◆ Reinitialise the
KEPAware
◆ Refresh the table at
SSMS:
◆ Data can be seen on the
SQL Table on the basis of
the defined trigger.
○ WIDE Table
○ Narrow vs Wide:
◆ Narrow All parameters on
the single column (Less
prone to failure)
◆ Wide all parameters on
the separate column :
Which lead to the change
in schema for the newer
data very frequently.
● Connectivity : New Channel >> ODBC
Client >> Browse Data Source >>
○ Create new device as Generic
>> Fixed Table
○ On SSMS creating new table set
a schema (ex: c1: nchar(10), c2:
nchar(10)) add value heres c1: A,
c3: B
○ In KEPWare : Select that table
>> All values fetched
○ Go to Advanced Tag: Type >>
Link >> Add a plc Tag as Input
and add a ODBC Table tag as a
output c1 >> On Data change
○ Reinitialise
○ See SQL Table and check values
>> PLC Values should be
updated into the Table as a
String
⸻⸻

NOV-10 :
● So far we have seen that how from
various PLC data can be either read
and put it on the another Database, or
How to write data to PLC. Narrow and
Wide Table.
● Suppose there is Manufacturing
Executive System (MES) installed and
there are multiple SCADAs and we
need to send data from SCADA to MES
system. So how scads will work with
our OPC.
● PLC to PLC communication.
● We can open 2 simulator at same time
and can do communication between
both of them. Both will have different
IP.
● Suppose 100 of Things, and we take a
ring network then it keeps getting
complicated.
○ We defined PLCs + 20 remote
stations (aka RIUs) >> Then we
converted RIUs to RING
Topology.
○ So now 1 network defined as
RING. Rest 80 devices (Things)
will also be keep running without
any issues.
○ Now we put one managed
Switch in each Remote Station.
○ Now rest 80 Devices we
converted the Topology to STAR.
(In each RIU we put 5-6 things
and converted them into STAR.)
○ Now suppose any component
from the Ring got failed then the
devices we connected in Star
into that RIU will only get failed.
Rest of the devices will work. So
the risk factor will reduce.

● If we need to use the logic and flush it


then we use FC, if we want to retain
the Values in a data block we use FB.
● Restart KEPWare Key Services in every
2 hours.
● Inside the KEPWare Quick connect
>> ._System >> System_Error : if 1
then “Error” if “0” then NO Error.
● Diagnostics: Enable diagnostics >>
Channel >> Properties >> Enable
Diagnostics | right click on the device
>> Diagnostics
● KEPWare: Advanced Tag >
○ Open SSMS >> Create New
Table inside a Database.
○ start_button : bit | stop_button :
bit | output_motor_run : bit |
rpm : int
○ run Query : Select * from
<table_name>
○ INSERT into <table_name>
(start_button, stop_button,
output_motor_run, rpm) values
(1,0,1,100)
○ Go to KEPWare: Link all the tags
of PLC with the newly created
Table
◆ KEPWare >> Connectivity
>> Create new Channel
>> ODBC Driver >> Create
new Device >> Browse
that Table: >> Give Write
Access >> Finish
◆ Runtime >> Reinitialise
◆ Advanced Tags : : Type
(Link)
◆ For Inputs (Table to
PLC) > Add table
tags | Outputs : Add
PLC Tags
◆ For Output [PLC to
Table ] (Example :
Motor Run State) :
input > Add PLC
Tag | Output Add
Table Tag
◆ Reinitialise
◆ Run Query on the
SSMS : UPDATE
<table_name> SET
start_button = 1,
stop_button = 0,
rpm = 1197
◆ Now PLC will
change the value as
we run the Query.
◆ Similarly 2 PLCs
can interchange
data using the
Advanced Tags.
(Any two party can
communicate with
each other by an
defined
relationship)
⸻⸻

NOV-14 :
● So far we have seen that how to
monitor the cyclic data in some
frequency.
● Now our concern is that if we are going
to start the Batch, and there are
numerous parameters. And we want to
transfer all the parameters to the PLC
or want to log that.
● Data Logging:
○ in data logging we need to put
into the database. suppose we
started a batch, and there are
some starting parameters and
we want to restore them with
time stamping.
○ Create a New DataBlock in TIA.
(for trigger base data logging.)
◆ p1 : int | p2 : int | p3 : int |
p4 : int | p5 : int | trigger:
boolean (when this trigger
fire only then data will log)
◆ Retain Value: value will
retain as long as no other
value pushes, even after
the power restore | Offset
will be use a address
value
◆ Data Block >> Right Click
>> Properties >>
Attributes >> Disable
Optimised Data Block
◆ Save >> Download
◆ Start Net2PLC
◆ Start PLC Sim
◆ Restart KEPAware Key
Service
◆ In KEPWare >> Right click
on Device >> Export >>
Save File >> Open File >>
Edit
◆ p1 :
DB2.DBW0 : short :
1 : R/W : 100
◆ p2 :
DB2.DBW2 : short :
1 : R/W : 100
◆ p3 :
DB2.DBW4 : short :
1 : R/W : 100
◆ p4 :
DB2.DBW6 : short :
1 : R/W : 100
◆ p5 :
DB2.DBW8 : short :
1 : R/W : 100
◆ trigger :
DB2.DBW10 :
boolean : 1 : R/W :
100
◆ In KEPWare >> Select the
same device >> Import
CSV >> All Tags will be
imported……
◆ Check Tag Status in Quick
Client >> Good Status
◆ Data Logger >> DSN
(Browse) >> Create a new
Table once and always
append to it. >> Create
Name
“Trigger_DL_table“…. >>
Add Log Items >> Item ID
one by one
◆ Trigger >>
Properties:
Condition Based >>
Item ID (trigger)
◆ Column Mapping
will add as soon as
we keep adding the
login items.
◆ Right click on the
all the Column
Mapping Items and
Select the
appropriate tags in
the Value Field
◆ Trigger >> Start
Condition >> Select
Trigger Tag >> Item
data set equal to a
specific value = 1
>> Optional not
required (Log All
item on Start : No |
Log all Items on
Stop : No) | Stop
Condition : Select
Trigger Tag >> Item
data set equal to a
specific value = 0
◆ Logging
Conditions :
Monitor Items : Yes
| Monitor Item Id :
Select trigger tag
here
◆ Enable Data Logger
>> Check if
increasing on the
trigger value = 1
◆ Trigger >> Start
Condition(When
this will fire then
data will log) + Stop
Condition (When
this will fire data
STOP logging.) >>
Logging Condition:
Static Interval > No
| Monitor Item : Log
All Items : Yes |
Monitor Item Id :
Select the same
trigger.
⸻⸻

NOV-16 :
SCADA to SQL >> SQL to SCADA
● Open TIA
● Create a new Project
● Add New Device >> PC System
(SCADA) >> PC General >> PC Station
● Now we need to add component into
that PC
● Communication Modules >> IE General
(Drag to the PC Station)
● SIMATIC HMI Application >> WinCC RT
Professional / WinCC RT Advanced
● Go to Network View >> We need to
established an HMI Connection
● Click on Connections >> HMI
Connections
● Right click on the PLC and click on the
“Add New Connection”
○ PLC 1 , Profinet interface_1 [X1] /
PLC 1 , Profinet interface_1 [X2]
(Click on Any one)
○ Close….. New connection
created
○ Click on Network
○ Click on the PLC X1 Port (Right
Side if X1 selected) and then
click on the PC Station port and
connect both by dragging and
dropping
○ We can define the IP (Already
setup)>>> Properties >>
Enternet X1 >> Ethernet Address
⸻⸻

NOV-17 :
● Open HMI RT >> Go To Screen >> Add
New Screen
○ Ex: Add Buttons and HMI Tags
related to the PLC Logic on
Motor Start Stop RPM….. Link it
with PLC Tag
○ On Button Press SetBit / On
Release : Reset
○ Set Animation Attribute to Color
for Motor run Parameter…. >>>
ON OFF…
○ Open KEPAware
○ Add Channel >> ODBC Client
>> Name (Scada) >> Data
Source (ODBC Data Source) >>
Finish
○ Create Table >> Start / Stop >>
Open SSMS >> Create a Table
>> start : bit | stop : bit |
motor_status : bit >> Save
○ Default In Table >> Start : 0,
Stop : 0, Motor_status : 0
○ Open KepWare >> Add a new
device >> Table Selection :
(Increase Login Timeout) >>
Scada_Table >> Write Access:
Enable >> Finish
○ ReInitialise
○ Open TIA >> HMI >>
Connections >> <Add new> >>
Name: Scada_Connection,
Communication Drive : OPC
○ In the Parameter >> OPC Server
>> Local Server >> Select
KEPAware
○ HMI(SCADA) >> Default Tag
Table >> Scada_Start >> HMI
Connection (Select
SCADA_Connection) >>
Address :: Scada01 ::: Select
Start, Stop, Status
○ Ex: We have Scada System, We
got 10-12 Torque Tool, We need
data logged into SQL >> We can
log the data through SCADA…..
(Torque Tool License + Data
Logger License )… in order to
reduce the cost we can use this
method :
○ In SCADA we created the
buttons + input/output box >>
Buttons We need to browse >>
Tag SCADA_Start / Tag
SCADA_Stop /
Scada_Motor_RUN
○ Open SSMS Database >> Now
we change the value in SQL DB
then these value will be change
in SCADA too.
○ For the Motor Run Button
instead of Click we will put the
value on Press >> Tag
(Scada_Motor_Run)
● Driver / Advanced Tags / Alarms and
Events (Separate license need to be
purchase : Vendor : Sarla Tech India)
● Reporting Services config Manager
(Run as Admin)
○ Service Account, Web URL
(Double click on the shown URL
here )
○ Web Portal URL : Click the link
here to open in browser
○ SQL Server Reporting Services :
Opened >> Manage Folder >>
Check Security Rights
○ SSDT 2012 download SQL
Server Data Tools
◆ Helps to represent the
Data looked via SQL DB,
etc….
◆ Installation: Next
>>>>>>> Install >>> Next
◆ Open SQL Server Data
Tools >> Select C# Visual
Studio >> New Projects
>> Report Server Project
◆ right click on the Reports
>> Add New Reports
◆ New Data Source >> Edit
>> SQL Server Credential
>> Select Table >> Next
>> Query Builder >> Add
Table
◆ Select Any Data Logging
Table >> for the less data
>> in SSDT go to Datasets
>> Right Click >> Query
>> Add SELECT TOP (100)
etc… for less data load. >
ReBuild >> Deployed….
◆ Displayed Field (Add
Columns) >> Next >>
Finish >> Preview >>
Properties >> Pasted the
copied Report Server URL
(ex: desktop-……../
ReportServer) >> OK
◆ Open Report Server URL
Again >> Click on the
Report1 >> Report will
displayed here
◆ In TIA create a new
Screen for Report Display
◆ From Controls >> Drag
Report Element to HMI >>
Put the URL and Report
will be displayed here in
SCADA
⸻⸻

NOV-20 :
● VBScript :
○ Add a new Script in VBScript
folder in TIA Left Pane inside
HMI_RT….
○ ………. SCRIPT GOES HERE………
Dim com, record, SQLtable
Set com =
CreateObject("ADODB.Connection")
Set record =
CreateObject("ADODB.Recordset")
com.Open =
"Provider=MSDASQL;Initial
Catalog=TIA17;DSN=TIA;UID=;PWD=;"
SQLtable = “INSERT INTRO
TIA_Log(Operator, Temperature,
Pressure, WaterLevel)
Values(‘“&SmartTags(“Operator_Name
”)&”’);”
Set record =
com.Execute(SQLtable)
com.close
Set com = Nothing
Set record = Nothing
End Sub
○ ………. SCRIPT ENDS HERE………
○ Open ODBC Data Sources >>
Create a new DSN called “TIA”
○ Default Database: TIA17 (We
created this using the SQL
Server Management Studio)
○ In ODBC Data Source >> Ok >>
Finish >> Test Data Source >>
OK
○ We created a table inside The
TIA17 DB in SSMS >>
DateAndTime : datetime |
Operator : nvchar(50) |
Temperature : float | Pressure :
float | WaterLevel : float
○ INSERT Command, UPDATE
Command, using HMI button and
input and put it into the
Database, Or use the SQL Table
recipe, Data to Database, PLC to
HMI Tags,
○ HMI Tags >> Default Tags
○ RECIPE MANAGEMENT INTO:
Data Updating and Data Retrieve
○ Create new PLC Device
○ PLC Right Click >> Properties >>
ENABLE SIMATIC Clock
Memories >> MB1 (by default) :
Locked for system memory bits
(First Cycle : M1.0, Diagnostics
status changed: M1.1, Always
1(high): M1.2, Always 0(low):
M1.3)
○ ENABLE Clock Memory Bits :
MB0 (by default) >> 10Hz clock :
M0.0, 5 Hz Clock : M0.1, 2.5 Hz :
M0.2, 2 Hz Clock: M 0.3, 1.25 Hz
Clock: M0.4 : Flip-flops like On-
OFF (1 Hz = )
○ So if you enabled the clock as
describe above you can’t use
any address related to these
Memories (by default : M0, M1)
○ Pulses good for Counting and
Timers
○ If we retain these Memory Bits
then value will also retain in DB.
○ P_TRIG : Called Positive Edge
(Raise On), Negative Edge (Fall
On)
○ Created the Function Block to
simulate Pressure, Temperature,
Level by using the Clock,
P_TRIG, ==, and MOV Blocks
○ Local variables used : Pulse,
Actual_Val, Set_Val, Initial_Val,
Enable, Achieved_Val, Pulse_Trig
○ Retain Value on DB: Ex: ENABLE,
Set_Val, Initial_Val, Val_Achieved
○ Make Changes in DB not directly
in PLC
○ Put HMI Values in PLC:
◆ We will pick 1st Record
from SQL:
◆ record.MoveFirst
◆ Create Tags in HMI
linked with FB local
vars:
◆ Create new
connection:
Device and
Networks >>
Right click on
PLC >> Add
A New
Connection
◆ Whatever
port you
choose you
should create
the
connection
using that
port only:
◆ Click
and
Add
◆ Click
on
Networ
k >>
Drag
PN to
That’s
Numbe
red
port
(X1 or
X2)
◆ Compil
e/
Downlo
ad
◆ Conne
ction
PLC
port
should
be
same
in
Networ
k too
◆ Now
you
can
browse
the Tag
◆ HMI Tags:
◆ Set_Te
mperat
ure :
Browse
>>
Progra
m
Block
>> All
DB
related
to
Temp,
Pressu
re,
Level
FB will
be
visible
here,
Select
the
related
tags in
each
DB >>
Temp :
Set_Va
l
◆ Set_Pr
essure
:
Pressu
re :
Set_Va
l
◆ Set_Le
vel :
Level :
Set_Va
l
◆ In SQL
Table :
Suppo
se
there
are
followi
ng
column
s:
◆ D
a
t
e
A
n
d
T
i
m
e
(
0
)
,
O
p
e
r
a
t
o
r
(
1
)
,
T
e
m
p
e
r
a
t
u
r
e
(
2
)
,
P
r
e
s
s
u
r
e
(
3
)
,
W
a
t
e
r
L
e
v
e
l
(
4
)
◆ T
h
e
n
r
e
c
o
r
d
.
F
i
e
l
d
s
(
0
)
w
il
l
b
e
D
a
t
e
A
n
d
T
i
m
e
◆ Select HMI
Smart Tag
(Ex:
SmartTags(“S
et_Temperatu
re”)=record.F
ields(2).Value
)
◆ SmartTags(“S
et_Pressure”)
=record.Field
s(3).Value
◆ SmartTags(“S
et_Level”)=re
cord.Fields(4
).Value
◆ Add New
Inputs in HMI
to SET the
Updated
Value
◆ From HMI
>>>
Database
◆ Database
>>> PLC
⸻⸻

NOV-22 :
● XYZ MOTORS >> MODEL List
○ Vehicle Code
○ Inside the HMI Default Tag:
◆ Model_Number >> Type:
Int
◆ Vehicle_Code >> String
◆ Create Button
◆ We need to create a Table
“Model_Master” in SSMS:
◆ Model_Name: int |
Code_Name:
nvchar(50) |
DateAndTime :
datetime
◆ Create a INSERT Script in
which by using the HMI
we can insert the Model
Number(Model Name),
Vehicle_Code
◆ Another Table will be of
Receipe_Master >>
Model_Name : int | p001:
int, p002:int, p003:int,
p004:int, p005:int,
DateTime: datetime
◆ Recipe Master :
Parameters related to the
Particular Model Name
◆ It’s is related to the family
not from the Variant.
◆ Tag: R_Model_Number :
int
◆ p1: int | p2: int | p3: int |
p4: int | p5: int
◆ we will scan the variant
>>> will fetch the
associated Model Number
>> Will fetch the
parameter associated with
that Model Number >>>
will load these parameters
to the PLC

⸻⸻

NOV-24 :
● Adding the value only if Value is being
put by the User.
● When value is being put by user: Then
Its shows :Entry successfully added
and <Model_Name> is added.:
● Item list should fetched by the SQL
using HMI, Entry should be edited,
added by the HMI, Fetch the updated
SQL into the dropdown. We should
also get the value to known which
value is being selected.

⸻⸻

NOV-27 :
● Mitsubishi : GS Work3 + GT Designer
(for HMI/Graphics Operational
Terminal)
● About Gantry (GUDEL)
● MCB Toggle Loto device (MCB with
KeyLock)
● Rockwell Studio 5000 ver above 30,
● Visual Studio Community 2022
● S7.NetPlus Library for C# PLC
Communications
● using S7.Net;
using S7.Net.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace S7Sample
{
class Program
{
static void Main(string[] args)
{
using (var plc = new
Plc(CpuType.S71500, "127.0.0.1", 0, 1))
{
plc.Open();

UInt32 db1Bool2 =
(UInt32)plc.Read("DB2.DBD0");
UInt32 db1Va

01:05:18.035,01:05:21.035
pradeep kaushal: UInt32 db1Bool2 =
(UInt32)plc.Read("DB2.DBD0");
UInt32 db1Var = db1Bool2;
plc.Write("DB2.DBD4", db1Var);

Console.WriteLine("DB2.DBD0:" +
db1Bool2);
}
Console.ReadKey();
}
}
}

⸻⸻

DEC-03 :
● C# Code Review using S7NetPlus
● PN PN Coupler
● We will make communication between
2 PLCs
● Create 2 PLC
○ Properties >> Protection and
Security >> Full Access
○ Connection Mechanisms >>
Permit access with PUT/GET
communication from remote
partner (On Both PLC)
○ Create 2 DBs on each PLC as
follows: (Structure should be
same)
◆ Write/Read for PLC 1
(P2P_PLC01_Input +
P2P_PCL01_Output) ==
Format should be same
◆ Write/Read for PLC2
(P2P_PLC02_Input +
P2P_PCL02_Output) ==
Format should be same
◆ In of PLC1 will be Out for
PLC2
◆ P2P_PLC02_Output1 +
P2P_PLC01_Input1
(int01:int | int02:int |
int03:int | int04:int) >>
Properties >> Uncheck
Optimise block access
◆ P2P_PLC02_Input1 +
P2P_PLC01_Output1
(val01:int | val02:int |
val03:int | val04:int |
val05:int | val06:int |
val07:int | val08:int |
val09:int) >> Properties
>> Uncheck Optimise
block access
◆ Open OB of a PLC
◆ ⸺[PUT Block]⸻—
◆ Req: PUT_DB.REQ
◆ Done:
PUT_DB.DONE
◆ Error:
PUT_DB.ERROR
◆ Status:
PUT_DB.STATUS
◆ ⸺[GET Block]⸻—
◆ Req: GET_DB.REQ
◆ Done:
GET_DB.DONE
◆ Error:
GET_DB.ERROR
◆ Status:
GET_DB.STATUS
◆ Click on Start Config icon
◆ Select LocalPLC
and Partner PLC
◆ It will fetch all
details
◆ Device and Network
>> Network >> Join
both PLC by using a
line
◆ Block Parameters :
Write Area
(ADDR_1): Example
we are into 1st PLC.
Then in this we will
put Partner PLC
Start
(PLC2_Output:
DB3.DBX0),
Length : 5 (5
integer)
◆ We will send from
PLC1: Send Area :
DB2.DBX0.0 |
Length: 5 | Int (Self
DB of Input which
exactly matches in
format with Partner
DB of output)
◆ Similarly We will put
the GET Block:
◆ connection
parameters :
READ AREA:
PLC2_Input1
(DB6.DBX0.0
) | Length: 9 |
Int
◆ STORE AREA:
Self PLC
Output
(DB5.DBX0.0
) | Length: 9 |
Int
◆ Create SET/RESET :
PUT_DB.REQ (we
need to reset if
error or done bit) in
parallel so that it
keeps running
◆ Same for GET :
GET_DB.REQ(NC),
GET_DB.ERROR,
Get_DB.NDR
◆ Download Run both
PLC (Green should
be visible on both
PLC (no ORANGE))
◆ Open Both DB
(Input of One PLC ,
Output of Another
PLC)
◆ If we change one
value then it
immediately
reflected in another
PLC DB
◆ We are using the
SET/RESET to
continuously
flipping/flopping the
Bit to keep getting
request.

⸻⸻

DEC-07 :
● AWS IoT
○ SignUp >> Sign In to AWS
Console:
○ All Devices >> Things >> Create
Things >> Create Single Things
>> KEP_thing01(Thing Name) >>
No Shadow
○ Next >> Auto Generate the
Certificates >> Create Policy >>
Policy_Name: Kep_Pol01
○ Policy_effect >> Allow
○ Policy Action >> *
○ Policy resources >> *
○ Create Things
○ Download the provided >>
Certificate, Public Key, Private
Key, Root CA certificates
○ Click on KEP_Thing01 >> Intract
>> View Settings >> EndPoint
API (copy to notepad)
○ Restart KEPWare Key Service
○ Open KepWare Ex
◆ Connectivity >> Create
new channel >> simulator
>>> Next …… >> Finish
◆ Create New Device1 >>
Address: KG01 | Default |
Read/Write >> Ok
◆ IoT Gateway >> Add Agent
>> MQTT1 >> Next >>
URL : ssl://
<paste_copied_link>:888
3
◆ Timeout : 20
◆ “Topic: iotgateway”
◆ Next >> Client ID(Name
OF Things : KEPThing01 in
AWS )
◆ Finish
◆ right Click on MQTT1 >>
Security >> Client
Certificate >> Enable
◆ Message >> Advanced
Templete >> Apply >> Ok
◆ Add Item >>
Channel1>>Device 01 >>
KG01 (Select Apply)
◆ Scan Rate : 5000
◆ Every Scan >> OK
○ Download 32 Bit GRE if missing
and installed
○ KEPWAre >> Settings >> IoT
Gateway >> Manage Certifcates
>> Import New Certificates >>
Select Private Key
○ Ok >> Close >> Reinitialise
○ <Connected to Broker>
○ AWS >> Test >> MQTT Test
Client >> Topic >> iotgateway…..
○ In KEPWare >> click on QC >> if
you will change the value here it
will reflect in AWS
○ Right click on MQTT >> Client
>> Topic (This topic name we
will put here for reading the
data)
○ Message : Format mention here
in which data will push.
● For Publish the Things Data:
MQTT >> Subscriptions >> Listen to
the write Request : Yes
Topic :: iotgateway/write
○ AWS >> Publish to a topic >>
Message Payload >> [{“id”:”
Channel.Device.KG01”,”v”:42}]
○ Put all tag into 1 gateway >>
subscribe to that topic >> Data
will start coming in Cloud
⸻⸻

You might also like