Beruflich Dokumente
Kultur Dokumente
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
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
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.
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
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
MAE 1C
Fig. 1-1
Copyright Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C
MAE 1C
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
Topics
MAE1C
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.
MAE 1C
Table 1 -1
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.
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.
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.
MAE 1C
Connection cable/
shaft angle encoder 6FX5002-2CA12-1AD0 1
signal line (3m)
S7-200Ùshaft angle encoder
Doku_Drehzahlmessung_e.doc
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
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
MAE 1C
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
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.)
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
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).
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.
MAE 1C
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)
MAE 1C
maximum error.
MAE1C
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%
MAE 1C
• The column Max. error shows the highest absolute error of the
forty’s series of measurements.
Doku_Drehzahlmessung_e.doc
1.0 14.05.2004
Copyright Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C
MAE 1C
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%
MAE 1C
correctly and without too much difficulty into the STEP7 code.
Doku_Drehzahlmessung_e.doc
Objectives of Part A2
MAE1C
Topics
Chap. Title Page
4 Function Mechanisms 20
4.1 Description of entire solution structure 20
4.2 Program and data structure 25
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
MAE 1C
MAE 1C
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.
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
MAE 1C
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.
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.
MAE 1C
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
MAE 1C
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
BACKWARDS_fil W
12 BOOL V8.4
tered
MAE 1C
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
MAE 1C
Table 5 -1
Fig. 5-2
MAE 1C
Table 5 -2
! 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
MAE 1C
Fig. 5-3
Copyright Siemens AG 2004 All rights reserved
Doku_Drehzahlmessung_e.doc
MAE1C
Table 5 -4
MAE 1C
Fig. 5-4
Copyright Siemens AG 2004 All rights reserved
Table 5 -5
Doku_Drehzahlmessung_e.doc
MAE 1C
Table 6 -1
Note The parameters Encoder, Timebase and Filter time are described in
the figure Parameter.
MAE 1C
This screen has no operating options. Only the current statuses stopped,
forward, backward and the measured speed revolutions per
Doku_Drehzahlmessung_e.doc
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.
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
MAE 1C
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
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
MAE 1C
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)
Table 7 -1
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.
MAE 1C