You are on page 1of 2

(http://www.siemens.

com)
Industry Online Support
Product Support

 Home (start)  Product Support

Entry type: FAQ Entry ID: 13406965, Entry date: 03/29/2006


     (3)
 Rate

How is numerical integration programmed in S7-SCL and STEP 7?


Entry Associated product(s)

Instructions:
The integral is the mathematical calculation of the area under a given function curve. However, there is often no mathematical correlation in practice, but rather an analog value which varies over time. The integral calculation involving
totaling the trapezoidal areas, spread between the last two function values and the time. This trapezoidal area is identical to the product of the average of the two process values and the time interval.

(/cs/images/13406965/step7_integral_01.gif?
inline=1)

Fig. 01

Fig. 01 illustrates the calculation of the integral of a trapezoidal area:

Calculation: 0.5*(F(t1)+F(t0))*(t1-t0) + 0.5*(F(t2)+F(t1))*(t2-t1) + ...

The table below contains some sample programs for calculating integrals. Copy the EXE files into a separate folder and then start the files with a double-click. The STEP 7 projects are then extracted automatically with all the associate
subfolders. You can then use the SIMATIC Manager to open and process the extracted projects.

No. Sample programs / Downloads


1 Integral calculation with STEP 7
The "I_STEP7.exe" download contains an FB1 function block with the STEP 7 program for calculating the integral. OB1's current cycle time is applied here. In the case of slower processes, you simply need to supply the time inpu
a timer or to call the FB in another OB. The slow changing output from a heating system represents a slow process here. In this case, the integral is the energy consumption in J (joules) or KWh.
FB1 is started with the input "start" and is reset to the value zero. If the last value has to continue to be available after recording, the "EN" input in the FB1 must be disabled in OB1. The data is retained in the instance data block.
I_STEP7.exe (/cs/attachments/13406965/I_STEP7.exe) ( 97 KB )
2 Integral calculation with S7-SCL
The "I_SCL.exe" download contains the S7-SCL "Integral_SCL" source with the (FB1) program for calculating the integral. There are two examples programmed in the STEP 7 project.
I_SCL.exe (/cs/attachments/13406965/I_SCL.exe) ( 123 KB )
In example 1 (Fig. 02) an analog input value (EW0 on the "IN" parameter) is converted to a floating-point value with the SCALE function and is transferred to MD4 via the "OUT" parameter. The transfer of the floating-point value to
integrator takes place when the MD4 is parameterized on the "IN" parameter of the FB1. The calculation of the integral is started with the flag M0.1 on FB1's "Enable" parameter.

(/cs/images/13406965/step7_integral_02_e.gif?
inline=1)

Fig. 02
Fig. 03 illustrates the example of a cascade. The flags M0.0 and M0.1 at the inputs of the "Integral" function block serve to start and stop the calculation of the integral for the input value in MD0 on FB1's "IN" parameter. The calcu
integral value is saved in its instance DB under the address DB1.DBD6 (DB1.OUT). The values between DB1.OUT and a specified constant from MD8 (Constant) are compared in the "CMP>R" floating-point number comparator. I
value from DB1.OUT is greater than the value of the constant, the value from DB1.DBD6 is added to MD4 (Output).

(/cs/images/13406965/step7_integral_03.gif?
inline=1)

Fig. 03
3 S7-SCL source: "Integral_SCL_B"
The "I_SCL_B.exe" download also contains the FB1 block described above, whereby this S7 program only contains the "Integral_SCL_B" source, the compiled FB1 function block and the associated "TIME_TCK" system function.
dearchiving, the S7 program is saved in the STEP 7 library.
I_SCL_B.exe (/cs/attachments/13406965/I_SCL_B.exe) ( 95 KB )

Runnability and test environment:


The examples can be used on all the CPU types of SIMATIC S7-300 and S7-400. The following table lists the components that have been used to create this entry and verify the functions described:

Test environment: Version:


PC platform Intel(R) Pentium(R) 4 CPU, 2.40 GHz
PC operating system Windows XP SP2
STEP 7 V5.3 SP3
S7 PLCSIM V5.3

Keywords:
Consumption measurement, Flow-rate measurement

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to
implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions
constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration. (https://www.siemens.com/cybersecurity#Ouraspiration)

© Siemens AG 2009-2020 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) /
Also available in the followingTerms
languages:
of use (http://www.siemens.com/terms_of_use) Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0
 German
 French
 Italian
 Spanish

Entry belongs to product tree folder(s):


 Automation Technology  Automation Systems  Industrial Automation Systems SIMATIC  Software for SIMATIC Controller  STEP 7 V5.x
 STEP7 basic software and editors  STEP 7 (products?pnid=14342)

 Automation Technology  Automation Systems  Industrial Automation Systems SIMATIC  Software for SIMATIC Controller  STEP 7 V5.x
 STEP7 basic software and editors  S7-SCL (products?pnid=14354)

Rate entry

     no rating Submit rating

Feedback *)

 Personalization saves you typing! If you have already been registered, you can login directly. If you are not registered yet, you can inform and register yourself without obligation her
(our service is free of charge).
 Log in
 Register

Name

Phone number

email

Comment Number of characters: 0 (max. 500)

Send copy of comment to sender. (login required) Sen

*) Important: Please use this form for general feedback only. All technical and specialist topics should be directed to the expert community in the Technical Forum
(https://support.industry.siemens.com/tf/ww/en/).

© Siemens AG 2009-2020 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) /

You might also like