0% found this document useful (0 votes)
2 views

B02 Analog e

This training document from Siemens AG focuses on Analog Value Processing within the Totally Integrated Automation (TIA) framework, specifically Module B2. It covers the input, processing, and output of analog values in a SIMATIC S7 system, including the types of analog signals, data types in STEP 7, and mathematical operations. The document is intended for educational purposes and requires prior knowledge of PLC programming and Windows operating systems.

Uploaded by

brendsriverasy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

B02 Analog e

This training document from Siemens AG focuses on Analog Value Processing within the Totally Integrated Automation (TIA) framework, specifically Module B2. It covers the input, processing, and output of analog values in a SIMATIC S7 system, including the types of analog signals, data types in STEP 7, and mathematical operations. The document is intended for educational purposes and requires prior knowledge of PLC programming and Windows operating systems.

Uploaded by

brendsriverasy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Automation and Drives - SCE

Training Document for Comprehensive Automation


Solutions
Totally Integrated Automation (T I A)

MODULE B2
Analog Value Processing

T I A Training Document Page 1 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

This document has been written by Siemens AG for training purposes for the project entitled "Siemens
Automation Cooperates with Education (SCE)".
Siemens AG accepts no responsibility for the correctness of the contents.

Transmission, use or reproduction of this document is only permitted within public training and educational
facilities. Exceptions require the prior written approval of Siemens AG (Mr. Michael Knust
[email protected]).

Offenders will be liable for damages. All rights, including the right to translate the document, are reserved,
particularly if a patent is granted or utility model is registered.

We would like to thank the following: Michael Dziallas Engineering, the teachers at vocational schools, and all
others who helped to prepare this document.

T I A Training Document Page 2 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

PAGE

1. Preface .................................................................................................................. 4

2. Analog Signals ..................................................................................................... 6

3. Data Types in STEP7 ........................................................................................... 8

4. Math Operations .................................................................................................. 9

4.1. Computing with Fixed Point Numbers (INT and DINT) ......................................... 9
4.2. Computing with Floating Point Numbers (REAL) .................................................. 10
4.3. Data Type Conversion Operations ........................................................................ 11

5. Entering/Reading Out Analog Values................................................................ 12

5.1. Entering and Normalizing Analog Values .............................................................. 13


5.2. Reading Out and Normalizing Analog Values ....................................................... 14

The following symbols provide a guide through this B2 module:

Information

Programming

Sample Exercise

Notes

T I A Training Document Page 3 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

1. PREFACE

In terms of its contents, Module B2 is part of the teaching unit entitled "Additional Functions of
STEP 7 Programming'.

Basics of
STEP 7 Programming
2 to 3 days Module A

Additional Functions of
Plant Simulation with
STEP 7 Programming
2 to 3 days Module B SIMIT SCE
1 to 2 days Module G

Programming Industrial Process


Languages Field Bus Systems Visualization
2 to 3 days Module C 2 to 3 days Module D 2 to 3 days Module F

Frequency Converter IT Communication


at SIMATIC S7 with SIMATIC S7
2 to 3 days Module H 2 to 3 days Module E

Learning Objective:

In module B2, the reader learns how analog values are input, processed, and output in a SMATIC
S7. The following steps are discussed:

 Analog signals
 Data types in STEP 7
 Mathematical operations
 Converting data types in STEP 7
 Inputting and normalizing analog values
 Normalizing and reading out analog values

Prerequisites:

To successfully work through this B2 module, the following knowledge is assumed:

 Knowledge in handling Windows


 Fundamentals of PLC programming with STEP 7 (for example, Module A3 – 'Startup’
PLC Programming with STEP 7)

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 4 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

Hardware and software required

1 PC, operating system Windows 2000 Professional starting with SP4/XP Professional starting
with SP1/Server 2003 with 600MHz and 512RAM, free hard disk storage 650 to 900 MB, MS
Internet Explorer 6.0
2 Software STEP7 V 5.4
3 MPI interface for the PC (for example, PC adapter USB)
4 PLC SIMATIC S7-300 with at least one analog input/output module to which, on one analog
value input, a potentiometer or another analog signal transmitter is connected. In addition, an
analog value display has to be connected to at least one analog output.
Sample configuration:
- Power supply: PS 307 2A
- CPU: CPU 314
- Digital inputs: DI 16xDC24V
- Digital outputs: DO 16xDC24V/0.5 A
- Analog inputs/outputs: AI 4/AO2 x 8 bits

2 STEP7
1 PC

3 PC Adapter USB

4 SIMATIC S7-300

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 5 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

2. ANALOG SIGNALS

In contrast to a binary signal that can only have the two signal states “Voltage present +24V“ and
"Voltage not present 0V“, analog signals can have many values within a certain range. A typical
example for an analog transmitter is a potentiometer. Depending on the position of the rotary button,
any resistance can be set here up to the maximum value.

