Back
Module06
Title

Tank level in STL

Synthetic Course: written to test the Site template, from no Professor's material

Worked examples

TopicTank level in STL
Title

The tank's volume from its level transmitter

ExampleW06.1
Step1 / 4
Mode
Given
Given

An S7-300 reads a horizontal cylindrical tank's level transmitter at PIW 256 and works out the volume, network by network, in the STL listing below. For each raw value, fill in the corrected value in MW 20, the level hh, the wetted area AA and the volume VV.

  • r=1.0 mr = 1.0\ \text{m}, tank length 4.0 m4.0\ \text{m}
  • raw 00 to 2764827648 is empty to full
  • zero-point offset 200200
Each network in turn, three raw values
PIW 256MW 20hhmAAm²VVl
67126912
1362413824
2053620736

Correct the zero point

Network 1 adds the offset with +I+I: 13624+200=1382413624 + 200 = 13824. An INT sum past 3276732767 would wrap and set OV, which latches M 1.2.
Sim

The tank listing, running

Set the level transmitter's raw value and the switches, then step a statement or run a whole scan. The trace shows the accumulators, AR 1, the status word and every byte each statement writes.

  1. ORGANIZATION_BLOCK OB 1
  2. TITLE = Horizontal cylindrical tank: level to volume
  3. // Tank radius r = 1.0 m, length 4.0 m.
  4. // PIW 256: level transmitter, 0..27648 = empty..full (-27648..27648 if I 0.1 = bipolar).
  5. // MD 60..72: four volume set-points in litres, written by the HMI.
  6. BEGIN
  7. NETWORK
  8. TITLE = 1 Zero-point correction
  9. L PIW 256 // raw level from the analog module
  10. L 200 // zero-point offset found at commissioning
  11. +I // INT add: wraps past 32767 and sets OV
  12. T MW 20 // corrected raw level
  13. A OV // did the addition overflow?
  14. S M 1.2 // latch: offset overflow alarm
  15. NETWORK
  16. TITLE = 2 Scale to metres with FC105
  17. CALL FC 105
  18. IN :=MW20
  19. HI_LIM :=2.000000e+000 // full = tank diameter, 2.0 m
  20. LO_LIM :=0.000000e+000 // empty = 0.0 m
  21. BIPOLAR:=I0.1
  22. RET_VAL:=MW22 // W#16#0008 = input out of range
  23. OUT :=MD24 // level h in metres
  24. NETWORK
  25. TITLE = 3 Wetted cross-section: A = r2 acos(d/r) - d sqrt(2rh - h2)
  26. L 1.000000e+000 // r = 1.0 m
  27. T MD 12
  28. L MD 12
  29. L MD 24
  30. -R // d = r - h
  31. T MD 44
  32. L MD 12
  33. /R // d / r
  34. ACOS // half the wetted angle, rad
  35. L MD 12
  36. SQR // r squared
  37. *R
  38. T MD 48 // r2 acos(d/r)
  39. L MD 12
  40. L 2.000000e+000
  41. *R // 2r
  42. L MD 24
  43. *R // 2rh
  44. L MD 24
  45. SQR // h squared
  46. -R
  47. ABS // clears -0.0 when h = 0 or h = 2r
  48. SQRT // half the chord
  49. L MD 44
  50. *R // d sqrt(2rh - h2)
  51. T MD 52
  52. L MD 48
  53. L MD 52
  54. -R // wetted area A, m2
  55. T MD 28
  56. NETWORK
  57. TITLE = 4 Volume in litres
  58. L MD 28
  59. L 4.000000e+000 // tank length 4.0 m
  60. *R
  61. L 1.000000e+003 // m3 to litres
  62. *R
  63. T MD 32 // volume V, litres
  64. NETWORK
  65. TITLE = 5 Level band: how many set-points has V passed?
  66. L 0
  67. T MW 36 // band := 0
  68. LAR1 P#60.0 // AR1 -> first set-point, MD 60
  69. L 4 // four set-points
  70. NEXT: T MW 38 // loop counter
  71. L MD 32 // volume
  72. L MD [AR1,P#0.0] // set-point under AR1
  73. >R
  74. JCN SKIP
  75. L MW 36
  76. L 1
  77. +I
  78. T MW 36 // band := band + 1
  79. SKIP: +AR1 P#4.0 // next set-point
  80. L MW 38
  81. LOOP NEXT
  82. L MW 20
  83. L 10
  84. *I // tenths of a count, 32 bits, for the trend log
  85. T MD 40
  86. NETWORK
  87. TITLE = 6 Alarms, latched until I 0.0 acknowledges
  88. A I 0.0 // acknowledge button
  89. R M 1.0
  90. R M 1.1
  91. R M 1.2
  92. L MW 22 // RET_VAL from FC105
  93. L 0
  94. <>I
  95. S M 1.0 // latch: level signal out of range
  96. L MW 36 // level band
  97. L 4
  98. >=I
  99. S M 1.1 // latch: above the high-high set-point
  100. O M 1.0
  101. O M 1.1
  102. O M 1.2
  103. = Q 4.1 // common alarm lamp
  104. NETWORK
  105. TITLE = 7 High-volume lamp (exam trap)
  106. A I 0.2 // pump running: opens a logic string ...
  107. L MD 32
  108. L 1.000000e+004
  109. >R // ... but a compare writes RLO outright
  110. = Q 4.0 // so Q 4.0 = (V > 10 000 l), whatever I 0.2 is
  111. END_ORGANIZATION_BLOCK

Scan 1 · statement 113 of 113

Statement111 BE
ACCU 110000.016#461C_4000
ACCU 26283.185516#45C4_597C
AR 1P#76.0
  • /FC0
  • RLO0
  • STA1
  • OR0
  • OS0
  • OV0
  • CC01
  • CC10
  • BR?

A ? is left by FC105: Siemens doesn't publish what the block leaves there, so the trace doesn't guess until a statement writes it.

Writtennothing
OperandValue
MW 2013824
MW 22W#16#0000
MD 241.0
MD 281.5707964
MD 326283.1855
MW 362
MD 40L#138240
Q 4.00
Q 4.10
M 1.00
M 1.10
M 1.20
LineStatementACCU 1RLO
9L PIW 256136240
10L 2002000
11+I138240
12T MW 20138240
13A OV138240
14S M 1.2138240
17CALL FC 105??
26L 1.000000e+0001.0?
27T MD 121.0?
28L MD 121.0?
29L MD 241.0?
30-R0.0?
31T MD 440.0?
32L MD 121.0?
33/R0.0?
34ACOS1.5707964?
35L MD 121.0?
36SQR1.0?
37*R1.5707964?
38T MD 481.5707964?
39L MD 121.0?
40L 2.000000e+0002.0?
41*R2.0?
42L MD 241.0?
43*R2.0?
44L MD 241.0?
45SQR1.0?
46-R1.0?
47ABS1.0?
48SQRT1.0?
49L MD 440.0?
50*R0.0?
51T MD 520.0?
52L MD 481.5707964?
53L MD 520.0?
54-R1.5707964?
55T MD 281.5707964?
58L MD 281.5707964?
59L 4.000000e+0004.0?
60*R6.2831855?
61L 1.000000e+0031000.0?
62*R6283.1855?
63T MD 326283.1855?
66L 00?
67T MW 360?
68LAR1 P#60.00?
69L 44?
70T MW 384?
71L MD 326283.1855?
72L MD [AR1,P#0.0]1000.0?
73>R1000.01
74JCN SKIP1000.01
75L MW 3601
76L 111
77+I11
78T MW 3611
79+AR1 P#4.011
80L MW 3841
81LOOP NEXT31
70T MW 3831
71L MD 326283.18551
72L MD [AR1,P#0.0]3000.01
73>R3000.01
74JCN SKIP3000.01
75L MW 3611
76L 111
77+I21
78T MW 3621
79+AR1 P#4.021
80L MW 3831
81LOOP NEXT21
70T MW 3821
71L MD 326283.18551
72L MD [AR1,P#0.0]10000.01
73>R10000.00
74JCN SKIP10000.01
79+AR1 P#4.010000.01
80L MW 3821
81LOOP NEXT11
70T MW 3811
71L MD 326283.18551
72L MD [AR1,P#0.0]12000.01
73>R12000.00
74JCN SKIP12000.01
79+AR1 P#4.012000.01
80L MW 3811
81LOOP NEXT01
82L MW 20138241
83L 10101
84*IL#1382401
85T MD 40L#1382401
88A I 0.0L#1382400
89R M 1.0L#1382400
90R M 1.1L#1382400
91R M 1.2L#1382400
92L MW 2200
93L 000
94<>I00
95S M 1.000
96L MW 3620
97L 440
98>=I40
99S M 1.140
100O M 1.040
101O M 1.140
102O M 1.240
103= Q 4.140
106A I 0.241
107L MD 326283.18551
108L 1.000000e+00410000.01
109>R10000.00
110= Q 4.010000.00
111BE10000.00