Sie sind auf Seite 1von 37

Micro Application Example

Speed Measurement of Rotating Shafts or Drives


(with S7-200 CPU and shaft angle encoder)

Micro Application Example 1C Issue 05/2004

Structure of the document

Part A1
Automation solution (incl. component list/basic performance data)

Part A2
Function mechanisms in detail

Part B
Setup and commissioning step by step

Part C
Program description and program changes

Micro Application Examples


the quickest way to the solution
Foreword

MAE 1C

Foreword
Structure of the document
Part Description Note
A1 Automation Solution
Part A1 gives you a general overview of the contents.
You learn about the components used (standard
hardware and software components and the
additionally developed software).
The basic function data illustrates the powerful
performance of this application.
A2 Function Mechanisms in Detail You can skip this part if you
Part A2 provides a detailed description of the function only want to test the
processes of the hardware and software components application using step-by-
involved. Read this part if you want to know what the step instructions.
functions do and how the solution components
interact.
Copyright  Siemens AG 2004 All rights reserved

B Setup and Commissioning Step by Step


Part B takes you step by step through installation and
start-up of the application.
Doku_Drehzahlmessung_e.doc

C Program Description and Program Changes


Part C is of interest if you want to take the software
MAE1C

and expand or adapt it to your set-up.

Liability
Siemens AG does not accept liability of any kind for damages arising from the use of this
document, except where they are obliged to by law, in case of damage to items used for
personal purposes, personal injury or due to willful damage or gross negligence.

Warranty
This Application Description includes selected suggested solutions prepared by Customer
Support in response to inquiries concerning complex tasks. Furthermore, we wish to point
out that the present state of the art does not allow to exclude errors in software programs for
all situations and conditions of application. All program examples have been prepared to the
best of our knowledge. However, we cannot accept any liability beyond the standard
guarantee for Class C software in accordance with our "General Terms of Sale for Software
Products for Automation and Drive Technology". The program examples can be purchased
on the Internet as single licenses. It is illegal to transfer them to a third party.

1.0 14.05.2004 2/37


Table of Contents

MAE 1C

Table of Contents
Preamble ........................................................................................................................ 4
Basic solution principle of this application...................................................................... 5
Part A1: Application Description ............................................................................................... 6
1 Automation Task.......................................................................................................... 7
A typical industrial case.................................................................................................. 7
Operator control and monitoring .................................................................................... 7
2 Automation Solution.................................................................................................... 9
2.1 Standard, hardware and software (“shopping list”)...................................................... 11
2.2 Application software components ................................................................................ 11
2.3 Alternative solution....................................................................................................... 12
3 Basic Performance Data............................................................................................ 14
Part A2: Function Mechanisms................................................................................................ 19
4 Function Mechanisms ............................................................................................... 20
Copyright  Siemens AG 2004 All rights reserved

4.1 Description of entire solution structure ........................................................................ 20


Doku_Drehzahlmessung_e.doc

4.1.1 Central intelligence (S7-200 CPU)............................................................................... 20


4.1.2 Shaft angle encoder..................................................................................................... 22
4.1.3 Operator control and monitoring (TP070) .................................................................... 24
MAE1C

4.2 Program and data structure ......................................................................................... 25


Part B: Installation of the Example Application ..................................................................... 27
5 Hardware and Software Installation......................................................................... 28
5.1 Hardware configuration................................................................................................ 28
5.2 Software installation..................................................................................................... 30
6 Operating the Application ......................................................................................... 32
6.1 Quick startup ................................................................................................................ 32
6.2 Detailed description of individual operator screens ..................................................... 33
Part C: Program Description .................................................................................................... 35
7 Explanation of the Main Parts of the S7-Micro/Win Program................................ 36
7.1 Sub-program INIT ........................................................................................................ 36
7.2 Sub-program HSC_INIT............................................................................................... 36
7.3 Sub-program Turns...................................................................................................... 36
7.4 Interrupt program Read_HSC ...................................................................................... 37

1.0 14.05.2004 3/37


Part A1: Application Description

MAE 1C

Preamble
The application on hand deals with the “speed measurement of rotating
shafts”.
It is assumed that it is possible to record the rotary movement of the system
(e.g. conveyor belt drive or agitator) with a shaft angle encoder.
The application described here requires the following component types:
• S7-222 CPU (DC)
• Shaft angle encoder
• LOGO! Power 24V 1.3A
• Touch Panel TP070
The shaft angle encoder mentioned above is also available in other
versions with different ratings; the application described here refers to a
type of shaft angle encoder which is common on the market:
Copyright  Siemens AG 2004 All rights reserved

If you use the components mentioned above, the application on hand offers
a Plug&Play solution for speed measurement.
Doku_Drehzahlmessung_e.doc

But you may also benefit from this application if you select other products
from the specified product types (e.g. other shaft angle encoder). Our
MAE1C

detailed description of the function mechanisms and of the user program


will help you to choose functional features that suit your specific
requirements (e.g. with regard to the HW components used).
An additional solution variant of the application is explained in detail in the
chapter “Alternative Solution”. You will find information on how the
alternative can be realized in a simple way.

1.0 14.05.2004 4/37


Part A1: Application Description

MAE 1C

Basic solution principle of this application


In order to realize a speed measurement process, the application uses
different standard components (hardware and software).
These have to be provided by you (please cf. figure 1-1). The delivered
application software relieves you of time-consuming parameterizing and
programming of the standard components and offers you a convenient way
of quick implementation of the speed measurement.

Fig. 1-1
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Possible fields of use for this application include


• agitators
• conveyor belt drives
• compressors
• spindle drives
• rotating machine tools
• fans

1.0 14.05.2004 5/37


Part A1: Application Description

MAE 1C

Part A1: Application Description


Overview
Content of Part A1
Part A1 gives you a general overview of the contents. You learn about the
components used (standard hardware and software components and the
additionally developed software).
The basic function data illustrates the powerful performance of this
application.

Objectives of Part A1
Part A1 of this document provides the reader with information on
• pinpointing the automation problem
• a solution (incl. alternative solution)
Copyright  Siemens AG 2004 All rights reserved