Below are examples of analog variables in control engineering:

 Temperature: -50 ... +150°C


 Flow rate: 0 ... 200l/min
 Speed: 500 ... 1500 U/min
 etc.

By using a measuring transducer, these variables are converted into electrical voltages, currents or
resistances. If, for example, a certain speed is to be recorded, the speed range of
500 ... 1500 r/min can be converted into a voltage range of 0 ... +10V by using a measuring
transducer. For a speed of 865 r/min, the transducer would read out a voltage of + 3.65 V.

500 865 1500 r/min


365
10V: 1000r/min = 0.01 V/r/min
1000 r/min
365 r/min x 0.01 V/r/min = 3.65
10V
0V +10V

These electrical voltages, currents or resistances are then connected to an analog module that
digitalizes this signal.

Note: Some analog modules can process different types of signals. This has to be set in the
hardware configuration. Please refer to the notes in the manuals.

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 6 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

If analog variables are processed with a PLC, the voltage, current or resistance value that was
entered has to be converted into digital information. This conversion is called analog/digital
conversion. It means that the voltage of 3.65V, for example, is stored as information in a series of
binary digits. The more binary digits are used for digital representation, the more detailed the
resolution. If, for example, you would have only 1 bit available for the voltage range 0 ... +10V, only
two values could be provided: whether the measured voltage is in the range of 0 .. +5V or in the
range +5V ... +10V. With 2 bits, however, the range can be divided into 4 individual ranges; that is 0
... 2.5 / 2.5 ... 5 / 5 ... 7.5 / 7.5 ... 10V. Usually, A/D converters in control engineering convert with 8
or 11 bits.
8 bits provide 256 individual ranges, and 11 bits a resolution of 2048 individual ranges.

0A/0V 20mA/10V
10V: 2048 = 0,0048828
 Voltage differences of
11 Bits <5mV can be recognized
0 2048

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 7 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

3. DATA TYPES IN STEP7

The SIMATIC S7 has a large number of different data types that can represent different numerical
formats. Below is a list of the elementary data types.

Type and Size Format Range and Numerical Example


Description Representation – Lowest to
in Bits Option
Highest Value
BOOL (Bit) 1 Bool text TRUE/FALSE TRUE
BYTE (Byte) 8 Hexa decimal B#16#0 to B#16#FF B#16#10
WORD (Word) 16 Dual number 2#0 to 2#1111_1111_1111_1111 2#0001_0000_0000_0000
Hexa decimal W#16#0 to W#16#FFFF W#16#1000
number
BCD C#0 to C#999 C#998
Decimal number B#(0,0) to B#(255,255) B#(10,20)
(unsigned)
DWORD (Double 32 Dual number 2#0 to 2#1000_0001_0001_1000_10
word) 2#1111_1111_1111_1111_1111_1111 11_1011_0111_1111
_1111_1111
Hexa decimal DW#16#0000_0000 to DW#16#00A2_1234
number DW#16#FFFF_FFFF
Decimal number B#(0,0,0,0) to B#(255,255,255,255) B#(1,14,100,120)
(unsigned)
INT (Integer) 16 Decimal number -32768 to 32767 1
DINT (Integer, 32 32 Decimal number L#-2147483648 to L#2147483647 L#1
bits)
REAL (Floating 32 IEEE Floating point High limit: +/-3.402823e+38 1.234567e+13
point number) number Low limit: +/-1.175495e-38
S5TIME 16 S7 time in S5T#0H_0M_0S_10MS to S5T#0H_1M_0S_0MS
(Simatic time) increments of 10 S5T#2H_46M_30S_0MS und S5TIME#1H_1M_0S_0MS
ms S5T#0H_0M_0S_0MS
TIME 32 IEC time in -T#24D_20H_31M_23S_648MS to T#0D_1H_1M_0S_0MS
(IEC time) increments of 1ms, T#24D_20H_31M_23S_647MS TIME#0D_1H_1M_0S_0MS
signed integer
DATE 16 IEC date in D#1990-1-1 to D#2168-12-31 DATE#1994-3-15
(IEC date) increments of 1
day
TIME_OF_DAY 32 Time of day in TOD#0:0:0.0 to TOD#23:59:59.999 TIME_OF_DAY#1:10:3.3
increments of 1ms
CHAR 8 ASCII character ´A´, ´B´ etc.. ´B´

Note: The data types ’INT’ and ’REAL’ are very important to analog value processing, since
input analog values are present as integers in the format ’INT’, and for exact continued processing,
only floating point numbers ’REAL’ can be used because of rounding errors regarding ’INT’.

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 8 of 14 Module


B2
Ausgabestand: 02/2008 Analog Value Processing
Automation and Drives - SCE

