Siemens LOGO! 8: Scaling a 4–20 mA Hydrostatic Pressure Sensor to Weight (kg)
1. Problem Overview
This reference covers a recurring field application: a Siemens LOGO! 8 base module (e.g. 6ED1052-1MD08-0BA2) with an analog expansion (AM2 / AM2 RTD) reads a hydrostatic 4–20 mA pressure transducer mounted at the bottom of an irregularly shaped process tank. The PLC must:
- Acquire the loop current at the AI channel.
- Convert the raw 0–1000 LOGO! count into engineering units (mbar, then cm H₂O).
- Apply a non-linear weight transfer function that accounts for a conical bottom followed by a rectangular and then a square cross-section.
- Optionally compensate for material density (water vs. dye / color concentrate).
- Select between two tanks and several stored density profiles.
- Display the resulting kilogram value on the integrated LOGO! HMI / TD.
Field experience shows that most accuracy issues with this topology are caused by two compounding factors: the LOGO! native resolution (effective ~800 counts across 16 mA) and the choice of a pressure range that does not match the hydrostatic head actually developed at fill height. Both are addressed below before any ladder or FBD logic is built.
2. Hardware Prerequisites
| Component | Catalog Number | Notes |
|---|---|---|
| LOGO! 8.3 base module (230RCE / 24RCE / 12/24RCE) | 6ED1052-1MD08-0BA2 / 1FB08-0BA2 | Onboard AI on 12/24 variants only; 230 V variants have no native AI |
| LOGO! AM2 analog input module | 6ED1055-1MA00-0BA2 | 2 AI, 0–10 V or 0/4–20 mA, 12-bit, 250 Ω sense |
| LOGO! AM2 RTD | 6ED1055-1MD00-0BA2 | If PT100/PT1000 also required |
| Hydrostatic pressure transmitter | Vendor-specific, e.g. IFM PN7 / WIKA A-10 / Endress+Hauser Waterpilot | Select span per Section 3; 2-wire loop-powered preferred |
| LOGO! Soft Comfort | ≥ V8.4 (matches firmware 1.82.x) | Programming environment |
| LOGO! TD or LOGO! TDE display | 6ED1055-4MH08-0BA2 / 6ED1055-5MH08-0BA2 | Optional; integrated display supports 6 lines × 16 chars |
Verify the AM2 datasheet input type dip-switch setting (positions 1 and 2 on the underside of the module) for current mode before commissioning. Default factory position is voltage.
3. Sensor Sizing — The Single Most Important Decision
Hydrostatic head for a liquid of density ρ at height h is:
P (mbar) = h (cm) × ρ (g/cm³) × 9.80665 / 10
For water at 20 °C (ρ = 0.998 g/cm³) this simplifies to 1 cm H₂O ≈ 0.979 mbar. A 2 m full-level water column produces ~195.8 mbar. A 250 mbar transmitter therefore covers a full-scale head of ~2.55 m of water, comfortably matching a 2 m working tank with margin. A 400 mbar transmitter only reaches ~4.08 m, wasting nearly 50 % of the available span and forcing the live tank to operate between 4.92 mA and ~12 mA — the exact symptom reported in the field discussion (a filled tank produced ~12 mA instead of the expected 20 mA).
| Tank Full Height | Material | ρ (g/cm³) | Required Sensor Span | Recommended Span (1.2×) |
|---|---|---|---|---|
| 2.0 m | Water | 1.00 | 196 mbar | 250 mbar |
| 2.0 m | Dye / color concentrate | 1.20 | 235 mbar | 400 mbar (minimum) |
| 2.0 m | Brine (25 % NaCl) | 1.20 | 235 mbar | 400 mbar |
| 2.0 m | Glycerine 60 % | 1.24 | 243 mbar | 400 mbar |
4. Native LOGO! Resolution — Why 0–1000 Counts Is Not Enough
The AM2 analog front-end always digitises on a 0–20 mA native span. LOGO! then maps that span into the integer range 0–1000. Consequence for a 4–20 mA sensor:
| Loop Current | LOGO! Native Count | Engineering Value |
|---|---|---|
| 0 mA | 0 | Sensor fault / open loop |
| 4 mA | 200 | Live-zero (empty tank) |
| 12 mA | 600 | Mid-scale |
| 20 mA | 1000 | Full scale |
Only 800 counts are available across the 16 mA span. The recommended remedy is the LOGO! Analog Amplifier (FB B042) with GAIN = 5 and OFFSET = −1000, which transforms the 0–1000 input into a 0–4000 working range. Each LSB then equals one part in 4000 of sensor full scale — five times the resolution of the raw count.
Amplifier FB B042
Sensor Type : 0–20 mA (4 mA live-zero)
Sensor Min : 4
Sensor Max : 20
GAIN : 5
OFFSET : -1000
Output Range : 0 … 4000 units (0 = empty, 4000 = full sensor span)
5. Configuring the AM2 Input in LOGO! Soft Comfort
- Add the AM2 expansion in the project tree. The base module auto-detects it on power-up.
- Open Properties > Analog Inputs and select
AI1 = 0–20 mA(the LOGO! UI does not offer a separate 4–20 mA setting — the live-zero offset is implemented in software, not the dip switch). - Set Smoothing to 8–16 samples for tanks exposed to pump pulsation; lower for fast batch response.
- Route the AI value into Analog Amplifier B042 as shown in Section 4.
6. Non-Linear Tank Geometry — Piecewise Linear Compensation
The user's tank comprises three sections:
Reported calibration points (water-equivalent height shown as % of amplifier output, weight in kg):
| Section | Height (cm) | Δh (cm) | ΔW (kg) | Δkg/cm | Comment |
|---|---|---|---|---|---|
| 1 — Cone bottom | 0 → 20 | 20 | 0 → 2000 | 100 | Non-linear; diameter grows linearly with h |
| 2 — Rectangular | 20 → 40 | 20 | 2000 → 5000 | 150 | Linear; constant cross-section |
| 3 — Square | 40 → 60 | 20 | 5000 → 9200 | 210 | Linear; larger cross-section |
Although each geometric section is theoretically non-linear (cone area = π·r²·h, where r scales linearly with h), the empirical kg-per-cm slope at the bottom of a cone is small and grows with h. A three-segment piecewise-linear approximation is adequate if the user calibration (Section 8) is performed with sufficient anchor points (≥ 5 per section).
7. Function-Block Architecture for Piecewise Conversion
LOGO! Soft Comfort supports the FBD language natively. The recommended architecture reuses three instances of Analog Multiplexer B021 plus three instances of Analog Arithmetic B030 / B036 to implement a 3-segment piecewise-linear transfer function.
AI1_raw (0–1000)
│
└──► [B042 Amplifier] GAIN=5, OFFSET=-1000 ──► AI_eng (0–4000)
│
┌──────────────────────────────────────────────────────────────┘
▼
[B003 Threshold Tr. #1] On = AI_eng ≥ 0 (Section 1 active)
[B003 Threshold Tr. #2] On = AI_eng ≥ 800 (Section 2 active)
[B003 Threshold Tr. #3] On = AI_eng ≥ 1600 (Section 3 active)
│
▼
[B021 Analog Mux #1] sel = threshold #1 → output = AI_eng × K1 + O1 (slope 2.0)
[B021 Analog Mux #2] sel = threshold #2 → output = AI_eng × K2 + O2 (slope 3.0)
[B021 Analog Mux #3] sel = threshold #3 → output = AI_eng × K3 + O3 (slope 4.2)
│
▼
[B009 Message Text] displays current weight on LOGO! HMI / TD
For each section the constants K and O are derived from the empirical kg-vs-cm anchors:
Section 1 (0–20 cm → 0–2000 kg):
K1 = 100 kg/cm (slope)
O1 = 0 (offset)
Section 2 (20–40 cm → 2000–5000 kg):
K2 = 150 kg/cm
O2 = -1000 (continuity correction: 2000 − 150×20)
Section 3 (40–60 cm → 5000–9200 kg):
K3 = 210 kg/cm
O3 = -3400 (continuity correction: 5000 − 210×40)
If the tank is wider in the upper region than these calcs assume, increase the number of segments — LOGO! supports up to 8 instances of B021 per scan for a single input.
8. Empirical Calibration Procedure
Because the cone-section slope is geometrically non-linear, never rely on hydrostatic calculation alone. Use this procedure after the sensor is installed and the tank is clean:
- Power the loop and verify open-tank current = 4.00 mA ± 0.02 mA (use a Fluke 789 or equivalent). If offset is non-zero, apply OFFSET correction in B042 until AI_eng reads 0 at empty.
- Add the first calibrated increment of material (e.g. 200 kg). Record the resulting AI_eng value. Repeat in 5–10 steps through full scale.
- Plot AI_eng (x) versus kg (y). Fit a piecewise-linear curve in 3 segments (Sections 1–3).
- Enter the resulting slopes and offsets into the B021 instances.
- Verify against the original calibration weights.
For dye or brine, repeat the procedure with the actual process fluid. Each material changes both the hydrostatic gain (slope) and the empty-tank offset slightly because the wetted sensing face is below the static fluid level.
9. Density / Material Selection Logic
To switch between materials, add a 4-position digital selector wired to LOGO! inputs I1, I2, I3, I4 and use the combination to enable one of four Analog Gain/Offset FB (B042) instances that scale the slope from kg_water to kg_material:
Material index M (1 = water, 2 = dye, 3 = brine, 4 = glycerine)
│
▼
[B042 Instance A] GAIN = K_water / ρ_water (e.g. 100 / 1.00 = 100)
[B042 Instance B] GAIN = K_water / ρ_dye (e.g. 100 / 1.20 = 83.3)
[B042 Instance C] GAIN = K_water / ρ_brine (e.g. 100 / 1.20 = 83.3)
[B042 Instance D] GAIN = K_water / ρ_glycerol(e.g. 100 / 1.24 = 80.6)
│
▼
[B021 4:1 Mux] selected by I1–I4 → drives the message text block
When the material selector changes, the displayed weight updates immediately because all four paths are evaluated every LOGO! scan (typical scan period 8–40 ms with one AM2 attached).
10. Multi-Tank Selection (Two Tanks, One LOGO!)
The user's hardware uses two AI channels of one AM2 for two tanks. Because the AM2 is multiplexed between its two inputs, only one channel is converted per scan, but both are read every other scan (~100 ms total cycle). Routing is straightforward:
- AI1 → Big tank path
- AI2 → Small tank path
- Selector input (e.g. I5) routes the desired AI to the message-text block via a 2:1 analog mux (B021).
Because both tanks share a single set of B042 / B021 instances, isolate the geometry constants per tank by creating two complete sub-circuits and using the selector to route one of them to the display. This keeps the program readable and avoids interaction between the two scale curves.
11. HMI / Message-Text Configuration
- Insert FB B009 (Message Text). Use the helper dialog to define:
- Up to 4 lines of text per message block.
- The block can display up to 1 analog value via the embedded
Value:field. - Configure the source as the output of the B021 multiplexer so the kg value updates with selection.
- Enable Acknowledge only for alarm states (e.g. AI_eng < 0 or > 4000).
- Set Bar graph option if a level bar is desired in addition to the kg readout.
Sample message text content (plain ASCII, 16 chars per line):
Line 1: BIG TANK #1
Line 2: MAT: DYE 1.20
Line 3: WEIGHT: xxxx kg
Line 4: AI: xxxx / 4000
12. Commissioning Checklist
| Step | Expected Result | Pass/Fail |
|---|---|---|
| Sensor powered, loop unbroken | AI_eng reads 0 at empty tank | |
| Tank half-filled with water | AI_eng ≈ 1000 (within ±10) | |
| Tank filled to known weight 2000 kg | HMI shows 2000 ± 10 kg | |
| Material selector changed to dye | Weight = water-weight × (1.00 / 1.20) | |
| Tank selector toggled | HMI label switches BIG/SMALL and AI source switches AI1/AI2 | |
| Sensor disconnected | AI_eng = 0 (live-zero alarm visible) | |
| Sensor short-circuited | AI_eng = 4000 (over-range alarm) |
13. Troubleshooting Matrix
| Symptom | Root Cause | Diagnostic | Remediation |
|---|---|---|---|
| HMI reads 0 kg permanently | Wrong AM2 dip-switch position (still on voltage) | Measure AI pin voltage → if > 1 V with current loop, switch to current | Power-cycle AM2 after switch change |
| HMI reads negative weight | Sensor live-zero < 4 mA, or GAIN/OFFSET miswired | Verify AI_eng = 0 at empty; OFFSET in B042 should be −1000 for ×5 amplifier | Adjust OFFSET or insert a B007 subtraction to clamp |
| HMI saturates at 9200 kg too early | Sensor over-ranged, hydrostatic head exceeds cell span | Check loop current at full fill; should be ≤ 19 mA | Re-rate sensor to next standard range (e.g. 400 mbar) |
| ±40–80 kg noise per reading | Insufficient span usage; sub-range resolution loss | Compute (window_mA / 16) × 4000 → should exceed 2500 | Use higher span sensor; or enable LOGO! analog smoothing |
| Section 1 (cone) reading off by 5 % | Empirical slope K1 derived from 1 anchor point only | Add anchors at 5, 10, 15, 20 cm and refit piecewise | Re-run Section 8 calibration with ≥ 4 anchors per section |
| HMI label flickers between tanks | Selector input bouncing; no debounce | Inspect I5 with LOGO! online monitor | Add ON-delay B004 (200 ms) on I5 |
| LOGO!Soft Comfort shows red dots on FB connections | Block types mismatch (analog vs digital) | Click red dot → check data type | Insert B042 or B003 to convert |
14. Optimization Tips
- Smoothing: LOGO! 8 has a built-in smoothing factor on each AI (1–16). Use 4 for water (settles ~200 ms), 8 for viscous dye.
- Scan time: With one AM2 attached, LOGO! scan ≈ 8 ms; with two AM2s, ≈ 12 ms. This is far below the response time of a hydrostatic sensor, so no further optimization is needed.
- Hidden shortcuts (the green arrow symbols): In FBD view, a green arrow denotes an implicit connection. Toggle View > Show connections to render as solid lines for documentation or printout.
- Firmware: Use LOGO! 8.3 firmware ≥ 1.82.x (released Q4 2020). Earlier firmware (LOGO! 8 FS4 and below) limits analog blocks to 8 instances per program; the 8.3 release removes this restriction.
-
Backup: Always export the project as
.lmaafter commissioning —.lscis editable but.lmais the binary file actually loaded to LOGO!.
15. Frequently Asked Questions
Why does my LOGO! show 0–1000 instead of 0–250 mbar directly from the 4–20 mA input?
LOGO! AM2 always converts on a 0–20 mA internal span and maps the result into the integer range 0–1000. Use the Analog Amplifier FB (B042) with GAIN = 5 and OFFSET = −1000 to recover a usable 0–4000 unit range that you can then scale into mbar or kg. Direct engineering-unit display is not supported at the AI level.
My hydrostatic sensor is 0–400 mbar but I only see ~12 mA at full tank. Is the sensor broken?
No. 400 mbar full scale corresponds to roughly 4 m of water column. If your tank is only 2 m tall, the head at full fill is ~196 mbar, producing about 4 mA + (16 mA × 196/400) = 11.84 mA. Either accept the loss of upper span or replace the sensor with a 250 mbar cell. The error is sensor-range mismatch, not a fault.
How do I implement a non-linear cone tank in FBD without writing custom math?
Use multiple instances of Analog Multiplexer (B021) gated by Analog Threshold Trigger (B003) blocks. Each B021 path contains its own slope (GAIN) and offset constants specific to one geometric section, producing a piecewise-linear approximation that is more than adequate for the 1–2 % accuracy typical of hydrostatic weighing.
Can I switch between two tanks and three materials with one LOGO! 8 + AM2?
Yes. The AM2 provides two independent AI channels; route each to its own scaling sub-circuit and use digital inputs with an Analog Multiplexer (B021) to select which scaled value reaches the HMI Message Text block (B009). Materials are similarly selected by re-routing the gain path through density-corrected B042 instances.
What accuracy can I realistically achieve with a 4–20 mA sensor on LOGO!?
With a properly ranged sensor and ×5 amplification, the effective resolution is one part in 4000, or ±0.025 % of full scale. Field accuracy is dominated by sensor repeatability (typically 0.1–0.3 % FS), temperature drift (0.5–1 % / 10 K typical for low-cost cells), and the slope-fitting error of the piecewise-linear conversion. Plan for ±0.5 % to ±1 % of full scale as a realistic total error budget.
How do I keep the FBD diagram readable when there are many connections?
Hide implicit connections by enabling View > Show connections or View > View as Ladder for documentation. Use named connector blocks (B004 / B005) to label signal nets and split long bus connections across multiple pages of the diagram. Keep each tank's sub-circuit on its own page so per-tank constants are obvious during troubleshooting.