You are on page 1of 10

WinCC V7

TASK 9 - DESCRIPTION

SIMULATION SCRIPT

We have done step-by step a simple SCADA System for water treatment
system. Anyway now we make some fun and create simulation in SCADA's
scripts so we can train our skills what we have learned during WinCC
SCADA Level1 course and we can make our visualization alive.

In this case i use the StaticText to make it running continuously. Each


properties of elements that are on screen are running with cyclic scan so
we can set 1s, 2s, upon change trigger for that. Let's leave default =
2seconds (our script under static text will run every 2 seconds). 

We could use also  button with vbscript or global action to get same result =
script running.

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

At the TOP we have one text = SIMULATION IN PROGRESS. This text we


show only when tag simulation is 1.

To show this text in first line you see:

hmiruntime.Tags("SIMULATION").Write(1)

After that in script we put some Dim and into this prepared tags we read
values from analog signals from system (flow1, flow2 and tank_level)

Dim flow1
flow1 = HMIRuntime.Tags("Flow1.VALUE").read
Dim flow2
flow2 = HMIRuntime.Tags("Flow2.VALUE").read
Dim level
level = HMIRuntime.Tags("Tank_level.VALUE").read

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

Below script's fragment is preparing data for out Depth_pump. Every time
we turn ON this pump script is changing speed value to display on screen.
If this pump is running we can also simulate flow counting. Look if flow
values is less than 60 we just adding 1 to show progress and if our flow is
greater we take 6 to make our simulations looks "live".
After calculation script is updating Flow1.Value to show this on screen and
log data to archiving system.

if HMIRuntime.Tags("Depth_pump.STATUS").Read = 1 Then
HMIRuntime.Tags("Depth_pump.OUT_PV").Write(100)
If flow1 < 60 Then
flow1 = flow1+1
Else
flow1 = flow1-6
End If

HMIRuntime.Tags("Flow1.VALUE").Write(flow1)

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

Next we simulate Water_pump running. So after pump is running we can


also update value of flow2. This simulations is simplest because we can put
same value for flow2 as flow1. Everytime we take water by depth_pump
and our water pump is running we should have near same values on bot
flow meters right?
Anyway if our water_pump is not running so we put value 0 to show that
there is not water flow in pipes.

if our depth pump is not running we have 2 lines to make .STATUS =0 and
Flow1 = 0 (to show our depth_pump is OFF on screen).
In our situation os simulation water_pump should work always.

If HMIRuntime.Tags("Water_pump.STATUS").Read = 1 Then
HMIRuntime.Tags("Flow2.VALUE").Write(flow1)
Else
HMIRuntime.Tags("Flow2.VALUE").Write(0)
End If
Else
HMIRuntime.Tags("Depth_pump.OUT_PV").Write(0)
HMIRuntime.Tags("Flow1.VALUE").Write(0)
End If

HMIRuntime.Tags("Water_pump.STATUS").write(1)
'HMIRuntime.Tags("Water_pump.OUT_PV").Write(100)

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

After water_pump is runnig we have fragment that calculate our


tank_level to show our tank is filled with water or not. Everytime our
water_pump speed is 100 we take 100 and if water pump is not running in
100 % we take 40 (slower or faster water leak).

If HMIRuntime.Tags("Water_pump.OUT_PV").Read = 100 Then


level = level - 100
Else
level = level - 40
End If

Script below is changing valves status to mak water flow in  pipes. So if we
have enough flow in flow1 we set aerator ON and OPEN 2 vales.

if flow1 > 20 Then


HMIRuntime.Tags("Aerator.STATUS").Write(1)
HMIRuntime.Tags("F1_Z1.STATUS").Write(1)
HMIRuntime.Tags("F1_Z4.STATUS").Write(1)
End If

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

After water_pump is runnig we have fragment that calculate our


tank_level to show our tank is filled with water or not. Everytime our
water_pump speed is 100 we take 100 and if water pump is not running in
100 % we take 40 (slower or faster water leak).