• the performance of the entire application


Doku_Drehzahlmessung_e.doc

Topics
MAE1C

Chap. Title Page


1 Automation Task 7
2 Automation Solution 9
2.1 Standard, hardware and software (“shopping list”) 11
2.2 Application software components 11
2.3 Alternative solution 12
3 Basic Performance Data 14

1.0 14.05.2004 6/37


Part A1: Application Description
Overview

MAE 1C

1 Automation Task
A typical industrial case
A container holds a liquid/dough material which is kneaded. As the
kneading process continues, the fluid/dough material becomes tougher
which, however, depends on the composition. The agitator speed drops as
the mass becomes tougher which is a measure for the progress of the
process.
Fig. 1-1
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Note This application deals exclusively with the speed of the agitator/motor.

Operator control and monitoring


Apart from the technological functionality, the application shall offer both a
comfortable and flexibly adjustable HMI connection. The criteria to be
monitored include:
• current speed
• status information (forward, backward, stop)

1.0 14.05.2004 7/37


Part A1: Application Description
Overview

MAE 1C

Parameters for the following must be fully operable:


• shaft angle encoder resolution
• updating time (time interrupt)
• filtering time (hysteresis time to prevent flickering of the status of the
direction of movement)

"Abstract" approach to the application requirements


The application shall be compatible with the "given" hardware components
(S7-CPU 222, TP070, and SIEMENS shaft angle encoders).
In combination with the "application software", the system offers specific
performance characteristics which define the range of possible applications
that can be realized with this solution.
The Plug&Play version of this application (i.e. in combination with the
defined hardware components, see above) is suitable for use with systems
that meet the following basic data:
Copyright  Siemens AG 2004 All rights reserved

Basic data of the application


Doku_Drehzahlmessung_e.doc

Table 1 -1

Criterion Basic performance Additional note


MAE1C

data
The test setup which was used to determine the
basic performance data, allowed to generate only
speeds up to 1200 rpm.
The shaft angle encoder used theoretically allows
to generate up to 2400 revolutions per minute.
Speed measuring range 0 to min.1200 rpm Use a shaft angle encoder with a lower resolution
for higher speeds.
Note the technical data of the high-speed
counter integrated in the S7-200 CPU!
(max. counting frequency!)
Update time 50 to 255ms (configurable)

Measuring direction
positive Signaling wrong counting direction and standstill
(counting direction)

Scalability
In principle, the „application software“ can also be used with other shaft
angle encoders or S7-200 CPUs which offers an extended range of
possible applications.

Note The above mentioned requirements are met by the application software,
without need for any additional programming.

1.0 14.05.2004 8/37


Part A1: Application Description
Overview

MAE 1C

2 Automation Solution
General
This chapter provides you with detailed information on how the application
on hand solves the automation problem described in chapter 1. It shows
what the application can do and how it works. Its functions are described in
universally applicable terms. Part A2 of this documentation includes in-
depth information which you will only need if you are interested in the
detailed processes and the interactions between the individual solution
components.

Functional hardware display


Fig. 2-1
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

1.0 14.05.2004 9/37


Part A1: Application Description
Overview

MAE 1C

Function description
The agitator performs a rotary movement. The shaft angle encoder records
this movement.
The S7-CPU 222 counts the pulses of the shaft angle encoder and forms a
difference between the new and old counter statuses in a defined TIME
cycle, only if the direction of rotation is positive. At the end of the defined
time cycle the calculation is enabled. If a negative direction of rotation or
standstill is detected, the status bits are set accordingly.
The actual calculation from the difference between the counter statuses is
done in the “normal” CPU cycle. When the calculation is enabled, the
difference between the old and new counter statuses is scaled to one
minute and divided by the shaft angle encoder resolution.
The following status diagram shows the actual speed of the plant (below).
In dependence on it, the counter status, measured speed, time of counter
status read-out and operating status are displayed.
Fig. 2-2
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Note The change of the actual speed always occurs in this figure at the time
when the counter is read out. The speed change at this point of time is
displayed like this only for a better understanding. Since, however, the
counter is read out every 50-255ms and speed changes mostly occur
continuously, the resulting measuring error is insignificant.

1.0 14.05.2004 10/37


Part A1: Application Description
Overview

MAE 1C

Functions of the individual hardware components in the overall solution


Table 2 -1
No. Category Hardware component Main function, feature
1 Visualization TP070 Operator control and monitoring
Calculation of the speed from the difference between
2 Higher-level intelligence S7-222 CPU (DC)
two counter statuses in a known time cycle
3 High-speed counter Part of the S7-222 CPU Counting the pulses of the shaft angle encoder
4 Recording of rotary Shaft angle encoder Generating pulses in dependence on speed
movement
5 LOGO! Power Power supply

2.1 Standard, hardware and software (“shopping list”)


Component Type MLFB / Order number No. Manufacturer
S7-200 CPU S7-CPU 222 DC 6ES7212-1AB22-0XB0 1 SIEMENS A&D
Power supply LOGO! Power 6EP1331-1SH02 1
Shaft angle encoder Shaft angle encoder 500 pulses 6FX2001-4SA50 [500] 1
Connection cable
Copyright  Siemens AG 2004 All rights reserved

Connection cable/
shaft angle encoder 6FX5002-2CA12-1AD0 1
signal line (3m)
S7-200Ùshaft angle encoder
Doku_Drehzahlmessung_e.doc

Touch Panel TP070 6AV6545-0AA15-2AX0 1


Connection cable TP070
MPI cable 6ES7901-0BF00-0AA0 1
S7-200ÙTouch Panel
MAE1C

Software components
Component Type MLFB / Order number No. Manufacturer
STEP7 MicroWin 32 From V3.2 SP4 6ES7810 2BC02 0YX0 1 SIEMENS A&D
TP Designer From V1.0 6ES7850-2BC00-0YX0 1
PC/PPI cable 6ES7901-3CB30-0XA0
Connection cable USB/PPI cable 6ES7901-3DB30- 1
0XA0

2.2 Application software components

No. Name Function description Technical data

Main (OB1) Call of the sub-programs


