1. Problem Overview
A common field scenario with the Siemens LOGO! 8 (6ED1052-xxx) is the need to apply a non-linear correction to a 4–20 mA process signal. A temperature transmitter, for example, is read on analog input AI1, scaled to engineering units, and then driven through a sensor-specific equation before being displayed or used for setpoint comparison. The LOGO! programming environment, however, imposes strict limits on the Math instruction block family, and exponential functions such as ex, ln, and log are not part of the available operator set. This article documents the exact capabilities of the LOGO! 8 Math block, the integer-only display constraint, and three engineering-acceptable workarounds: Taylor-series truncation, segmented linear interpolation via analog threshold switches, and migration to a SIMATIC S7-1200 when the application demands a true exponential result.
2. Sensor Scaling: 4–20 mA to Degrees Celsius
The transmitter in the source provides a 4–20 mA loop that represents -25 °C to +100 °C. Because LOGO! 8 analog inputs can be configured as 0–10 V or 0–20 mA, the 4–20 mA mode must be selected and the offset/subtraction must be performed in software.
| Loop current | Engineering value | Raw count (0–20 mA = 0–1000) |
|---|---|---|
| 4 mA | -25 °C | 200 |
| 12 mA | 37.5 °C | 600 |
| 20 mA | 100 °C | 1000 |
Use the LOGO! 8 Analog Amplifier block (B042) to subtract 200 and multiply by 0.125 (=(100-(-25))/(1000-200)=125/800=0.15625), producing a linear °C value on block output AQ1:
Sensor gain = (100 - (-25)) / (1000 - 200) = 0.15625 °C / count
Sensor offset = -25 - (0.15625 * 200) = -56.25 °C
Configure the Analog Amplifier with Gain = 0.15625 and Offset = -56.25. The Math block downstream of this stage now sees a true °C value that can be used inside the equation.
3. The Two Equivalent Formulations
The original poster proposes the linear approximation
X = 28 · (1 + 0.00336 · T)
and then corrects this to the exponential form
X = 28.084 · e(0.0336 · T)
These two expressions are related through the Taylor expansion of ey = 1 + y + y²/2! + y³/3! + ... truncated to its first-order term, which yields exactly 1 + y. The poster's own nine-term expansion reaches X = 249.41 for T = 65 °C, while the closed-form exponential gives X = 249.44 — a relative error of 0.012 %. The linear first-order truncation, in contrast, gives X = 34.12 at T = 65 °C, a 86 % underestimation that is not acceptable for the application.
| T (°C) | Linear X = 28·(1+0.00336·T) | Exact X = 28.084·e0.0336·T | Relative error |
|---|---|---|---|
| -25 | 25.65 | 12.13 | -111.5 % |
| 0 | 28.00 | 28.08 | -0.3 % |
| 25 | 30.35 | 64.86 | -53.2 % |
| 65 | 34.12 | 249.44 | -86.3 % |
| 100 | 37.41 | 808.50 | -95.4 % |
The exponential is the physically correct expression. The remainder of this reference shows how to realize it on hardware that does not provide a native exp() operator.
4. LOGO! 8 Math Block Capability Matrix
The current LOGO! 8 System Manual (06/2023 edition) documents the Math instruction (B043) operators as: addition, subtraction, multiplication, division, and a square-root option. Constants, AI/AQ values, and intermediate flags are valid operands. Maximum eight Math blocks per program and maximum 32 Math instructions per program (firmware 8.3 limits; verify with the live Siemens Industry Online Support portal for newer firmware).
| Operator | Supported in Math block | Notes |
|---|---|---|
| +, -, *, / | Yes | 32-bit float internally |
| SQRT | Yes (toggle in block properties) | Internal float |
| Constant (Gain/Offset) | Yes | Float value allowed in Soft Comfort |
| ex, ln, log, xy | No | No native operator |
| sin, cos, tan | No | No native operator |
| Conditional / ABS | Indirect | Use gain sign trick or two parallel blocks |
Although the internal representation is float, the LOGO! on-device display and the network variable publish range are still limited to the signed 16-bit window. For the source problem, X peaks at 808.50 (well inside ±32767), so the display limit is not a blocker — the missing exp() is.
5. Workaround 1 — Taylor Series Truncation
The exponential is approximated by N terms of the Maclaurin series:
ey ≈ Σk=0..N-1 yk / k!
For the source equation, set y = 0.0336 · T. The maximum y in the range is 0.0336 · 100 = 3.36. With seven Taylor terms the residual |R7| ≤ y7/7! = 3.367/5040 ≈ 0.47, an absolute error acceptable when the engineering tolerance of the sensor itself is ±0.5 °C equivalent.
Because LOGO! 8 cannot compute yk directly, the polynomial is pre-expanded on paper and entered as a fixed coefficient polynomial of the form
X = a0 + a1·T + a2·T² + a3·T³ + a4·T⁴ + ...
with the coefficients scaled to avoid sub-0.001 constants. The example below uses a scaling factor of 10000 so that the Math block can work in integer-friendly arithmetic, and the final result is rescaled before display.
// Scaled polynomial form for LOGO! 8 Math blocks
// y = 0.0336 * T
// X = 28.084 * (1 + y + y^2/2 + y^3/6 + y^4/24 + y^5/120 + y^6/720)
//
// Expanded symbolically, then multiplied by 10000 and rounded:
// X_scaled = C0 + C1*T + C2*T^2 + C3*T^3 + C4*T^4 + C5*T^5 + C6*T^6
//
// C0 = 280840 ( = 28.084 * 10000 )
// C1 = 9436 ( = 28.084 * 0.0336 * 10000 )
// C2 = 158 ( = 28.084 * 0.0336^2/2 * 10000 )
// C3 = 2 ( < 0.5 -- truncate )
// C4 .. C6 = 0
//
// LOGO! 8 wiring (six Math blocks):
// M1 = ( C2 * T^2 ) + C0
// M2 = ( T * T ) ( = T^2, then fed to M1 )
// M3 = M1 + C1*T ( final X_scaled )
// M4 = M3 / 10000 ( final X for display )
// AQ1 = Analog Amplifier (sensor to °C)
// AQ2 = M4 (computed X)
X_scaled is a design choice. If the application needs sub-unit resolution, use the more accurate scaled-by-100000 form, but verify the value of C2 · 100000 = 1585 fits inside the integer range and that the post-divide result preserves the engineering unit.Program-level verification at T = 65 °C:
- y = 0.0336 · 65 = 2.184
- e2.184 = 8.882
- X_exact = 28.084 · 8.882 = 249.44
- Two-term Taylor: 28.084 · (1 + 2.184 + 2.184²/2) = 28.084 · 5.769 = 162.05
- Four-term Taylor: 28.084 · (5.769 + 1.082) = 28.084 · 6.851 = 192.40
- Six-term Taylor: 28.084 · (6.851 + 0.157 + 0.018) = 28.084 · 7.026 = 197.32
For this problem a six-term Taylor still leaves a 20 % gap, so either raise N further (consuming Math blocks) or adopt Workaround 2.
6. Workaround 2 — Segmented Linear Lookup via Analog Thresholds
This is the most efficient approach on LOGO! 8 because it leverages the platform's strong analog threshold switch family (B007, B008, B009, B011, B012, B013). The full -25 to +100 °C span is broken into K linear segments, each implemented as its own Analog Amplifier (B042) with pre-computed slope and offset. A higher-level Analog Multiplexer (B044) selects the active segment based on the threshold comparator outputs.
| Segment | T range (°C) | X range | Slope (per °C) | Offset |
|---|---|---|---|---|
| 1 | -25 to -10 | 12.13 to 18.86 | 0.448 | 23.33 |
| 2 | -10 to 5 | 18.86 to 29.33 | 0.698 | 25.84 |
| 3 | 5 to 20 | 29.33 to 45.61 | 1.085 | 23.90 |
| 4 | 20 to 35 | 45.61 to 70.92 | 1.687 | 11.87 |
| 5 | 35 to 50 | 70.92 to 110.27 | 2.624 | -20.91 |
| 6 | 50 to 65 | 110.27 to 171.45 | 4.079 | -93.69 |
| 7 | 65 to 80 | 171.45 to 266.61 | 6.344 | -240.74 |
| 8 | 80 to 100 | 266.61 to 808.50 | 27.094 | -1900.92 |
LOGO! 8 ladder implementation (excerpt):
- Configure eight Analog Amplifier blocks (B042) with the slopes and offsets from Table 4. Each takes the °C value from
AQ1. - Insert eight Analog Threshold switches (B007) configured to
Onwhen T is within the segment. - Wire all eight amplifier outputs into an Analog Multiplexer (B044) with the eight threshold flags as the selector. The multiplexer output is the piecewise-linear X.
- Send the multiplexer output to message-text variable
VM0and toAQ2if the value must be written to a 0–10 V analog output.
With 15 °C-wide segments the worst-case residual error is 0.8 % near the segment midpoints and 0 % at the segment boundaries. This is well within the typical Pt100 / Pt1000 transmitter class of ±0.3 °C and is the recommended solution when the application must remain on LOGO! 8.
7. Workaround 3 — Migration to SIMATIC S7-1200
When the equation set is non-linear and changes frequently, or when sub-degree precision is required across the full span, the recommended target is the SIMATIC S7-1200 Programmable Controller System Manual (06/2022). The S7-1200 CPU family (CPU 1211C through CPU 1215C) executes LREAL (64-bit IEEE 754) math and includes the EXPT, LN, EXP, SQRT, and trigonometric functions in the SCL (Structured Control Language) instruction set.
Equivalent SCL code (TIA Portal V17 or later):
// Sensor scaling (4-20 mA on %IW64, raw 0-27648)
#Temp_C := (INT_TO_REAL(%IW64) / 27648.0 * 125.0) - 25.0;
// Compute X = 28.084 * EXP(0.0336 * T)
#X := 28.084 * EXP(0.0336 * #Temp_C);
// Publish to HMI tag (LREAL, full precision)
"HMI_Tag_X" := #X;
Recommended S7-1200 starter part numbers for a like-for-like migration:
| Function | LOGO! 8 part | S7-1200 equivalent | Notes |
|---|---|---|---|
| CPU (basic) | 6ED1052-1MD08-0BA1 | 6ES7211-1AE40-0XB0 | CPU 1211C DC/DC/DC |
| CPU (with Ethernet) | 6ED1052-2MD08-0BA1 | 6ES7214-1AG40-0XB0 | CPU 1214C, 14 DI / 10 DO / 2 AI |
| Analog input (4-wire RTD) | LOGO! AM2 RTD (6ED1055-1MD00-0BA2) | 6ES7231-5PD32-0XB0 | SM 1231 RTD, 4 AI |
| Engineering software | LOGO! Soft Comfort V8.3 | TIA Portal V17 (or V18) | Free trial available |
8. Workaround 4 — External Transmitter with Linearization
Many modern 4–20 mA temperature transmitters support customer-specific linearization. The Siemens SITRANS and Endress+Hauser lines can be pre-configured with a 32-point custom curve in the field. The transmitter then emits a 4–20 mA signal that is already the post-correction X, removing the LOGO! 8 of all math burden and leaving only a linear scaling block. Specify the curve table at order entry using the manufacturer's free Curve Configurator tool.
9. Verification Procedure
After implementing the chosen workaround, validate it on the bench before commissioning:
- Inject a calibrator current of 4.000 mA, 8.000 mA, 12.000 mA, 16.000 mA, and 20.000 mA into AI1.
- Read the LOGO! message-text variable that displays X. Compare to the expected values in Table 2.
- Tolerate a deviation of ±0.5 % of full span (8.0 units on the 12.13–808.50 range) for the segmented lookup, and ±2 % for the six-term Taylor.
- Record the LOGO!Soft Comfort online monitor trace of
AQ1(°C) and the math-block output that produces X. Verify there is no overflow (value clipping at 32767). - For S7-1200 implementations, use the TIA Portal Monitor & Force table to read
%IW64, the intermediateTemp_C, and the finalXtag.
10. Troubleshooting Matrix
| Symptom on LOGO! display | Likely root cause | Remediation |
|---|---|---|
| Display shows 0 regardless of input | Sensor scaling gain = 0 in Analog Amplifier | Re-enter gain = 0.15625, offset = -56.25 |
| Display shows -32768 | Integer underflow on the post-divide Math block | Verify the polynomial is positive across the full range; add an ABS-only path |
| X reads 808 at T=100 °C, but -25 °C shows 12 (correct) — sign flipping in high segments | Lookup table sign error in segment 8 slope/offset | Recompute slope = (808.50 - 266.61) / (100 - 80) = 27.0945 |
| Math block flagged red in Soft Comfort | More than 8 Math blocks per network | Chain the math across multiple networks; LOGO! 8 supports 32 Math blocks total |
| On-device display truncated | Message text variable format width | Increase character count of the message-text block to 6 digits |
| MQTT publish from LOGO! 8 shows integer only | Variable mapping to integer type | Use the "real" or "word" mapping; LOGO! 8 CMR2020 / CMR2040 supports LREAL publish |
11. Safety and EMC Considerations
Sensor loops in panel environments must follow IEC 61131-2 and IEC 61010-1 for creepage, clearance, and over-voltage. The 4–20 mA loop should be shielded twisted pair, grounded at one end only, with the shield bonded to the LOGO! 8 PE terminal. When using the AM2 RTD module, the 3-wire connection is mandatory to cancel lead resistance; do not ground the RTD sheath at both ends. For explosive atmospheres, the sensor and transmitter must be ATEX/IECEx certified for the zone, and the LOGO! 8 must be installed outside the hazardous area or inside an approved enclosure.
12. FAQ
Can the LOGO! 8 Math block compute e^x, ln, or any other transcendental function directly?
No. The LOGO! 8 Math instruction (B043) supports +, -, *, /, and SQRT only. For e^x, ln, log, sin, cos, and tan you must either pre-compute the result in the transmitter, expand a Taylor / Maclaurin series in Math blocks, or use a segmented linear lookup. For native support migrate to a SIMATIC S7-1200 with SCL.
Why does my LOGO! display show only integer values when the internal calculation is floating point?
The on-device 4-line HMI and the message-text variables in LOGO! 8 (firmware 8.x) are bound to the signed 16-bit integer range -32768 to +32767. The Math block executes in 32-bit float, but values are rounded for display. To retain decimals you must publish the value to an HMI that supports real numbers (LOGO! TDE, CMR module, or external HMI) or migrate to S7-1200 where the LREAL type is supported throughout.
What is the best workaround for an exponential equation that must stay on LOGO! 8?
A segmented linear lookup implemented with Analog Amplifier blocks (B042) and an Analog Multiplexer (B044), selected by Analog Threshold switches (B007). With 15 °C-wide segments the worst-case residual is below 1 %, well inside typical Pt100 transmitter accuracy. The Taylor-series approach consumes more Math blocks and is only preferable for low-slope (y < 0.5) regions.
How many Math blocks can one LOGO! 8 program contain?
Up to eight Math blocks per network and up to 32 Math instructions per program in LOGO! Soft Comfort V8.3 and firmware 8.3. Earlier firmware (LOGO! 6/7) had lower limits. Always verify the limit against the current LOGO! 8 System Manual revision.
Can I bypass LOGO! 8 entirely by configuring the transmitter to emit the post-correction value?
Yes. Modern 4–20 mA HART temperature transmitters (Siemens SITRANS TH100/200/300/400, Endress+Hauser iTHERM TM411, Rosemount 644) accept a 32-point custom linearization curve at order entry. The loop then carries the corrected X directly and the LOGO! 8 needs only a single linear scaling block. This is the lowest-risk and lowest-CPU-load approach.