Siemens 1200/1500 Analog Scaling Function Block Guide
In industrial automation, analog signals from sensors like temperature transmitters, pressure sensors, and flow meters need to be converted into engineering units for processing. Siemens S7-1200 and S7-1500 PLCs provide powerful analog input and output modules, but the raw integer values must be scaled to meaningful engineering values. This article explains a universal scaling formula and how to implement it as a reusable function block.
The Universal Analog Scaling Formula
The conversion between raw analog values and engineering units follows a linear relationship. The formula is:
Ov = [(Osh – Osl) * (Iv – Isl) / (Ish – Isl)] + Osl
Where:
| Variable | Description |
|---|---|
| Ov | Output value (scaled engineering value) |
| Iv | Input value (raw analog value from the module) |
| Osh | Output scale high limit (e.g., 100.0 °C) |
| Osl | Output scale low limit (e.g., 0.0 °C) |
| Ish | Input scale high limit (e.g., 27648 for 0-10V) |
| Isl | Input scale low limit (e.g., 0 for 0-10V) |
This formula works for both analog inputs (converting raw to engineering) and analog outputs (converting engineering to raw). For outputs, simply swap the roles: Iv becomes the desired engineering value, and Ov becomes the raw value to send to the module.
Typical Analog Signal Ranges in Siemens PLCs
Siemens analog modules use a normalized range for unipolar and bipolar signals. The most common ranges are:
| Signal Type | Raw Range (Integer) | Engineering Example |
|---|---|---|
| 0-10 V / 0-20 mA | 0 to 27648 | 0-100% pressure |
| 4-20 mA | 0 to 27648 (with 4mA = 0) | 0-300 °C temperature |
| ±10 V / ±20 mA | -27648 to 27648 | -100 to 100% speed |
| 0-20 mA (with open wire detection) | 0 to 27648 (values below 0 indicate fault) | 0-500 m³/h flow |
Note: For 4-20 mA signals, the module still returns 0 at 4 mA and 27648 at 20 mA. If you need to detect wire break, values below 0 (e.g., -32768) indicate an open circuit.
Implementing a Universal Function Block in TIA Portal
Instead of writing the scaling formula repeatedly, you can create a reusable function block (FB) in TIA Portal. This FB can handle both input and output scaling with a simple mode selection.
Here is a step-by-step approach to design the block:
- Define Input/Output Parameters: Create inputs for Iv, Ish, Isl, Osh, Osl, and a mode selector (e.g., 0 = input scaling, 1 = output scaling). Output the scaled value Ov.
- Add Fault Handling: Check if Iv is within valid range (e.g., for 4-20 mA, Iv should be >= 0). If out of range, set an error bit.
- Implement the Formula: Use real (floating-point) math to avoid overflow. Convert integers to real before calculation.
- Test with Typical Values: Verify with known points, e.g., for 4-20 mA to 0-100%, 0 raw = 0%, 27648 raw = 100%.
The block can be written in LAD, FBD, or SCL. SCL is often preferred for mathematical operations due to its clarity.
Example: Scaling a 4-20 mA Temperature Sensor
Consider a temperature transmitter with range -50°C to 150°C, output 4-20 mA, connected to an S7-1200 analog input module (0-20 mA range). The raw value at 4 mA is 0, at 20 mA is 27648.
Using the formula:
Ov = [(150 – (-50)) * (Iv – 0) / (27648 – 0)] + (-50) = (200 * Iv / 27648) – 50
If the raw value is 13824 (12 mA), the scaled temperature is (200 * 13824 / 27648) – 50 = 100 – 50 = 50°C.
This calculation can be easily done in the function block, and the result can be used for display, alarms, or control loops.
Benefits of a Standardized Scaling Block
- Consistency: All analog channels use the same logic, reducing errors.
- Reusability: The block can be instantiated multiple times with different parameters.
- Maintainability: Changes to scaling logic are made in one place.
- Flexibility: Easily switch between input and output scaling, or handle different signal types.
Advanced Considerations
In real-world applications, you may need to add filtering, alarm limits, or integration with PID loops. The function block can be extended to include:
- Low-pass filter to smooth noisy signals.
- High and low alarm limits with hysteresis.
- Rate-of-change monitoring for predictive maintenance.
- Direct output to HMI tags for visualization.
By building a robust analog scaling function block, you can significantly speed up project development and ensure reliable operation of your Siemens PLC-based control system.