1

Init (SBR0)
2 Initializes interrupt programs and high-speed counter
405Bytes
3 HSC_INIT (SBR1) Wizard block for initialization of the high-speed counter
4 Revolutions (SBR3) Conversion of counter status into revolutions per minute
Within constant time intervals, the counter status is read out
5 Read_HSC (INT0) and a difference between the new and old counter statuses is
formed
6 Data block Central storage of initialization values 20Bytes

1.0 14.05.2004 11/37


Part A1: Application Description
Overview

MAE 1C

2.3 Alternative solution

This chapter shows the alternative solutions which can be used in principle
to realize a speed measurement.
The solution described here is a lower-priced alternative with a lower
measuring quality. Advantage: Remote.

This alternative is only a basic solution which has not been coded
explicitly and which has not been tested in the system.
Note
Here only one alternative out of several possible solutions is
demonstrated.

General
This solution is also demonstrated with an agitator used as the
technological example.
Copyright  Siemens AG 2004 All rights reserved

However, the speed information is not obtained with a shaft angle encoder,
Doku_Drehzahlmessung_e.doc

but with a BERO.

Setup diagram
MAE1C

A BERO emits light which is reflected by the reflective foil on the shaft. This
means that one pulse is obtained per full shaft rotation. (If 2 reflectors are
used which are offset by 180°, 2 pulses per rotation are obtained, etc.)

1.0 14.05.2004 12/37


Part A1: Application Description
Overview

MAE 1C

Hardware components
Component Type MLFB / Order number No. Manufacturer
S7-200 CPU S7-CPU 222 (DC!) 6ES7212-1AB22-0XB0 1 SIEMENS A&D
Power supply LOGO! Power 6EP1331-1SH02 1
Opto-BERO 3RG7121-0AB00 1
Optical BERO
Reflective foil (to be stuck on) 3RX7917 1

Method of Function
In principle, in this alternative solution the speed information is not obtained
from a shaft angle encoder but from another sensor (in this case a BERO).
Any sensor may be used here. For the solution described here, an optical
BERO (light barrier) is used.
An inductive BERO at gear unit parts (e.g. toothed wheel) is another option
which would permit a higher resolution.
Since there are several solution options with a BERO, two variants will be
shown in the following which are especially suitable for the measurement of
Copyright  Siemens AG 2004 All rights reserved

low or high speeds.


Doku_Drehzahlmessung_e.doc

High speeds (high pulse frequencies)


The pulses of the BERO are counted in a defined time interval and divided
MAE1C

by the number of pulses per shaft revolution (= resolution). As a result you


get a speed value for the defined time interval. When you scale this value
to a minute, the value is obtained in the common unit “revolutions per
minute”.

The program code of the MAE 1C speed measurement can be used as basis for
adjustments.
Tip The program must be adapted so that not the pulses of the shaft angle encoder (A/B
counter) are counted but the pulses of the BERO (normal counter).

Low speeds (low pulse frequencies)


The time is measured until two pulses of the BERO have passed. As a
result you get the time for one revolution. When you scale this value to a
minute, the value is obtained in the common unit “revolutions per minute”.

The program code of the MAE 1B speed measurement can be used as basis for
adjustments.
Tip The program must be adapted so that the start and stop pulses are not generated by two
different BEROs but only by one BERO. Additionally, the (angular)
velocity must be converted into a speed.

1.0 14.05.2004 13/37


Part A1: Application Description
Overview

MAE 1C

3 Basic Performance Data


General
The following chapter gives a summary of the performance of this
application.
Measurements of the application with the specified components were
performed based on a test setup.
In principle, the test setup is a stepper motor which “drives” the shaft angle
encoder via a belt.
Due to the stepper motor principle it is possible to generate a defined
speed whose amount is known and also relatively constant.

Fig. 3-1
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Influencing factors
The basic performance data is influenced by the following factors:
• Constancy of the time-controlled interrupt call (measuring cycle)
(the more constant the (call) frequency of the time-controlled interrupt, the more exact
the measurement)

• Resolution/accuracy of the shaft angle encoder


(high-resolution shaft angle encoders are advantageous for slow movements)

A series of measurements was performed regarding any of the two points


which illustrates the problem using the application as an example.

1.0 14.05.2004 14/37


Part A1: Application Description
Overview

MAE 1C

Description of measured value table 1


A number of 15 series of measurements are included in the following table
for a defined speed of 1200 rpm. In the series of measurements, the cycle
time of the time-controlled interrupt call was varied.
The gray lines give the cycle time of the time-controlled interrupt call. They
are followed by the series of measurements with 40 repetitions each.
The light gray lines give intermediate values for further calculations. They
are not dealt with in detail.
The blue lines show the following evaluations:
• The line Ø [rpm] shows the mean value of the respective series of
measurements.
• The column Dispersion shows the range of the measured value
dispersion which is a measure of reproducibility accuracy.
• The column Max. error shows the highest absolute error of the
Copyright  Siemens AG 2004 All rights reserved

forty’s series of measurements.


The orange-colored line shows the percentage evaluation of the
Doku_Drehzahlmessung_e.doc

maximum error.
MAE1C

1.0 14.05.2004 15/37


Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Part A1: Application Description


Overview