If (HMIRuntime.Tags("F1_Z1.STATUS").Read And
HMIRuntime.Tags("F1_Z4.STATUS").read ) Then
If level < 9000 Then
level = level + 90
End If
HMIRuntime.Tags("Tank_level.VALUE").write(level)
End If

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

Below we have fragment of script that helps us to close or turn OFF


equipment when we have alarm in any element in our system. So after we
have ALARM we write to status (0) which means closed/turned off.

If HMIRuntime.Tags("Depth_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Depth_pump.STATUS").Write(0)
End If

If HMIRuntime.Tags("Aerator.ALARM").Read = 1 Then
HMIRuntime.Tags("Aerator.STATUS").Write(0)
End If

If HMIRuntime.Tags("Air.ALARM").Read = 1 Then
HMIRuntime.Tags("Air.STATUS").Write(0)
End If

If HMIRuntime.Tags("Purging_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Purging_pump.STATUS").Write(0)
End If

If HMIRuntime.Tags("Severs_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Severs_pump.STATUS").Write(0)
End If

If HMIRuntime.Tags("Water_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Water_pump.STATUS").Write(0)
End If

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

FULL SCRIPT:

hmiruntime.Tags("SIMULATION").Write(1)

Dim flow1
flow1 = HMIRuntime.Tags("Flow1.VALUE").read
Dim flow2
flow2 = HMIRuntime.Tags("Flow2.VALUE").read
Dim level
level = HMIRuntime.Tags("Tank_level.VALUE").read

If HMIRuntime.Tags("Depth_pump.STATUS").Read = 1 Then
HMIRuntime.Tags("Depth_pump.OUT_PV").Write(100)
If flow1 < 60 Then
flow1 = flow1+1
Else
flow1 = flow1-6
End If
HMIRuntime.Tags("Flow1.VALUE").Write(flow1)
If HMIRuntime.Tags("Water_pump.STATUS").Read = 1 Then
HMIRuntime.Tags("Flow2.VALUE").Write(flow1)
Else
HMIRuntime.Tags("Flow2.VALUE").Write(0)
End If
Else
HMIRuntime.Tags("Depth_pump.OUT_PV").Write(0)
HMIRuntime.Tags("Flow1.VALUE").Write(0)
End If

HMIRuntime.Tags("Water_pump.STATUS").write(1)
'HMIRuntime.Tags("Water_pump.OUT_PV").Write(100)

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

If HMIRuntime.Tags("Water_pump.OUT_PV").Read = 100 Then


level = level - 100
Else
level = level - 40
End If

If flow1 > 20 Then


HMIRuntime.Tags("Aerator.STATUS").Write(1)
HMIRuntime.Tags("F1_Z1.STATUS").Write(1)
HMIRuntime.Tags("F1_Z4.STATUS").Write(1)
End If

If (HMIRuntime.Tags("F1_Z1.STATUS").Read And HMIRuntime.Tags("F1_Z4.STATUS").read


)Then
If level < 9000 Then
level = level + 90
End If
HMIRuntime.Tags("Tank_level.VALUE").write(level)
End If

"You can't repair the world with just one SCADA"


WinCC V7
TASK 9 - DESCRIPTION

If HMIRuntime.Tags("Depth_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Depth_pump.STATUS").Write(0)
End If

If HMIRuntime.Tags("Aerator.ALARM").Read = 1 Then
HMIRuntime.Tags("Aerator.STATUS").Write(0)
End If

If HMIRuntime.Tags("Air.ALARM").Read = 1 Then
HMIRuntime.Tags("Air.STATUS").Write(0)
End If

If HMIRuntime.Tags("Purging_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Purging_pump.STATUS").Write(0)
End If

If HMIRuntime.Tags("Severs_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Severs_pump.STATUS").Write(0)
End If

If HMIRuntime.Tags("Water_pump.ALARM").Read = 1 Then
HMIRuntime.Tags("Water_pump.STATUS").Write(0)
End If

Generally this script is making for us simulation just to show us out


SCADA is running with some values.
In HMI / SCADA programming - SIMATIC WinCC V7 (level 2) we will use
PLC/ PLC simulation to perform all simulations from real life projects.

"You can't repair the world with just one SCADA"

You might also like