show the entry list
STEP 7 Micro/WIN -- Creating S7 programs -- Calling blocks and functions
How do you reset the high-speed counters of the S7-200?
Using an S7-200 without twilight switch, how do you have shutters open at sunrise and close at sunset?
How do you count values over 16 bits with the S7-200?
How can you limit the pitch of jumps with S7-200?
How do you configure the positioning module EM253 so that the connected stepper motor can proceed in both directions?
How do you position a servo drive axis using the S7-200 pulse interface?
How do you create a bar display in TD 200 or TD 200C?
How can you optimize use of timers in STEP 7 Micro/WIN?
How do you determine the frequency of a pulse sequence and speeds?
How can you scale analog values with S7-200 in conjunction with CPU224XP and expansion modules EM 231, EM 232 and EM 235?
How do you convert a binary number into Gray code (or vice versa) in STEP 7 Micro/WIN?
How do you convert the number format DOUBLE INTEGER into BCD code (or vice versa) in STEP 7 Micro/WIN?
How do you form the absolute and negative values of numbers in STEP 7 Micro/WIN?
Why does the PID controller created by the instruction wizard sometimes not work?
What do you have to do in the SIMATIC S7-200 in order to edit part of the program once after restarting?
Which library with the inverse functions to the trigonometric functions (sine, cosine, tangent) is available for STEP 7-Micro/WIN?
Scaling the setpoint and actual values in the STEP 7 Micro/WIN V4 wizards for PID control loops
Positioning Wizard for PTO/PWM in STEP 7 Micro/WIN V4.0
How to implement a three step control with PID-loop in the S7-200 via STEP 7-Mirco/WIN?
How can you scale analog values with S7-200 in conjunction with CPU224XP and expansion modules EM 231, EM 232 and EM 235?
Part number:

Instructions
Analog input and output values of the expansion modules EM 231, EM 232 and EM 235, as well as of CPU 224XP are displayed digitally in the INTEGER data word format. It is necessary to make conversions to ensure correct interpretation and processing. These conversions are explained using the download attached. The download contains both the "Scale" library with conversion functions and the sample program "Tip038" for better understanding.

1. Scaling
The following diagrams show how the input and output values are scaled.

The terms "unipolar", "bipolar" and "20% offset" are explained here. These are important for, among others, the STEP 7 Micro/Win - Instruction Wizard PID (Tools > Instruction Wizard > PID Controller).
Unipolar scaling is done only in the positive or negative value range (Fig. 01 shows an example for an analog input value of between 0 and 32000).


Fig. 01

In the case of unipolar scaling with a 20% offset, the lower limit of the value range is 20% of the upper limit (Fig. 02 shows an example for an analog input value of between 6400 and 32000).


Fig. 02

Bipolar scaling is done in the positive and negative value range (Fig. 03 shows an example for an analog input value of between -32000 and 32000).


Fig. 03

The following table explains the abbreviations used:
 
Parameter Description
Ov Scaled output value (Output value)
Iv Analog input value (Input value)
Osh Upper scale limit for the scaled output value (Output scale high)
Osl Lower scale limit for the scaled output value (Output scale low)
Ish Upper scale limit for the scaled input value (Input scale high)
Isl Lower scale limit for the scaled input value (Input scale low)
Table 01

2. Formula
The following formula is derived from the diagram for calculating the scaled value:

Ov = (Osh - Osl) / (Ish - Isl) * (Iv - Isl) + Osl

3. Library

3.1 Description of the "Scale" library
The "scale.mwl" library contains the function blocks for converting the scaling from data type INTEGER to REAL (S_ITR), from REAL to REAL (S_RTR) and from REAL to INTEGER (S_RTI).


Fig. 04

3.2 Scaling the analog input in the output data format REAL (S_ITR)
The S_ITR function permits you to convert the analog input signal into a normalized value between 0.0 and 1.0 (type REAL).


Fig. 05

3.3 Scaling change to the data type format REAL (S_RTR)
The S_RTR function permits you to convert value ranges within the REAL format (e.g., convert the input value between 0.0 and 1.0 to the output range in percent).


Fig. 06

3.4 Converting to the analog output scaling format INTEGER (S_RTI)
The S_RTI function converts a REAL number to the analog output data type INTEGER.


Fig. 07

4. Sample program

4.1 Description of the sample program "Tip038"
There is a liquid in a closed container.

The differential pressure measuring transducer provides a current (4 - 20 mA) at the input of the analog input module. The current is proportional to the fill level in the container.

The analog module EM 235 must be calibrated so that the analog value of 20 mA is converted into the digital value of 32000 at a fill level of 10 m. At a fill level of 0 m the analog value of 4 mA is converted into the value 6400. The program scales the converted digital values as height in meters.

The voltage for the fill level indicator must be produced via the analog output module. This voltage is generated by writing the corresponding digital value to the analog output word (AQW).

The analog output module transfers the fill level height (between 0 m and 10 m) to a measuring instrument in the form of a voltage of between 0 V and 10 V. The analog display of the measuring instrument reacts to the voltage with needle deflection proportional to the fill level.

The formula scales every value between a maximum and minimum scaling value. This program receives the analog input value (AIW) and scales it for the analog output module. First the program reads the AIW, a value between 4 mA and 20 mA (6400 and 32000), and scales the value to a normalized value between 0.0 and 1.0 (see Fig. 05). This value is then scaled for the ranges of 0.0 to 100.0 (see Fig. 06) and 0 to 32000 (see Fig. 07).

4.2 The STEP 7 Micro/WIN library as zip file
Copy the "scale.zip" file to a separate directory and extract the file. You can then integrate the "scale.mwl" library and the sample program "Tip038_D.mwp", which can be used in version 4.0.7.10 and higher of STEP 7 Micro/WIN, into your S7-200 project. The "scale.zip" file contains the library "scale.mwl" and the sample program in German ("Tip038_D.mwp") and in English ("Tip038_E.mwp").

Notes

  • This program is also part of the SIMATIC S7-200 Programming Tips 08/03 ("Tip038")
    Entry ID: 1232912
  • Information on inserting libraries in STEP 7 Micro/WIN is available in 
    Entry ID: 16689345

scale.zip ( 20 KB )

 

 Entry ID:27043396   Date:2012-05-03 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Topics
Help
Online Help
Guided Tour