MAE 1C
Cycle 40 50 60 70 80 90 100 120 140 160 180 200 220
1192,5 1194,6 1196 1195,714 1196,25 1196,667 1197 1197,5 1198,286 1198,313 1198,5 1198,5 1198,773
1191,75 1194,6 1195,5 1195,714 1196,25 1197,333 1196,7 1197,5 1198,072 1198,313 1198,5 1198,65 1198,773
1194 1194,6 1195,5 1195,286 1197 1197 1197 1198 1198,072 1198,313 1198 1198,5 1198,636
1193,25 1194,6 1195,5 1197 1195,875 1197,333 1197 1197,25 1198,072 1198,125 1198,5 1198,8 1198,773
1193,25 1194,6 1194,5 1196,143 1197 1196,333 1197 1198 1198,072 1198,313 1198,5 1198,65 1198,5
1192,5 1194,6 1196 1196,143 1196,25 1197 1196,7 1197,5 1198,286 1198,313 1198,667 1198,5 1198,5
1193,25 1194,6 1195 1196,572 1196,625 1197 1197,6 1197,5 1197,643 1198,313 1198,5 1198,65 1198,773
1192,5 1194,6 1195,5 1195,714 1196,625 1197 1197,3 1197,5 1198,286 1198,313 1198,5 1198,65 1198,364
1193,25 1194 1195,5 1196,572 1196,625 1196,667 1197 1197,75 1198,286 1198,313 1198,5 1198,5 1198,773
1192,5 1195,2 1195,5 1196,572 1196,625 1197 1196,7 1197,5 1198,286 1198,313 1198,5 1198,5 1198,773
1192,5 1194,6 1195,5 1196,143 1195,875 1196,667 1197,6 1197,75 1198,072 1198,125 1198,5 1198,65 1198,5
1191,75 1194,6 1195,5 1196,572 1196,625 1196,667 1197,3 1197,5 1198,072 1198,5 1198,5 1198,65 1198,909
1192,5 1194,6 1195 1195,714 1197 1197,333 1197 1197,5 1198,286 1198,125 1198,5 1198,65 1198,773
1193,25 1194,6 1195,5 1196,572 1196,625 1197,333 1197 1197,5 1198,072 1198,125 1198,5 1198,65 1198,773
1193,25 1194 1195,5 1196,572 1196,625 1196,667 1197 1197,5 1198,072 1198,313 1198,5 1198,5 1198,773
1192,5 1194,6 1195 1195,714 1196,625 1196,667 1197,6 1197,5 1198,072 1198,313 1198,5 1198,65 1198,364
1192,5 1194,6 1196,5 1196,572 1196,25 1197 1197 1197,5 1198,286 1198,313 1198,5 1198,35 1198,636
1192,5 1194,6 1194,5 1196,143 1197 1197 1197 1197,75 1198,072 1198,313 1198,333 1198,65 1198,773
Repetitions

1192,5 1194 1196 1196,143 1196,25 1197 1197 1197,5 1197,857 1198,313 1198,5 1198,5 1198,636
[rpm]

1192,5 1195,2 1195 1196,572 1196,625 1196,667 1197 1197,75 1198,286 1198,313 1198,667 1198,8 1198,773
1192,5 1194 1196 1196,572 1195,5 1197,333 1196,7 1197,5 1197,857 1198,313 1198,333 1198,65 1198,773
1192,5 1194,6 1194,5 1196,572 1195,875 1197 1197,3 1197,25 1198,072 1198,313 1198,667 1198,5 1198,773
1193,25 1194,6 1195 1195,714 1197 1196,667 1197,6 1197,75 1198,286 1198,313 1198,5 1198,5 1198,773
1193,25 1194 1195,5 1196,572 1196,25 1197,333 1197 1197,5 1198,072 1198,313 1198,5 1198,8 1198,5
1193,25 1194,6 1195,5 1195,286 1197 1196,667 1196,7 1197,25 1197,857 1198,313 1198,5 1198,65 1198,636
1192,5 1194,6 1195,5 1196,572 1195,875 1196,667 1197,3 1198,25 1198,5 1198,313 1198,5 1198,65 1198,773
1192,5 1194,6 1195,5 1196,572 1197 1197 1197,3 1197,5 1197,857 1198,313 1198,667 1198,8 1198,773
1192,5 1194,6 1196 1195,286 1196,25 1197 1197 1197,75 1198,286 1198,5 1198,5 1198,5 1198,636
1192,5 1194,6 1194 1196,572 1196,25 1197 1197,3 1197,5 1198,072 1198,313 1198,333 1198,8 1198,773
1191,75 1194,6 1195,5 1195,286 1196,625 1197 1197,3 1197,5 1198,286 1198,313 1198,333 1198,5 1198,909
1194 1194,6 1195 1195,714 1196,25 1196,667 1197,3 1197,25 1197,857 1198,313 1198,5 1198,65 1198,773
1192,5 1194,6 1196 1196,572 1196,25 1196,667 1197 1198 1198,286 1198,5 1198,5 1198,8 1198,773
1193,25 1194,6 1194,5 1195,714 1196,625 1197 1197 1197,75 1198,072 1197,938 1198,5 1198,8 1198,636
1192,5 1194,6 1195 1196,572 1196,25 1197 1197,3 1197,5 1197,857 1198,5 1198,333 1198,65 1198,773
1193,25 1194,6 1196 1196,572 1196,625 1197 1197,3 1198 1198,286 1198,313 1198,833 1198,65 1198,773
1193,25 1194,6 1194,5 1195,714 1196,25 1197,333 1197,3 1197,5 1197,214 1198,313 1198,333 1198,65 1198,773
1192,5 1194,6 1195,5 1196,572 1196,625 1197 1197 1197,5 1198,929 1198,313 1198,667 1198,65 1198,773
1192,5 1194,6 1195,5 1195,714 1196,625 1196,667 1197 1198 1198,072 1198,125 1198,333 1198,8 1198,773
1193,25 1194,6 1195 1196,572 1195,5 1197 1197 1197,5 1198,072 1198,313 1198,333 1198,5 1198,773
1191 1194,6 1195 1196,143 1196,25 1197,333 1196,7 1197,5 1198,072 1198,313 1198,5 1198,8 1198,773

Max. value [rpm] 1194 1195,2 1196,5 1197 1197 1197,333 1197,6 1198,25 1198,929 1198,5 1198,833 1198,8 1198,909
Min. value [rpm] 1191 1194 1194 1195,286 1195,5 1196,333 1196,7 1197,25 1197,214 1197,938 1198 1198,35 1198,364

Ø [rpm] 1192,725 1194,555 1195,3375 1196,17525 1196,4375 1196,9417 1197,0975 1197,6 1198,10925 1198,29883 1198,4833 1198,63125 1198,7115
Dispersion [rpm] 3 1,2 2,5 1,714 1,5 1 0,9 1 1,715 0,562 0,833 0,45 0,545
Max. error [rpm] 9 6 6 4,714 4,5 3,667 3,3 2,75 2,786 2,062 2 1,65 1,636
Max. error% 0,75% 0,50% 0,50% 0,39% 0,38% 0,31% 0,27% 0,23% 0,23% 0,17% 0,17% 0,14% 0,14%

