You are on page 1of 13

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 S7200 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 S7200? 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 7Micro/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 7Mirco/WIN?

How can you scale analog values with S7-200 in conjunction with CPU224XP and expansion modules EM 231, EM 232 and EM 235? Display 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 Ov Iv Osh Osl Ish

Description Scaled output value (Output value) Analog input value (Input value) Upper scale limit for the scaled output value (Output scale high) Lower scale limit for the scaled output value (Output scale low) Upper scale limit for the scaled input value (Input scale high)

Isl Table 01 2. Formula

Lower scale limit for the scaled input value (Input scale low)

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 ) esto es prueba de guardar Word vvvvvv

Instrucciones La representacin de los valores de entrada y salida analgicos en los mdulos de ampliacin EM 231, EM 232 y EM 235, as como en la CPU 224XP, se realiza de forma digital con el formato de tipo palabra INTEGER. Para la interpretacin correcta y consiguiente elaboracin de los datos, es necesaria una conversin. Con ayuda del Download abajo indicado, se

aclaran estas conversiones. El Download contiene tanto la librera "Scale" con las funciones de conversin, como el programa ejemplo "Tip038" para una mejor comprensin. 1. Escalado El escalado de los valores de entrada y salida se puede tomar de los siguientes diagramas. Aqu se explican los conceptos "unipolar", "bipolar" y "20% de desviacin". Especialmente importante para el STEP 7-Micro/Win - Asistente de operaciones PID (Herramientas -> Asistente de operaciones -> Regulador PID). El escalado unipolar slo se desarrolla en el rango de valores positivos o negativos (la figura 01 muestra un ejemplo para valores de entradas analgicas de 0 a 32000).

Figura 01 Con un escalado unipolar con una desviacin del 20%, el lmite inferior del rango de valores est al 20% del valor superior (la figura 02 muestra un ejemplo de un valor de entrada analgica que va de 6400 a 32000).

Figura 02 El escalado bipolar se desarrolla en el rango de valores positivo y negativo (la figura 03 muestra un ejemplo de un valor de entrada analgica que va de -32000 a 32000).

Figura 03

La siguiente tabla da informacin sobre las abreviaturas utilizadas:

Parmetro Descripcin Ov Iv Osh Valor de salida escalado (Output value) Valor de entrada analgico (Input value) Valor lmite superior de la escala para el valor de salida escalado (Output scale high) Osl Valor lmite inferior de la escala para el valor de salida escalado (Output scale low) Ish Valor lmite superior de la escala para el valor de entrada analgico ( Input scale high) Isl Valor lmite inferior de la escala para el valor de entrada analgico (Input scale low) Tabla 01 2. Frmula La siguiente frmula se deduce del diagrama para el clculo del valor escalado: Ov = (Osh - Osl) / (Ish - Isl) * (Iv - Isl) + Osl 3. Librera 3.1 Descripcin de la librera "Scale" La librera "scale.mwl" contiene mdulos de funcin para convertir el escalado de tipo INTEGER a REAL (S_ITR), de tipo REAL a REAL (S_RTR) y de tipo REAL a INTEGER (S_RTI).

Figura 04 3.2 Escalado de la entrada analgica al formato de datos de salida REAL (S_ITR) Las funciones S_ITR ofrecen la posibilidad de convertir seales de entradas analgicas en valores normalizados entre 0.0 y 1.0 (tipo REAL).

Figura 05 3.3 Modificacin del escalado al forma to de tipo de datos REAL (S_RTR) Las funciones S_RTR ofrecen la posibilidad de convertir rangos de valores enteros de formato REAL (por ejemplo, los valores de entrada entre 0.0 y 1.0 a la zona de salida en porcentaje).

Figura 06 3.4 Conversin al formato de escalado de salidas analgicas INTEGER (S_RTI) Las funciones S_RTI convierten un nmero real en el tipo de datos de salida analgica INTEGER.

Figura 07 4. Programa ejemplo 4.1 Descripcin del programa ejemplo "Tip038" Se tiene un fluido determinado dentro de un contenedor cerrado. El conversor de medida de diferencia de presin suministra una intensidad (4 - 20 mA) a la entrada del mdulo de entradas analgicas. La intensidad es proporcional al nivel de llenado del contenedor. El mdulo analgico EM 235 se tiene que calibrar de tal manera que el valor analgico de 20 mA, con un nivel de llenado de 10 m, se convierta al valor digital 32.000. Con un nivel de llenado de 0 m, el valor analgico de 4 mA se convierte al valor digital 6.400. El programa realiza la escala de los valores digitales convertidos en altura en metros. La tensin para el sealizador del nivel de llenado se tiene que crear a travs del mdulo de salidas analgicas. Esta tensin se crea escribiendo el valor digital correspondiente en una palabra de salidas analgicas (AAW). El mdulo de salidas analgicas suministra la altura del nivel de llenado (entre 0 y 10 metros) al equipo de medida en forma de una tensin entre 0 V y 10 V. La sealizacin analgica del equipo de medida reacciona a la tensin con un movimiento de la aguja que es proporcional al nivel de llenado. La frmula escala cada valor que se encuentra entre un valor de escalado mximo y mnimo. Este programa recibe la palabra de entradas analgicas (AEW) y la escala para el md ulo de salidas analgicas. Primero, el programa lee la palabra AEW, es decir un valor entre 4 y 20 mA (6.400 y 32.000), y escala el valor a un nmero normalizado entre 0.0 y 1.0 (consulte la figura 05). Este valor se escala para el rango de 0.0 a 100.0 (consulte la figura 06) y de 0 a

32.000 (consulte la figura 07). 4.2 La librera de STEP 7-Micro/WIN como archivo ZIP Copie el archivo "scale.zip" en un directorio aparte y descomprmalo. A continuacin, la librera "scale_d.mwl" y el programa ejemplo "Tip038_D.mwp" ya se pueden integrar en el S7200 a partir de la versin 4.0.7.10 del STEP 7-Micro/WIN. El archivo "scale.zip" contiene la librera y el programa ejemplo en alemn ("scale_d.mwl" und "Tip038_D.mwp") e ingls ("scale_e.mwl" und "Tip038_E.mwp"). Advertencias Este programa tambin forma parte de los tipos de programacin 08/03 del SIMATIC S7-200 ("Tip038") Pgina del Customer Support con nmero ID 1232912 Informacin para la insercin de libreras en el STEP 7 Micro/WIN est disponible en: Pgina del Customer Support con nmero ID 16689345

scale.zip ( 20 KB )

You might also like