How do you standardize and destandardize analog values with STEP 7 (TIA Portal)?
For standardizing you should only use the general linear equation for linear signals. Defining two points of the straight line is sufficient to calculate the gradient of the line and the ordinate value.
Standardizing or scaling the analog value
An analog input module provides a numerical value for a standardized analog signal (current, voltage, resistance or temperature). This numerical value must represent the parameter to be measured (fill level in liters, for example).
Inversely, the user program calculates a process value that has to be converted into a numerical value. The analog output module converts this numerical value into an analog signal to trigger an actuator, for example.
The functions of the library available for downloading below can be used for standardizing and destandardizing in analog value processing.
- The x values are the known parameters in each case.
- The corresponding y value includes the result of the conversion.
The table below includes the functions for the S7-300/S7-400 and for the S7-1200/S7-1500:
|SclScaleLinearInt||S7-1200/S7-1500||SCL||Here the x values and the y values are integer numbers.|
|SclScaleLinearIntToReal||S7-1200/S7-1500||SCL||Here the x values are integer numbers and the y values are real numbers.|
|SclScaleLinearReal||S7-1200/S7-1500||SCL||Here the x values and the y values are real numbers.|
|SclScaleLinearRealToInt||S7-1200/S7-1500||SCL||Here the x values are real numbers and the y values are integer numbers.|
With the S7-300/S7-400 these functions do not change the address register AR1/AR2 and for the FBD and LAD applications they provide the ENO box in which the RLO = 0 or 1 is stored in the BR bit.
By entering "yMin" and "yMax" you can limit the calculated y value to a specific range with lower and upper limits. In this way you avoid overrange and underrange areas with the analog modules.
The value for "Y" (function value "Ret_Val") is calculated according to the general linear equation with y = ax + b.
This yields the following relationship:
|(y1 - y0)|
|y =||------------||* (x - x0) + y0|
|(x1 - x0)|
Fig. 3 shows linear scaling with the function "SclScaleLinearIntToReal".
A signal of 4mA to 20mA is present at an analog module. This signal is converted to the internal CPU value of 0 to 27648 to measure a fill level. Here, 4mA corresponds to the fill level of 0.0m and 20mA to the fill level of 1.7m.
Then parameterize the block as follows:
- P0 (x0 = 0; y0 = 0.0)
- P1 (x1 = +27648; y1 = 1.7)
Fig. 4 shows the call and parameters of the function "SclScaleLinearIntToReal".
Download for the S7-1200/S7-1500
The download includes the STEP 7 (TIA Portal) library with the blocks described above for the S7-1200 and for the S7-1500. Unpack the Zip file in a separate directory on your hard disk. Then you can open and edit the library in STEP 7 (TIA Portal).
Download for the S7-300/S7-400
The download includes the STEP 7 (TIA Portal) library with the blocks described above for the S7-300 and for the S7-400. Unpack the Zip file in a separate directory on your hard disk. Then you can open and edit the library in STEP 7 (TIA Portal).
You can only open and edit the libraries in STEP 7 (TIA Portal). Further information about opening libraries is available in Entry ID: 107147393
The screens and downloads in this FAQ response were created with STEP 7 (TIA Portal) V13 + SP1.
Measuring range, Measured value modification