1.0 14.05.2004 16/37


Part A1: Application Description
Overview

MAE 1C

Description of measured value table 2


A number of 14 series of measurements are included in the following table
for a defined speed of 10 rpm to 1200 rpm.
The gray lines give the defined speed of the measurement. They are
followed by the series of measurements with 20 repetitions each.
The light gray lines give intermediate values for further calculations. They
are not dealt with in detail.
The blue lines show the following evaluations:
• The line Ø shows the mean value of the respective series of
measurements given in revolutions per minute.
• The column Ø error shows the mean error, given in revolutions
per minute.
• The column Dispersion shows the range of the measured value
dispersion which is a measure of reproducibility accuracy.
Copyright  Siemens AG 2004 All rights reserved

• The column Max. error shows the highest absolute error of the
forty’s series of measurements.
Doku_Drehzahlmessung_e.doc

The orange-colored lines show the percentage evaluation of the


MAE1C

maximum and mean errors.

1.0 14.05.2004
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Part A1: Application Description


Overview

MAE 1C

Default stepper motor (ACTUAL speed)


Actual speed 10 20 40 60 80 100 200 300 400 500 600 800 1000 1200

Measurement # Speeds measured with shaft encoder [rpm]


1 9,9 20,1 40,2 59,7 79,8 99,9 199,2 299,7 399 498 598,5 795,9 998,7 1197
2 9,9 20,1 39,9 60 79,8 99,6 199,8 299,1 399,6 498,6 598,5 797,1 997,2 1194,3
3 9,9 19,5 39,6 60 80,1 99,9 199,2 298,8 398,7 498,9 597,9 795,3 996,6 1198,5
4 9,9 20,1 39,9 60 79,8 99,6 199,5 299,4 399 498,6 598,8 795,9 998,4 1197,6
5 9,9 20,1 39,6 60 79,5 99,6 200,1 299,4 398,7 499,2 598,8 796,8 995,7 1195,5
6 9,9 19,8 39,6 59,7 79,8 99,9 199,2 298,8 399 498,9 598,2 796,8 997,8 1197,3
7 10,2 20,1 40,2 59,7 79,8 99,6 199,2 299,4 398,7 498,6 598,5 796,8 997,8 1196,4
8 9,9 20,1 39,6 60 79,8 100,2 200,1 298,8 399,6 498,6 598,8 796,8 996,3 1196,7
9 9,9 19,8 39,6 59,7 80,1 99,9 199,2 299,4 398,7 498,6 598,2 796,2 998,7 1195,5
10 9,9 20,1 40,2 59,7 79,8 99,6 199,5 299,4 398,4 498,9 598,8 796,8 996,6 1198,2
11 9,9 20,4 39,9 59,7 79,8 99,3 199,2 299,1 399,3 499,2 597,9 797,1 998,4 1197,6
12 10,2 19,8 39,6 60 79,8 99,9 199,5 299,1 398,4 498,9 597,9 796,2 996,9 1196,7
13 10,2 19,8 40,2 60 79,8 99,9 199,2 299,1 399,6 498,3 599,1 796,5 996,6 1197
14 9,9 20,4 39,9 60 79,5 99,3 199,5 299,4 399 498,9 598,8 795,6 997,5 1197
15 9,9 19,8 39,6 60 79,8 99,9 199,5 299,7 398,4 498,9 597,9 796,8 998,1 1196,1
16 9,9 20,1 40,2 60 80,1 99,9 199,2 299,1 399,3 498,3 598,8 796,2 996,6 1199,1
17 9,9 20,1 39,9 59,7 80,1 99,6 199,8 298,8 398,7 499,5 598,8 796,5 998,7 1195,2
18 10,2 19,8 39,9 60,3 79,5 99,9 199,5 299,7 399 498,9 598,2 795,9 996,9 1197,9
19 9,9 19,8 40,2 60 80,1 99,6 199,2 299,1 398,4 498,6 599,4 795,3 998,7 1195,5
20 9,9 20,1 39,6 59,7 79,8 99,6 199,8 298,8 399,3 498,9 597,9 797,7 995,4 1196,4

MAX 10,2 20,4 40,2 60,3 80,1 100,2 200,1 299,7 399,6 499,5 599,4 797,7 998,7 1199,1
MIN 9,9 19,5 39,6 59,7 79,5 99,3 199,2 298,8 398,4 498 597,9 795,3 995,4 1194,3
Deviation p 0,2 0,4 0,2 0,3 0,1 0,2 0,1 0,3 0,4 0,5 0,6 2,3 1,3 0,9
Deviation n 0,1 0,1 0,4 0,3 0,2 0,4 0,2 1,2 0,7 1,1 2,1 2,3 4,6 3,6
Min. deviation 0,1 0,1 0,2 0,3 0,1 0,2 0,1 0,3 0,4 0,5 0,6 2,3 1,3 0,9

Ø 9,96 20,00 39,87 59,90 79,83 99,74 199,47 299,21 398,94 498,77 598,49 796,41 997,38 1196,78
Øerror 0,04 0,005 0,13 0,105 0,17 0,265 0,53 0,795 1,06 1,235 1,515 3,59 2,62 3,225
Øerror% 0,4% 0,0% 0,3% 0,2% 0,2% 0,3% 0,3% 0,3% 0,3% 0,2% 0,3% 0,4% 0,3% 0,3%
Dispersion 0,3 0,9 0,6 0,6 0,6 0,9 0,9 0,9 1,2 1,5 1,5 2,4 3,3 4,8
Max. error 0,2 0,4 0,4 0,3 0,2 0,4 0,2 1,2 0,7 1,1 2,1 2,3 4,6 3,6
Max. error% 2,0% 2,0% 1,0% 0,5% 0,3% 0,4% 0,1% 0,4% 0,2% 0,2% 0,4% 0,3% 0,5% 0,3%

