Turning Tank Level Into Volume Without Getting the Inventory Wrong
Building a strapping table into SCADA: circular-segment geometry, why 100 mm spacing is 40% wrong at 50 mm, NAMUR NE 43 fault currents that clamp to a plausible 0 L, OPC UA Part 4 deadband, and why a DP transmitter is really a mass gauge.
920 litres that were never in the tank
The day tank shows 380 mm on the level transmitter and the SCADA inventory tag says 1,470 L. The operator dips it, the tank is horizontal, and the real number is closer to 550 L. Nobody typed a bad range. The transmitter is fine, the scaling is fine, the 4–20 mA loop checked out at commissioning. What happened is that somebody scaled level to volume with a straight line, and a horizontal cylinder is not a straight line.
That's the whole problem in one sentence: level is a height, volume is a shape. They're only proportional in one case — a vertical cylinder with a flat bottom, no dished head, no internal structure. Every other tank on site needs a table.
What the geometry actually does to you
Take a real vessel: 2.5 m diameter, 6 m long, horizontal, ignoring the heads for now. Full shell volume is about 29.4 m³.
Fill it to 5% of the diameter — 125 mm of liquid in the bottom. The wetted cross-section is a circular segment:
A = r²·acos((r−h)/r) − (r−h)·√(2rh − h²)
V = A · L
That works out to 0.55 m³, or 1.9% of the tank. A linear scale would have reported 5%, or 1.47 m³. You've invented 920 litres of product out of arithmetic. At the top of the tank the error flips sign — 95% level is 98.1% volume — so the tank also overflows earlier than the inventory screen suggests.
The middle is where linear scaling looks fine and lulls people into keeping it. At half full, the segment formula and the straight line agree exactly. So the tag validates beautifully at the one point everybody checks and is worst at the two points that matter: nearly empty, and nearly full.
The strapping table, and why the spacing isn't uniform
A strapping table is just a list of (level, volume) pairs from a real tank calibration — manual strapping per API MPMS Chapter 2.2A, or the equivalent ISO 7507-1 method for upright cylindrical tanks, or a liquid calibration for odd shapes. You interpolate between the points. For a fabricated vessel with dished heads you want the measured table rather than a formula, because 2:1 ellipsoidal heads, a sloped bottom, an internal heating coil and a suction well are all in the real numbers and none of them are in your equation.
The tempting implementation is a uniformly spaced table — a point every 100 mm — so you can index it with integer division and skip a search. That's the right instinct in general, and it's wrong at the bottom of a horizontal tank. Here's why: the slope of the volume curve is the chord width, which near the bottom goes as √h. Its derivative blows up as h → 0, and linear interpolation error scales with that curvature.
Numbers on the same 2.5 m tank, 100 mm table spacing:
| Level | True volume | Interpolated from 100 mm table | Error |
|---|---|---|---|
| 50 mm | 141 L | 198 L | +40% |
| 1,250 mm | 14,726 L | 14,726 L | ~0 |
Don't take my numbers — get your own. This reproduces both rows above in a couple of seconds; change r, L and step to your vessel:
import math
r, L, step = 1.25, 6.0, 0.100 # radius m, length m, table spacing m
V = lambda h: (r*r*math.acos((r-h)/r) - (r-h)*math.sqrt(2*r*h-h*h))*L if 0 < h < 2*r else 0.0
for h in (0.050, 1.250):
lo = h - h % step
lerp = V(lo) + (V(lo+step) - V(lo)) * (h-lo)/step
print(f"{h*1000:6.0f} mm true {V(h)*1000:9.1f} L table {lerp*1000:9.1f} L {100*(lerp/V(h)-1):+.1f}%")
It prints +40.6% at 50 mm and +0.0% at 1,250 mm. That error is a property of your geometry and your spacing, which is why you run it before you commit to a spacing rather than after a stock count disagrees.
Mid-shell the interpolation is essentially exact. In the first interval it's off by 40%. So: cluster the table points where the curvature is — 10–25 mm steps through the bottom 10% and the top 10%, 100 mm through the straight shell. That costs you the cheap indexing trick and forces a search, which for a 60–120 point table is a handful of comparisons on a scan that has bigger problems. Take the accuracy.
Two more table rules I don't compromise on:
- Clamp, don't extrapolate. Below the first point and above the last, hold the endpoint value and set the quality bad or raise a "level out of table range" flag. Extrapolating a √h curve past its ends produces numbers that look plausible and aren't.
- The table starts at the datum the calibration used, which is usually the tank bottom or a dip plate — not the transmitter's zero. If your radar reads distance from the flange, you need reference height minus distance, and that offset belongs in one place, documented, not folded silently into the table.
There is a second reason I won't extrapolate. If level arrives as 4–20 mA, the transmitter reports faults as a current, not as a status bit. NAMUR NE 43 keeps 3.8–20.5 mA as the real measuring band and reserves ≤3.6 mA for a downscale failure and ≥21.0 mA for an upscale failure. Push those currents through a linear scale on a loop spanned 0–2,500 mm and you get this:
| Current | What NE 43 means by it | (mA−4)/16 × 2,500 | Inventory tag after clamping |
|---|---|---|---|
| 3.6 mA | downscale failure | −62.5 mm | 0 L |
| 21.0 mA | upscale failure | 2,656 mm | 29,452 L |
Both of those are plausible numbers. A broken wire reads as an empty tank and a failed sensor reads as a full one. So clamping on its own isn't enough — the clamp has to carry a bad quality with it. "Input below the table" and "genuinely sitting on the bottom table point" must not look the same on the screen.
Where the calculation lives
Three candidates, and the answer isn't "wherever it's easiest to type."
Put it in the PLC or RTU if anything automatic uses volume: a pump permissive, a batch cut-off, a transfer interlock, a high-level trip on volume rather than height. Control logic should not depend on a value computed by a supervisory system that can drop off the network.
Put it in SCADA if volume is purely for display, reporting and inventory. Most SCADA platforms have a lookup/interpolation function or an expression tag; this is what it's for. A 100-point table in a PLC eats retained memory and is painful to correct after a re-strap, whereas editing a SCADA lookup is a five-minute change with an audit trail.
Do not put it in both. The classic mess is the PLC computing volume for the interlock and SCADA computing its own from raw level with a slightly different table version. They agree for a year, someone re-straps the tank after a repair, one side gets updated, and now the trend and the trip disagree by a few hundred litres with no obvious culprit.
And don't compute it in the historian as a calculated tag if the number is used operationally. Historian calculations run on stored data — they inherit its gaps, its compression deadband and its late arrivals. Fine for a monthly inventory report, bad for anything on the operator's screen.
The density trap — a DP transmitter is a mass gauge
If level comes from a hydrostatic (DP) transmitter, you are not measuring height. You are measuring head pressure:
h = P / (ρ·g)
The device converts that to height using a fixed density ρ_c that you configured. In a vertical tank of constant cross-section the head pressure at the bottom is P = m·g/A, so the indicated level reduces to:
h_ind = P / (ρ_c·g) = m / (A·ρ_c)
There is no actual density on the right-hand side. A DP level tag is mass divided by the density you typed in — a mass reading wearing a height scale, and every density trap falls out of that one line.
The sign is easy to get backwards, so put numbers on it. Configured density 800 kg/m³, product actually received at 810 kg/m³, true level 2.000 m. The head pressure is ρ_a·g·h_a and the device divides by 800:
h_ind = (810 / 800) × 2.000 = 2.025 m
The indicated level reads 1.25% high. Denser product makes more pressure at the same height, and the device reports that as more height. Push 2.025 m through the table for the 2.5 m × 6 m tank above and you get 25,556 L against a true 25,259 L at 2.000 m: 297 L of product that isn't there, and no amount of table accuracy touches it.
Temperature is the one that catches people, because it runs the other way. Warm the product so density falls from 800 to 790 and the same mass occupies more volume, so the true level rises by 1.27%. But nothing in m/(A·ρ_c) changed — not m, not ρ_c. So in a vertical tank the indicated level does not move at all. It doesn't creep up; it sits still. The instrument stays exactly right about mass and goes 1.27% short about volume, and if your inventory is counted in volume you never get that 1.27% back.
If you actually care about inventory, this is the fork in the road:
- Volume only, product density stable — hydrostatic plus strapping table is fine. Document the configured density on the tag description so the next person knows the assumption exists.
- Volume with varying grade or wide temperature swing — go to a level technology that measures geometry, not weight: guided-wave radar or non-contact radar. Radar doesn't care what the density is.
- Mass or standard volume — that's a different job. Correcting gross observed volume to standard volume at 15 °C means volume correction factors per API MPMS Chapter 11.1 (ASTM D1250), plus tank shell thermal expansion, plus a floating-roof adjustment if there is one, all of which live in API MPMS Chapter 12.1. Do not reimplement VCF polynomials in ladder logic. That belongs in a flow computer or a tank inventory package that gets audited.
For custody transfer the whole discussion changes anyway — ISO 4266 and the API standards govern how the level and temperature are measured in the first place, and a SCADA-computed inventory number is a monitoring aid, not a ticket.
Commissioning it
Checking volume against a manual dip at one point proves nothing — as established, the middle of the tank is where every method agrees. Check it where it's hard:
- Near-empty, just above the lowest table point. This is where linear scaling and coarse tables fall apart, and where the strapping table's own accuracy is worst because a millimetre is worth almost nothing until it isn't.
- Near-full, above the shell tangent line if the tank has heads.
- Across a transfer, not absolutely. Run a known quantity in — a metered truck delivery or a timed transfer against a calibrated flow meter — and compare the change in the volume tag. Delta-volume cancels out datum and offset errors and tests the table's shape, which is the part you actually wrote.
One thing that catches people on the historian side: set the deadband on the volume tag as an absolute volume, not as a percentage. In the OPC UA Part 4 DataChangeFilter, DeadbandType is None (0), Absolute (1) or Percent (2), and Percent is computed against the node's EURange Property from Part 8 as DeadbandValue / 100 × (EURange.high − EURange.low). With an EURange of 0–29,452 L on this volume tag, "1%" means a flat 294.5 L everywhere.
The question is what 294.5 L is in millimetres of level. Near the bottom it is 82 mm; mid-shell it is 19.6 mm. One setting, four times coarser in the stretch where you are counting the last of the product. The slope says the same thing: dV/dh is chord width × length, 4.20 m² at 50 mm and 15.00 m² mid-shell, so a 5 mm level change is 21 L down there and 75 L in the middle. Use Absolute (1) with a number you can defend against the instrument's own noise.
Same reason your high-level alarm should stay on the level tag — it's protecting against overflow, which is a height, and putting it on a derived volume adds a calculation between the sensor and the trip for no benefit. ISA-18.2's rationalisation step asks you to define the operator response behind each alarm, and the response to high level is identical whether the tag reads millimetres or litres; the derived tag gains nothing and inherits every table and datum error. If the overfill protection is a safety instrumented function rather than an alarm, it stops being a preference: IEC 61511-1 expects the SIF to be independent of the basic process control system, which disqualifies a volume that SCADA computed from a lookup table SCADA also lets you edit.
The next thing to check, if the numbers still don't close: tank tilt. A vessel that settled 15 mm out of level over ten years invalidates the bottom of the strapping table long before it affects the middle, and the only fix is a re-strap — not a fudge factor in the SCADA expression, however tempting that is at month end.