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 , the wetted area and the volume .
- , tank length
- raw to is empty to full
- zero-point offset
| PIW 256 | MW 20 | m | m² | l |
|---|---|---|---|---|
| 6712 | 6912 | |||
| 13624 | 13824 | |||
| 20536 | 20736 |
Correct the zero point
Network 1 adds the offset with : . An INT sum past 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.
ORGANIZATION_BLOCK OB 1TITLE = Horizontal cylindrical tank: level to volume// Tank radius r = 1.0 m, length 4.0 m.// PIW 256: level transmitter, 0..27648 = empty..full (-27648..27648 if I 0.1 = bipolar).// MD 60..72: four volume set-points in litres, written by the HMI.BEGINNETWORKTITLE = 1 Zero-point correctionL PIW 256 // raw level from the analog moduleL 200 // zero-point offset found at commissioning+I // INT add: wraps past 32767 and sets OVT MW 20 // corrected raw levelA OV // did the addition overflow?S M 1.2 // latch: offset overflow alarmNETWORKTITLE = 2 Scale to metres with FC105CALL FC 105IN :=MW20HI_LIM :=2.000000e+000 // full = tank diameter, 2.0 mLO_LIM :=0.000000e+000 // empty = 0.0 mBIPOLAR:=I0.1RET_VAL:=MW22 // W#16#0008 = input out of rangeOUT :=MD24 // level h in metresNETWORKTITLE = 3 Wetted cross-section: A = r2 acos(d/r) - d sqrt(2rh - h2)L 1.000000e+000 // r = 1.0 mT MD 12L MD 12L MD 24-R // d = r - hT MD 44L MD 12/R // d / rACOS // half the wetted angle, radL MD 12SQR // r squared*RT MD 48 // r2 acos(d/r)L MD 12L 2.000000e+000*R // 2rL MD 24*R // 2rhL MD 24SQR // h squared-RABS // clears -0.0 when h = 0 or h = 2rSQRT // half the chordL MD 44*R // d sqrt(2rh - h2)T MD 52L MD 48L MD 52-R // wetted area A, m2T MD 28NETWORKTITLE = 4 Volume in litresL MD 28L 4.000000e+000 // tank length 4.0 m*RL 1.000000e+003 // m3 to litres*RT MD 32 // volume V, litresNETWORKTITLE = 5 Level band: how many set-points has V passed?L 0T MW 36 // band := 0LAR1 P#60.0 // AR1 -> first set-point, MD 60L 4 // four set-pointsNEXT: T MW 38 // loop counterL MD 32 // volumeL MD [AR1,P#0.0] // set-point under AR1>RJCN SKIPL MW 36L 1+IT MW 36 // band := band + 1SKIP: +AR1 P#4.0 // next set-pointL MW 38LOOP NEXTL MW 20L 10*I // tenths of a count, 32 bits, for the trend logT MD 40NETWORKTITLE = 6 Alarms, latched until I 0.0 acknowledgesA I 0.0 // acknowledge buttonR M 1.0R M 1.1R M 1.2L MW 22 // RET_VAL from FC105L 0<>IS M 1.0 // latch: level signal out of rangeL MW 36 // level bandL 4>=IS M 1.1 // latch: above the high-high set-pointO M 1.0O M 1.1O M 1.2= Q 4.1 // common alarm lampNETWORKTITLE = 7 High-volume lamp (exam trap)A I 0.2 // pump running: opens a logic string ...L MD 32L 1.000000e+004>R // ... but a compare writes RLO outright= Q 4.0 // so Q 4.0 = (V > 10 000 l), whatever I 0.2 isEND_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
| Operand | Value |
|---|---|
| MW 20 | 13824 |
| MW 22 | W#16#0000 |
| MD 24 | 1.0 |
| MD 28 | 1.5707964 |
| MD 32 | 6283.1855 |
| MW 36 | 2 |
| MD 40 | L#138240 |
| Q 4.0 | 0 |
| Q 4.1 | 0 |
| M 1.0 | 0 |
| M 1.1 | 0 |
| M 1.2 | 0 |
| Line | Statement | ACCU 1 | RLO |
|---|---|---|---|
| 9 | L PIW 256 | 13624 | 0 |
| 10 | L 200 | 200 | 0 |
| 11 | +I | 13824 | 0 |
| 12 | T MW 20 | 13824 | 0 |
| 13 | A OV | 13824 | 0 |
| 14 | S M 1.2 | 13824 | 0 |
| 17 | CALL FC 105 | ? | ? |
| 26 | L 1.000000e+000 | 1.0 | ? |
| 27 | T MD 12 | 1.0 | ? |
| 28 | L MD 12 | 1.0 | ? |
| 29 | L MD 24 | 1.0 | ? |
| 30 | -R | 0.0 | ? |
| 31 | T MD 44 | 0.0 | ? |
| 32 | L MD 12 | 1.0 | ? |
| 33 | /R | 0.0 | ? |
| 34 | ACOS | 1.5707964 | ? |
| 35 | L MD 12 | 1.0 | ? |
| 36 | SQR | 1.0 | ? |
| 37 | *R | 1.5707964 | ? |
| 38 | T MD 48 | 1.5707964 | ? |
| 39 | L MD 12 | 1.0 | ? |
| 40 | L 2.000000e+000 | 2.0 | ? |
| 41 | *R | 2.0 | ? |
| 42 | L MD 24 | 1.0 | ? |
| 43 | *R | 2.0 | ? |
| 44 | L MD 24 | 1.0 | ? |
| 45 | SQR | 1.0 | ? |
| 46 | -R | 1.0 | ? |
| 47 | ABS | 1.0 | ? |
| 48 | SQRT | 1.0 | ? |
| 49 | L MD 44 | 0.0 | ? |
| 50 | *R | 0.0 | ? |
| 51 | T MD 52 | 0.0 | ? |
| 52 | L MD 48 | 1.5707964 | ? |
| 53 | L MD 52 | 0.0 | ? |
| 54 | -R | 1.5707964 | ? |
| 55 | T MD 28 | 1.5707964 | ? |
| 58 | L MD 28 | 1.5707964 | ? |
| 59 | L 4.000000e+000 | 4.0 | ? |
| 60 | *R | 6.2831855 | ? |
| 61 | L 1.000000e+003 | 1000.0 | ? |
| 62 | *R | 6283.1855 | ? |
| 63 | T MD 32 | 6283.1855 | ? |
| 66 | L 0 | 0 | ? |
| 67 | T MW 36 | 0 | ? |
| 68 | LAR1 P#60.0 | 0 | ? |
| 69 | L 4 | 4 | ? |
| 70 | T MW 38 | 4 | ? |
| 71 | L MD 32 | 6283.1855 | ? |
| 72 | L MD [AR1,P#0.0] | 1000.0 | ? |
| 73 | >R | 1000.0 | 1 |
| 74 | JCN SKIP | 1000.0 | 1 |
| 75 | L MW 36 | 0 | 1 |
| 76 | L 1 | 1 | 1 |
| 77 | +I | 1 | 1 |
| 78 | T MW 36 | 1 | 1 |
| 79 | +AR1 P#4.0 | 1 | 1 |
| 80 | L MW 38 | 4 | 1 |
| 81 | LOOP NEXT | 3 | 1 |
| 70 | T MW 38 | 3 | 1 |
| 71 | L MD 32 | 6283.1855 | 1 |
| 72 | L MD [AR1,P#0.0] | 3000.0 | 1 |
| 73 | >R | 3000.0 | 1 |
| 74 | JCN SKIP | 3000.0 | 1 |
| 75 | L MW 36 | 1 | 1 |
| 76 | L 1 | 1 | 1 |
| 77 | +I | 2 | 1 |
| 78 | T MW 36 | 2 | 1 |
| 79 | +AR1 P#4.0 | 2 | 1 |
| 80 | L MW 38 | 3 | 1 |
| 81 | LOOP NEXT | 2 | 1 |
| 70 | T MW 38 | 2 | 1 |
| 71 | L MD 32 | 6283.1855 | 1 |
| 72 | L MD [AR1,P#0.0] | 10000.0 | 1 |
| 73 | >R | 10000.0 | 0 |
| 74 | JCN SKIP | 10000.0 | 1 |
| 79 | +AR1 P#4.0 | 10000.0 | 1 |
| 80 | L MW 38 | 2 | 1 |
| 81 | LOOP NEXT | 1 | 1 |
| 70 | T MW 38 | 1 | 1 |
| 71 | L MD 32 | 6283.1855 | 1 |
| 72 | L MD [AR1,P#0.0] | 12000.0 | 1 |
| 73 | >R | 12000.0 | 0 |
| 74 | JCN SKIP | 12000.0 | 1 |
| 79 | +AR1 P#4.0 | 12000.0 | 1 |
| 80 | L MW 38 | 1 | 1 |
| 81 | LOOP NEXT | 0 | 1 |
| 82 | L MW 20 | 13824 | 1 |
| 83 | L 10 | 10 | 1 |
| 84 | *I | L#138240 | 1 |
| 85 | T MD 40 | L#138240 | 1 |
| 88 | A I 0.0 | L#138240 | 0 |
| 89 | R M 1.0 | L#138240 | 0 |
| 90 | R M 1.1 | L#138240 | 0 |
| 91 | R M 1.2 | L#138240 | 0 |
| 92 | L MW 22 | 0 | 0 |
| 93 | L 0 | 0 | 0 |
| 94 | <>I | 0 | 0 |
| 95 | S M 1.0 | 0 | 0 |
| 96 | L MW 36 | 2 | 0 |
| 97 | L 4 | 4 | 0 |
| 98 | >=I | 4 | 0 |
| 99 | S M 1.1 | 4 | 0 |
| 100 | O M 1.0 | 4 | 0 |
| 101 | O M 1.1 | 4 | 0 |
| 102 | O M 1.2 | 4 | 0 |
| 103 | = Q 4.1 | 4 | 0 |
| 106 | A I 0.2 | 4 | 1 |
| 107 | L MD 32 | 6283.1855 | 1 |
| 108 | L 1.000000e+004 | 10000.0 | 1 |
| 109 | >R | 10000.0 | 0 |
| 110 | = Q 4.0 | 10000.0 | 0 |
| 111 | BE | 10000.0 | 0 |