1.0 14.05.2004 18/37


Part A2: Function Mechanisms
Overview

MAE 1C

Part A2: Function Mechanisms


Overview
Content of Part A2
Part A2 provides a detailed description of the function processes of the
hardware and software components involved. Read this part if you want to
know specific details and how the solution components interact.
You will find information on the solution structure realized in this
application. For example, it explains in more detail how the ring buffer is
created and managed.

What can you do with it?


The application can really be used immediately without further ado. The
installation instructions tell you how to start it without reading this chapter.
But if you want to modify specific parts of the application, you will require
certain information, for example to convert your program sequences
Copyright  Siemens AG 2004 All rights reserved

correctly and without too much difficulty into the STEP7 code.
Doku_Drehzahlmessung_e.doc

Objectives of Part A2
MAE1C

Part A2 of this document provides the reader with information on


• all function elements involved
• those components that can be easily integrated into your own
applications.

Topics
Chap. Title Page
4 Function Mechanisms 20
4.1 Description of entire solution structure 20
4.2 Program and data structure 25

1.0 14.05.2004 19/37


Part A2: Function Mechanisms
Overview

MAE 1C

4 Function Mechanisms
4.1 Description of entire solution structure

Functional structure
Fig. 4-1
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Function units of the application


From a structural point of view, the individual functions of the application
can be broken down into different units which are discussed in the following
sections:
• Central intelligence (S7-222 CPU, see chapter 4.1.1)
• Shaft angle encoder (see chapter 4.1.2)
• Operator control and monitoring (TP070, see chapter 4.1.3)

4.1.1 Central intelligence (S7-200 CPU)

The S7-200 CPU takes on primarily the following tasks:


• evaluating the shaft angle encoder
• converting the measured value into speed

1.0 14.05.2004 20/37


Part A2: Function Mechanisms
Overview

MAE 1C

General display of the CPU functions


Fig. 4-2
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Evaluating the shaft angle encoder


The evaluation of the shaft angle encoder pulses is made via the high-
speed counter integrated in the S7-222 CPU. The number of the pulses are
a measure for the speed.
The high-speed counter is read out in known and constant time intervals. A
difference is always formed between the new and old counter statuses. The
resulting difference is a measure for the speed in this time interval.
• If the difference is positive, the shaft is in forward motion.
• If the difference is negative, the shaft is in backward motion.
• If the difference is 0, the shaft is at standstill.

In case of a power failure, the current counter contents are not


! saved retentively!
Attention A measurement (during power failure) is faulty!

1.0 14.05.2004 21/37


Part A2: Function Mechanisms
Overview

MAE 1C

Converting the measured value into speed


The difference measurement gives only information about a number of
angular steps within the measured time interval. If the information is to be
given in a standard unit, such as revolutions per minute
(rpm), a conversion must be made.
The conversion must include:
• resolution of the shaft angle encoder
• length of the time interval
The conversion formula is:
∆ 60 [seconds ]
Speed [rpm] = Counter status

Encoder resolution Time interval [seconds ]

4.1.2 Shaft angle encoder

Function
Copyright  Siemens AG 2004 All rights reserved

A luminescent source transilluminates the disc with slits stripes being fixed
on the shaft. If the disc rotates it will generate intermittently contrasts which
Doku_Drehzahlmessung_e.doc

will then be detected by a photo element. These pulses are changed into
square wave pulses and displayed.
MAE1C

Structure
Fig. 4-3

Capacitor
Scanning plate Separating plate

Photocells

Light
source

Reference mark

Direction recognition
The shaft angle encoder has two channels (A and B), i.e. theoretically there
are two shaft angle encoders. The channels are phase-shifted towards
each other by 90°, thus allowing to determine the rotational direction of the
shaft.

1.0 14.05.2004 22/37


Part A2: Function Mechanisms
Overview

MAE 1C

Fig. 4-4

Phase quadrature
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc

Pulse quadruplication
In order to increase the resolution all edges of the counter are evaluated
MAE1C

resulting in quadruplicating the pulses.


Fig. 4-5

1.0 14.05.2004 23/37


Part A2: Function Mechanisms
Overview

MAE 1C

4.1.3 Operator control and monitoring (TP070)

General
For operator control and monitoring, TP070 is used, which provides a
comfortable interface. A total of 3 figures is available, whose functions are
illustrated in the table. The TP070 is connected directly to the (PPI-)
interface of the S7-CPU 222 with a PPI-connecting line.

HMI screens and their functions


Screen Screen Function description
No.
Measuring B1 This screen displays the status of the speed measurement as well as the
currently measured speed.
Parameter B2 This figure shows the parameterization of the time for the measurement
update and of the filtering time.
System B3 Here, you can set the system properties of the TP070 interface.
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc

Screen selection
It is particularly handy for you that each screen can be selected from every
MAE1C

other screen. This is possible via a standard navigation bar at the bottom of
each screen. On this are various “sensors”. By “pressing a button” you can
move into the different screens of the project. The button of the currently
chosen screen is always highlighted.

Configuration software TP Designer


The configuration is realized via an additional software. The development
package TP Designer is an additional software and must be ordered
separately.

1.0 14.05.2004 24/37


Part A2: Function Mechanisms
Overview

MAE 1C

4.2 Program and data structure

General
This chapter explains the program and data structure of the S7 Micro/Win
program located on the S7-CPU 222.

Program structure
For better understanding, the figure uses colors: Data block ¦, sub-
programs (nesting depth 1¦ and 2¦) and OB1¦.

Fig. 4-6
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Organization block MAIN (OB1)


The organization block is processed in each cycle of the CPU. Here, the
sub-programs INIT (SBR0) and Turns (SBR4) are called.

Sub-program INIT (SBR0)


The sub-program is only called in the first cycle and initializes the program
code. Additionally, the sub-program HSC_INIT (SBR1) is called.

Sub-program HSC_INIT (SBR1)


The sub-program is only called in the first cycle and initializes the counter.
(HSC_INIT is generated by the wizard.)

Sub-program Turns (SBR4)


The sub-program is called in each cycle. It converts the counted pulses into
the speed.

