Sei sulla pagina 1di 4

Course T300, Engineering an 800xA System

Exercise 7.5 Structured Text

TABLE OF CONTENTS
Exercise 7.5 Structured Text....................................................................................................................................................... 7.5-1
7.5.1 General Information....................................................................................................................................................... 7.5-3
7.5.1.1 Objectives................................................................................................................................................................ 7.5-3
7.5.2 Exercise Steps ................................................................................................................................................................ 7.5-3
7.5.2.1 General .................................................................................................................................................................... 7.5-3
7.5.2.2 Create new calculation code page .......................................................................................................................... 7.5-3
7.5.2.3 Create new variables for calculation ...................................................................................................................... 7.5-4
7.5.2.4 Create new variable getting the vessel input and assign it to IO ........................................................................... 7.5-4
7.5.2.5 Write ST code for calculating................................................................................................................................. 7.5-4
7.5.2.6 Download and test the application.......................................................................................................................... 7.5-4

7.5-1

Course T300, Engineering an 800xA System

7.5-2

Engineering an 800xA System

7.5.1 General Information


In this exercise you will practice programming in structured text. This may be a new
language for some but it is a powerful and efficient way in which to write code.
This exercise serves only as an introduction to the structured text language. The code
will be used later to perform a small batch operation.

7.5.1.1 Objectives
You will

Learn about the syntax for structured text editor to write simple statements

Get a general overview of the language elements.

Write code for a simple calculation to convert the level signal into a mass in kg for
the vessel contents.

Learn how to address components in a structured data type.

7.5.2 Exercise Steps


7.5.2.1 General
The range of the sensor in the vessel is in liter. But what we need is a range in kg. All
this should be pictured e.g. to the faceplate of the input signal. To get this we have to
create a calculation which will generate new

Min and Max values

Value

Unit (in kg)

Right now the input signal from the vessel is transferred into the variable LT1_In. For
the calculation to the kg unit we have to create a new variable for the vessel input and
transfer the values to the LT1_In variable. The picture below should explain this
better.

Vessel1_In
( liter )

Calculation
( Min, Max, Value, Unit )

LT1_In
( kg )

7.5.2.2 Create new calculation code page


Open the program Control1 and create a new code page for it. As language please
select the Structure Text language. Please name the page Calculation

7.5-3

Engineering an 800xA System


Exercise 7.5 Structured Text

7.5.2.3 Create new variables for calculation


Create two local program variables for the calculation conversion.
Name
Calc_conversion
Calc_unit

Type
real
string[10]

Init value
0.5
kg

Description
Per default: 1 liter ==> 0.5 kg
Unit after confersion

7.5.2.4 Create new variable getting the vessel input and assign it to IO
Right now we get the vessel input from the variable LT1_In. Because of the
conversion we need a new variable for the vessel input.
1. Please create a new global application (Tank1) variable:
Name
Type
Description
Vessel1_In
RealIO
The input from the vessel
2. Assign the variable Vessel1_In to channel 1 of the analog input board AI810
(instead of the variable LT1_In).

7.5.2.5 Write ST code for calculating


On the code page Calculation please write ST code for
1. Calculating the new Min and Max for the input signal LT1_In.
Use the structured components of the LT1_In (LT1_In.Parameters.Min/Max)
and the Vessel1_In (Vessel1_In.Parameters.Min/Max) variable.
2. Calculating the new Value for the input signal LT1_In.
Use the structured component LT1_In.Value and Vessel1_In.Value.
3. Assign the new Unit for the input signal LT1_In (LT1_In.Parameters.Unit).

7.5.2.6 Download and test the application


Please download the application Tank1 into the controller and test the calculation.

7.5-4

Potrebbero piacerti anche