4. MATHEMATICAL OPERATIONS
4.1 CALCULATING WITH THE FIXED POINT NUMBERS (INT AND DINT)

With fixed point numbers, the basic mathematical operations Addition, Subtraction, Multiplication
and Division are performed. However, digits after the decimal point are not taken into account which
causes rounding errors regarding division.

Operation Size in Bits Function


+I 16 Adds the content of the less significant word of ACCU 1 and 2, and stores the result
in the less significant word of ACCU1.
-I 16 Subtracts the content of the less significant word of ACCU 1 from the content of the
less significant word of ACCU 2, and stores the result in the less significant word of
ACCU1.
*I 16 Multiplies the content of the less significant words of ACCU 1 and 2 and
stores the result (32 bits) in ACCU 1.
/I 16 Divides the content of the less significant word of ACCU 2 by the content of the less
significant word of ACCU 1. The result is stored in the less significant word of
ACCU 1. The remainder is stored in the more significant word of
ACCU 1.
+D 32 Adds the content of ACCU 1 and 2 and stores the result in ACCU 1.
-D 32 Subtracts the content of ACCU 1 from the content of ACCU 2 and stores the result
in ACCU 1.
*D 32 Multiplies the content of ACCU 1 with the content of ACCU 2 and stores the result
in ACCU 1.
/D 32 Divides the content of ACCU 2 by the content of ACCU 1 and stores the quotient in
ACCU 1.
MOD 32 Divides the content of ACCU 2 by the content of ACCU 1 and stores the remainder
in ACCU 1.

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 9 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

4.2 CALCULATING WITH FLOATING POINT NUMBERS (REAL)

Floating point numbers can be used for performing a large number of mathematical operations. For
this format, the decimal positions are also taken into account.

Operation Function
+R Adds up floating point numbers (32 bits, IEEE-FP) in ACCU 1 and 2 and stores the 32 bit
result in ACCU 1.
-R Subtracts the floating point number (32 bits, IEEE-FP) in ACCU 1 from the floating point number (32
bits, IEEE-FP) in ACCU 2 and stores the 32 bit result in ACCU 1.
*R Multiplies the floating point number (32 bits, IEEE-FP) in ACCU 1 with the floating point number (32
bits, IEEE- FP) in ACCU 2 and stores the 32 bit result in ACCU 1.
/R Divides the floating point number (32 bits, IEEE-FP) in ACCU 2 by the floating point number
(32 bits, IEEE-FP) in ACCU 1. The 32 bit result is stored in ACCU 1.
ABS Generates the absolute value of a floating number (32 bits, IEEE-FP) in ACCU 1. The result is
stored in ACCU 1. The operation is performed without taking the status bits into account, or
influencing them.
SQRT Calculates the square root of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the
32 bit result in ACCU 1.
SQR Calculates the square of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the 32
bit result in ACCU 1. ÁÁÁÁÁ
LN Calculates the natural logarithm of the floating point number (32 bits, IEEE-FP) in ACCU 1 and
stores the 32 bit result in ACCU 1.
EXP Calculates the exponential value of the floating point number (32 bits, IEEE-FP) to base e and
stores the 32 bit result in ACCU 1.
SIN Calculates the sine of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the 32 bit
result in ACCU 1. ÁÁÁÁÁ
COS Calculates the cosine of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the 32
bit result in ACCU 1.
TAN Calculates the tangent of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the 32
bit result in ACCU 1
ASIN Calculates the arc sine of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the 32
bit result in ACCU 1. ÁÁÁÁÁ
ACOS Calculates the arc cosine of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the
32 bit result in ACCU 1. ÁÁÁÁÁ
ATAN Calculates the arc tangent of the floating point number (32 bits, IEEE-FP) in ACCU 1 and stores the
32 bit result in ACCU 1.

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 10 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

4.3 DATA TYPE AND CONVERSION OPERATIONS

Since numbers are often not available in the number formats required for continued processing, they
have to be adapted by using conversion operations.

Operation Function
BTI Converting a BCD into an integer (16 bits). This operation converts a binary coded decimal value
in ACCU 1 into an integer (16 bits).
BTD Converting a BCD into an integer (32 bits). This operation converts a binary coded decimal value in
ACCU 1 into an integer (32 bits).
ITB Converting an integer (16 bits) into a BCD. This operation converts an integer (16 bits) in the less
significant word of ACCU 1 into a binary coded decimal value.
ITD Converting an integer (16 bits) into an integer (32 bits). This operation converts an integer (16 bits) in
the less significant word of ACCU 1 into an integer (32 bits).
DTB Converting an integer (32 bits) into a BCD. This operation converts an integer (32 bits) in ACCU 1
into a binary coded decimal value.
DTR Converting an integer (32 bits) into a floating point number (32 bits, IEEE-FP). This operation
converts an integer (32 bits) in ACCU 1 into a floating point number (32 bits, IEEE-FP).
RND Rounding off into an integer. This operation rounds off the converted number into the next integer. If
the fraction of the converted number is exactly between an even and an uneven result, the operation
selects the even result.
RND+ Rounding off to the next higher integer. This operation rounds off the converted number to the lowest
integer that is larger or equal to the converted floating point number.
RND- Rounding off to the next lower integer. This operation rounds off the converted number to the highest
integer that is lower or equal to the converted floating point number.
TRUNC Rounding off with truncation. This operation converts the integer part of the floating point number