1.0 14.05.2004 25/37


Part A2: Function Mechanisms
Overview

MAE 1C

Interrupt program HSC-Read (INT0)


The interrupt program is called in a defined and parameterized time interval
and it forms the difference between the old and new counter statuses.

Variables used
The designations of the variables are symbolic names and/or are explained
in a supplementary comment. Furthermore, the type and kind of variable
are indicated, as well as the blocks with read or write access to these
variables.

Variable table
Type and kind of Program block with access to the variable (R=read, W=write)
Ser Description of variables
variable
ial
no. HSC_ HSC _Read
Symbolic name Note Type IO’s DB MAIN [OB1] INIT (SBR0) Turns (SBR3)
INIT (SBR1) (INT0)

Counter status is
1 HC-old
old status
DINT VD0 RW
Copyright  Siemens AG 2004 All rights reserved

Difference R W
between old and
2 Differnce DINT VD4
new counter
Doku_Drehzahlmessung_e.doc

statuses

Value of speed in RW
Umin
3 revolutions per REAL VD12
MAE1C

minute

Shaft angle R
4 Encoder encoder DINT VD16
resolution

Intermediate RW
5 Factor value for scaling REAL VD20
to minutes

6 FILTER_TIME Filtering time Int VW10 R


Default R
7 Set_Timebase measuring/updati Byte VB9
ng time

8 updated BOOL V8.0 RW W


9 STOPPED BOOL V8.1 R W
10 BACKWARDS BOOL V8.2 R W
STOPPED_filtere W
11 BOOL V8.3
d

BACKWARDS_fil W
12 BOOL V8.4
tered

13 FORWARD BOOL V8.5 R W


14 init_new BOOL V8.6 R
15 STOP_FILTER Timer T37 RW
BACKWARDS_F RW
16 Timer T38
ILTER

11 High-speed counter HC0 W R

1.0 14.05.2004 26/37


Part B: Installation of the Example Application
Overview

MAE 1C

Part B: Installation of the Example Application


Overview
Contents of Part B
Part B takes you step by step through installation and start-up of the
application.

Objectives of Part B
Part B of this document provides the reader with information on
• the installation of the example with all hardware/software components
• how to manipulate the application

Topics
Chap. Title Page
Copyright  Siemens AG 2004 All rights reserved

5 Hardware and Software Installation 28


5.1 Hardware configuration 28
Doku_Drehzahlmessung_e.doc

5.2 Software installation 30


MAE1C

6 Operating the Application 32


6.1 Quick startup 32
6.2 Detailed description of individual operator screens 33

1.0 14.05.2004 27/37


Part B: Installation of the Example Application
Hardware and Software Installation

MAE 1C

5 Hardware and Software Installation


5.1 Hardware configuration

Power supply of LOGO! Power, S7-222 CPU and TP070


Connect the components (as displayed below) to the voltage supply.
Fig. 5-1
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

24V supply of shaft angle encoder

Depending on the type selected, there are different types of connection


! cables for the shaft angle encoder. Cable assignments should therefore
Attention follow the enclosed instruction sheet, or if necessary be measured.

Table 5 -1

No. Instructions Note


1 Connect + 24V to the shaft angle encoder.
Make sure that the
With this shaft angle encoder:
assignment agrees with
Core color blue/white (Pin11) to (-) minus and red/white your shaft angle encoder!
(Pin2) to (+) plus. (see previous figure)

Fig. 5-2

Plug side view of the shaft angle encoder.

1.0 14.05.2004 28/37


Part B: Installation of the Example Application
Hardware and Software Installation

MAE 1C

Cabling of shaft angle encoder and S7-200 CPU

! Depending on the type selected, there are different types of connection


cables for the shaft angle encoder. Cable assignments should therefore
Attention
follow the enclosed instruction sheet, and if necessary be measured.

Table 5 -2

No. Instructions Note


1 Connect both pulse tracks A and B of the shaft angle
encoder to counting inputs I0.0 and I0.1. Make sure that the
assignment agrees with
With this shaft angle encoder:
your shaft angle encoder!
Core color yellow (Pin5) and black (Pin8) to I0.0 and I0.1

Depending on installation position and mechanical coupling, the count


direction of the shaft angle encoder may vary!
Copyright  Siemens AG 2004 All rights reserved

! If the counter counts in negative direction, even though the conveyor belt
Doku_Drehzahlmessung_e.doc

Attention moves in positive direction for example, you switch the pulse tracks of the
shaft angle encoder.
MAE1C

Connecting the TP070 to the S7-200 CPU


Table 5 -3

No. Instructions Note


1 Connect the interfaces of TP070 and S7-200 CPU via
MPI cable.

1.0 14.05.2004 29/37


Part B: Installation of the Example Application
Hardware and Software Installation

MAE 1C

5.2 Software installation

In this chapter it is assumed, that the configuration software


S7-Micro/Win 32 V3.2 SP4 and TP-Designer have already been installed
Note on your Windows PC.
This chapter gives no introduction into handling the configuration
software, you should already be familiar with those tools.

Transferring the application software to the S7-222 CPU

Fig. 5-3
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

Table 5 -4

No. Instructions Note


1 Start S7-Micro/Win 32 V3.2 SP4.
2 Open the application project via File Æ open .
Check in the system data block whether the transmission Checking the communication
3 speed for port 0 (connection for TP070) has been set to settings between TP070 and
19.2kBps. S7-CPU
Please ensure that the communication settings from Ensure that the configured
4 Micro/Win to the S7-200 CPU have been selected connection to the CPU exists.
correctly.
5 Transfer the project to the CPU.

1.0 14.05.2004 30/37


Part B: Installation of the Example Application
Hardware and Software Installation

MAE 1C

Transferring the user interface to the TP070

Fig. 5-4
Copyright  Siemens AG 2004 All rights reserved

Table 5 -5
Doku_Drehzahlmessung_e.doc

No. Instructions Note


1 Start the TP-Designer for the TP070.
MAE1C

2 Open the TP070 project via File Æ open.


3 Please ensure that the communication settings from Ensure that the configured
TP-Designer to TP070 and TP070 to the CPU (19.2kBps) connection to the TP070
have been selected correctly. exists.
4 Set the TP070 to transmission mode.
5 Transfer the TP070 project to the panel.

Note PG/PC can of course be the same system.

1.0 14.05.2004 31/37


Part B: Installation of the Example Application
Operating the Application

MAE 1C

6 Operating the Application

In this chapter it is assumed that all steps in the chapter “Installation of


Note
Hardware and Software“ have been performed successfully.

6.1 Quick startup


Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc

Table 6 -1

No. Instructions Note


MAE1C

Ensure that all steps in the chapter “Installation of


1 Hardware and Software“ have been performed
successfully.
Switch on the system power supply. Start-up of the TP070 takes approx. 1
2
min.
Select the Parameter button in the menu bar at the
3
bottom of the display.
The two additional parameters
Change here the parameter Encoder according to Timebase and Filter time are
4
your conditions. not dealt with here for the quick
startup, see chapter “Parameters”.
5 The application is now ready for operation.

Note The parameters Encoder, Timebase and Filter time are described in
the figure Parameter.

1.0 14.05.2004 32/37


Part B: Installation of the Example Application
Operating the Application

MAE 1C

6.2 Detailed description of individual operator screens

Turns per minute


Fig. 6-1
Copyright  Siemens AG 2004 All rights reserved

This screen has no operating options. Only the current statuses stopped,
forward, backward and the measured speed revolutions per
Doku_Drehzahlmessung_e.doc

minute are displayed.


MAE1C

Parameters
Fig. 6-2

In this operator screen you have to adapt the parameters to suit your
conditions.
• Timebase gives the value for the updating time of the
measurement (50ms-255ms); push initialise new after a value
has been changed.
• Filter Time is the default time after which a counter change is
interpreted as standstill.
• Encoder gives the resolution of the shaft angle encoder used.

1.0 14.05.2004 33/37


Part B: Installation of the Example Application
Operating the Application

MAE 1C

System
Fig. 6-3

These buttons provide you with all control options for the Touch Panel
Copyright  Siemens AG 2004 All rights reserved

TP070.
Doku_Drehzahlmessung_e.doc

• The display contrast can be modified by means of the buttons


MAE1C

Increase contrast and Reduce contrast.


• The connection status is influenced by the two sensors Status
online and Status offline.
• If it is necessary to clean the screen, the button Cleaning screen will
have to be pressed beforehand. This deactivates the touch-sensitive
screen for 60 seconds.
• A calibration ensures the congruence between the invisible raster of the
touch screen and the actual optical display. These are calibrated by
pressing the button Calibrate screen.
• A new TP070 project can be loaded onto the touch panel by pressing
the serial upload button.

1.0 14.05.2004 34/37


Part C: Program Description
Overview

MAE 1C

Part C: Program Description


Overview
Contents of Part C
Part C is of interest if you want to take the software and expand or adapt it
to your set-up.

Objectives of Part C
This part of the documentation shall
• explain the code details of some core elements of the program to the
reader
• suggest where it might usefully be expanded

Precondition
This is not an introduction into the S7 Micro/Win 32 programming language.
Copyright  Siemens AG 2004 All rights reserved

Readers should be familiar with the basics of this programming language.


Doku_Drehzahlmessung_e.doc

Before reading the code description , it may be useful to read the chapters
in Parts 1 and A2.
MAE1C

Topics
Chap. Title Page
7 Explanation of the Main Parts of the S7-Micro/Win Program 36
7.1 Sub-program INIT 36
7.2 Sub-program HSC_INIT 36
7.3 Sub-program Turns 36
7.4 Interrupt program Read_HSC 37

1.0 14.05.2004 35/37


Part C: Program Description
Explanation of the Main Parts of the S7-Micro/Win Program

MAE 1C

7 Explanation of the Main Parts of the S7-Micro/Win


Program
7.1 Sub-program INIT

The sub-program INIT is executed once when the CPU starts up and it
initializes the control for speed measurement. The following functions are
initialized:
• assignment of the interrupt program
• initializing the high-speed counter (see chapter 7.2)

7.2 Sub-program HSC_INIT

The sub-program HSC_INIT was generated with the wizard of Micro/Win.


Therefore, the configuration of the high-speed counter is not discussed
here in greater detail.
Copyright  Siemens AG 2004 All rights reserved

Only the requirements/settings for the high-speed counter are worth


knowing as the wizard leads you through the menu.
Doku_Drehzahlmessung_e.doc

Table 7 -1

Criterion Requirements Setting


MAE1C

Counter type A/B track HC0 (type 9)


Special inputs none
Reaction at special events none No interrupt programs

7.3 Sub-program Turns

The time interrupt program Read_HSC (see following chapter) sets a bit if
there is an updated counter status available. After this trigger, the following
calculation is performed in the sub-program Turns.

Calculation
∆ 60 [seconds ]
Speed [rpm] = Counter status

Encoder resolution Time interval [seconds ]
Following the speed calculation the bit for the updated counter status is
reset.

Filtering/damping direction diagnosis


In addition, a filtering for the direction diagnosis is performed in this sub-
program. This prevents „fluttering“ of the status bits. Concretely, the status
signal is “switched through” only after a filtering time.

1.0 14.05.2004 36/37


Part C: Program Description
Explanation of the Main Parts of the S7-Micro/Win Program

MAE 1C

7.4 Interrupt program Read_HSC

This interrupt program is always executed after a defined parameterized


time. The cyclic program processing is interrupted and the interrupt
program is executed.
When this sub-program is executed, the current counter status is read out
and the difference between new and old counter statuses is formed. (After
the difference has been formed, the current counter status is saved for the
next calculation.) The resulting difference is a measure for the speed in this
time interval.
• If the difference is positive, the shaft is in forward motion. The bit for an
updated counter status and the bit for forward motion are set.
• If the difference is negative, the shaft is in backward motion. The bit for
backward motion is set.
• If the difference is 0, the shaft is at standstill. The bit for standstill is set.
Copyright  Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C

1.0 14.05.2004 37/37

Das könnte Ihnen auch gefallen