Note: Regarding analog value processing, the analog value is present in ’INT’ and -for
exact continued processing- is to be converted into a floating point number ’REAL’
because of the rounding errors in the case of ’INT’. Since this can’t be done directly,
first a conversion has to be made with ’ITD’ to ’DINT’ and then with ’DTR’ to ’REAL’.

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 11 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

5. ENTERING/READING OUT ANALOG VALUES

Analog values are entered in the PLC or read out as word information. These words are accessed
with the following instructions:

L PEW x for ‘Load analog input word’


T PAW x for ‘Transfer analog output word’

To each analog value ("channel“), an IO input word or an IO output word is assigned. The format is
’INT’, an integer.

Addressing the input and output words is based on the module’s start address. If the analog module
is inserted in Slot 4, it has the default start address 256. The start address for each additional analog
module increases by 16 per slot.
This default start address can be looked up in the hardware configuration table under Detail View.

Thus, the address of the first analog input for an analog module would be PEW 288 on Slot 6, the
address of the second analog input PEW 290, the address of the first analog output therefore PAW
288 etc..

The analog value transformation for further processing in the PLC (digitalized) is the same for analog
inputs and analog outputs.
For module SM334, with 4 analog inputs and 2 analog outputs, and with the analog value ranges
0 to 10V as well as 0 to 20mA, the digitalized value ranges look like this:

Nominal range of the


0A 10mA/5V 20mA/10V analog value

0 13824 27648 Digitalized value for further


processing in the PLC

Often, these digitalized values have to be normalized through corresponding further processing in
the PLC.

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 12 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

5.1. ENTERING AND NORMALIZING ANALOG VALUES

If the analog input value is a digitalized value, it usually has to be normalized before it can be
processed further in the PLC.
Likewise, the analog output to the IO output word is usually made only after the output value is
normalized.

In STEP7 programs, mathematical operations are used for normalizing.


For this to be done as exactly as possible, the values have to be converted into the data type REAL
for normalizing, so that the rounding errors are kept to a minimum.

Exercise:

In the example below, a value from 0 to 10V is entered with an analog module SM334 on Slot 6
(PEW288). Initially, the value is an INTEGER (16 bits) and is to be normalized to 100 to 1000 in the
floating point format, and stored in the flag double word MD10.

Solution in STL:

L PEW 288 //Enter analog value; 0 to 10 V corresponds to 0 to 27648 integer (16 bits)
ITD //Convert the value of the integer (16 bits) to integer (32 bits)
DTR // Convert the value of the integer (32 bits) into floating point number
L 2.7648e+4 //
/R //Division with floating point number 27648
L 9.000e+2 //
*R // Multiplication with floating point number 900 (1000 - 100)
L 1.000e+2 //
+R // Addition with floating point number 100 (offset)
T MD10 //Normalized value 100 to 1000 in floating point format

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 13 of 14 Module


B2
Issued: 02/2008 Analog Value Processing
Automation and Drives - SCE

5.2. NORMALIZING AND READING OUT ANALOG VALUES

If there is a normalized value and it is to be read out on an analog output module, it has to be
suitably normalized.

In STEP7 program, mathematical operations are used for normalizing. This is done in the data type
REAL, to keep the rounding errors to a minimum. Only then is this value rounded off to an integer
value. The digits after the decimal point are lost.

Exercise:

In the example below, there is a value from 100 to 1000 -stored in the floating point format on the
flag double word MD20- which is, normalized from 0 to 10V, to be read out with an analog module
SM334 (PAW288).

Solution in STL:

L MD20 // Value100 to 1000 in floating point format


L 1.000e+2 //
-R // Subtraction with floating point number 100 (offset)
L 9.000e+2 //
/R // Division with floating point number 900
L 2.7648e+4 //
*R // Multiplication with floating point number 27648
RND // Rounding off to integer
T PAW 288 // 0 to 27648 integer (16 bits) corresponds to analog value output 0 to 10 V

Preface Analog Signals Data Types Math Operations Entering/Reading Out Analog Values

T I A Training Document Page 14 of 14 Module


B2
Issued: 02/2008 Analog Value Processing

You might also like