Professional Documents
Culture Documents
User Information
Product Overview 1
DB Assignments 11
M7 Reference
Counter Function Library 12
Appendices
Technical Specifications A
References C
Glossary, Index
Safety Guidelines This manual contains notices which you should observe to ensure your own personal safety, as well as to
protect the product and connected equipment. These notices are highlighted in the manual by a warning
triangle and are marked as follows according to the level of danger:
Danger
! indicates that death, severe personal injury or substantial property damage will result if proper precautions are
not taken.
Warning
! indicates that death, severe personal injury or substantial property damage can result if proper precautions are
not taken.
Caution
! indicates that minor personal injury or property damage can result if proper precautions are not taken.
Note
draws your attention to particularly important information on the product, handling the product, or to a particular
part of the documentation.
Qualified Personnel The device/system may only be set up and operated in conjunction with this manual.
Only qualified personnel should be allowed to install and work on this equipment. Qualified persons are
defined as persons who are authorized to commission, to ground, and to tag circuits, equipment, and sys-
tems in accordance with established safety practices and standards.
Warning
! This device and its components may only be used for the applications described in the catalog or the technical
description, and only in connection with devices or components from other manufacturers which have been
approved or recommended by Siemens.
This product can only function correctly and safely if it is transported, stored, set up, and installed correctly, and
operated and maintained as recommended.
Purpose This manual describes all the steps required for using the FM 450-1 function
module effectively. It supports you in learning the functionality of the
FM 450-1 quickly and effectively.
Contents of This This manual describes the hardware and software of the FM 450-1. It consists
Manual of an instructional section and a reference section (appendices).
The manual contains the following:
S Basics of counting
S Installation and expansion of the FM 450-1
S Wiring the FM 450-1
S Assigning parameters to the FM 450-1
S Programming the FM 450-1
S Appendices
Scope of This This manual contains the description of the FM 450-1 function module valid
Manual at the time of publication of the manual. We reserve the right to describe any
subsequent changes in the functionality of the FM 450-1 in a Product
Information.
Other References You will find a list of other references on the topic of the S7-400 and pro-
grammable controllers in the appendix.
Structure of This To make it easier for you to locate specific information, the manual has been
Manual structured as follows:
S At the beginning of the manual, you will find a complete table of contents
and a list of all the figures and tables contained in the manual.
S In the individual chapters, the information in left margin gives an over-
view of the contents of each section.
S Following the appendices, there is a glossary containing definitions of the
important technical terms used in the manual.
S At the end of the manual, you will find a detailed index giving you fast
access to the information you seek.
Standards The S7-400/M7-400 programmable controller conforms to the IEC 1131 stan-
dard.
Additional If the manual fails to answer any questions concerning products described in
Assistance the manual please contact your Siemens representative at your local Siemens
office. You will find the relevant addresses in the SIEMENS Worldwide
Appendix of the S7-400 and M7-400 Programmable Controllers manual.
If you have any questions or remarks regarding the manual itself, please fill
in the reply sheet at the back of the manual and send it to the address given.
Please also indicate your personal evaluation of the manual in the remarks
form.
We offer courses for entry-level users of the SIMATIC automation system.
Please contact your local training center or the Central Training Center in
D-90327 Nuremberg, Tel. ++49 911/895 3154.
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
1 Product Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 What Can the FM 450-1 Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.2 Application Areas of the FM 450-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
1.3 FM 450-1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
1.4 FM 450-1 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
2 How the FM 450-1 Counts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2.2 Gate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
3 Installing and Removing the FM 450-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1 Preparing the Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
3.2 Installing and Removing the FM 450-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
4 Wiring the FM 450-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
4.1 Terminal Assignments of the Front Connector . . . . . . . . . . . . . . . . . . . . . . . . 4-2
4.2 Wiring the Front Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
4.3 Module Status After Switching On . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
5 Assigning Parameters to the FM 450-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
5.1 Installing and Calling Parameter Assignment Screen Forms . . . . . . . . . . . 5-2
6 Programming the FM 450-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
6.1 The FC CNT_CTRL Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
6.2 The FC DIAG_INF Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
6.3 Application Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
6.4 Technical Specifications of the Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
7 Programming in M7 with the Counter Function Library . . . . . . . . . . . . . . . . . . . . . 7-1
7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7.2 Basic Program Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7.3 Initializing and Parameterizing the Counter Channel . . . . . . . . . . . . . . . . . . 7-5
7.4 Transferring the Load Value and Comparison Values . . . . . . . . . . . . . . . . . 7-7
7.5 Control of the Digital Inputs and Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
Comparison For each counter, you can store on the module two comparison values as-
Values signed to the two relevant outputs on the module. If the counter status
reaches one of the two comparison values, the relevant output can be set to
initiate control actions direct in the process.
Starting Value You can specify a starting value (load value) to the FM 450-1 for each
counter. The counter is set to the starting value if a software or hardware sig-
nal is present at the module.
Process Interrupts The FM 450-1 can trigger a process interrupt in the CPU if the comparison
values are reached, or in the case of overflow, underflow and/or in the case of
zero pass of a counter.
Diagnostics The FM 450-1 can trigger a diagnostics interrupt if any of the following oc-
Interrupts cur:
S Fault in external auxiliary voltage
S Fault in 5.2 VDC encoder supply
S Module not parameterized or errors in parameterization
S Watchdog triggered
S RAM defective
S Process interrupt lost
S Fault in signal A, B or N
Pulse Duration You can specify a pulse duration for the digital outputs of the FM 450-1. The
pulse duration specifies how long the relevant digital output is to be set. You
can specify a value between 0 and 500 ms for the pulse duration. This value 1
applies for both outputs. You can adapt the FM 450-1 to existing actuators by
specifying a pulse duration.
Which Signals Can The FM 450-1 can count signals generated by the following encoders:
the FM 450-1
S Incremental 5 V encoders
Count?
S Incremental 24 V encoders
S 24 V pulse encoders with direction level
S 24 V initiators without direction level
for example, light barrier or BERO
Input Filter For the purpose of suppressing interference, you can parameterize input fil-
ters (RC elements) with a uniform filter time for the 24 V inputs A*, B* and
N* and for the digital inputs. The following two input filters are available:
Example for the In this example, a carton must be filled with a specific number of parts. One
Use of an FM 450-1 counter of the FM 450-1 counts the parts and controls the motor for trans-
porting the parts and the motor for transporting the carton.
If the carton is in the correct position, conveyor belt A is stopped via the light
barrier, the count is started and the motor for conveyor belt B is switched on.
When the carton contains the programmed number of parts, the FM 450-1
stops the motor for conveyor belt B and switches on the motor for conveyor
belt A for removal of the carton. The count can start again when the next
carton reaches the light barrier.
FM 450-1
Belt A
Motor
Light barrier Motor
Gate
Belt B
Version
Diagnostics
and status LEDs
Order Number and The full order number of the FM 450-1 is shown on the rating plate.
Version
The abbreviated order number and the version of the FM 450-1 are given at
the top end of the module front.
Diagnostics and The FM 450-1 has 16 LEDs that are used both for diagnostics and for indicat-
Status LEDs ing the status of the FM 450-1 and its digital inputs and outputs. Table 1-2
1 gives the labeling, color and function of the LEDs.
Front Connector When you swing the front connector down into position, the front connector
Coding coding engages. Thereafter, this front connector can only be attached to an
FM 450-1 module.
Labeling Strips Enclosed with the module is a labeling block with four labeling strips on
which you can write your relevant signal names.
Parameter The FM 450-1 is adapted to the task in hand via parameters. These parameter
Assignment are stored in an SDB and transferred to the module from the CPU.
Screen Forms
You can specify the parameters via parameter assignment screen forms.
These parameter assignment screen forms are installed on your programming
device and called up within STEP 7.
Software for the The software for the CPU consists of the FC CNT_CTRL function called in
S7-400-CPU the user program of the CPU. This FC enables communication between the
CPU and the FM 450-1. In addition, there is also the FC DIAG_INF function
for the FM 450-1, with which you can transfer diagnostics information into
the DB of the FC CNT_CTRL.
Figure 1-3 shows an S7-400 configuration with an FM 450-1 and several sig-
nal modules.
Programming
device (PG) with STEP 7 and
the parameterization screen
forms
CPU
with user program
and FCs of the
FM 450-1 FM 450-1
2.1 Definitions
What is Counting? Counting refers to the process of capturing and summing up events. In the
2 case of the FM 450-1 function module, encoder signals are captured and eva-
luated accordingly.
Count Range, The FM 450-1 can count up and down. By selecting the count range, you
Count Limits define the limits within which the FM 450-1 can count.
Load Value You can specify a starting value to the FM 450-1 for each of the two count-
ers. Counting starts at this value. The starting value is referred to as the load
value. The load value can be any value within the count limits.
Example In the example in Section 1.2, the motor for conveyor belt B is to be stopped
as soon as the carton contains the programmed number of parts. For this pur-
pose, you can specify this number to the FM 450-1 as the comparison value
for counter 1, for example, and use the assigned digital output to stop the
motor.
Three Different With the FM 450-1, you can count rectangular pulses in three different ways:
Counting Methods
S Continuous counting, with or without gate function
S Single count, with hardware or software gate
S Periodic counting, with hardware or software gate
The differences between the methods become obvious in the behavior of the
FM 450-1 when a counter has reached a count limit.
Continuous If a counter reaches the upper limit when counting up, and if another count
Counting pulse comes, the counter jumps to the lower count limit and starts to add the
count pulses again; so it continues to count continuously.
If a counter reaches the lower limit when counting down, and if another
count pulse comes, it jumps to the upper count limit and continues to count
down from there.
2
Counter status
Time
Single Counting In single counting, the counter starts at the load value. If a counter reaches
the upper count limit when counting up, and if another count pulse comes,
the counter jumps to the lower count limit and remains there even if further
count pulses come.
If a counter reaches the lower limit when counting down, and if another
count pulse comes, it jumps to the upper limit and remains there even if fur-
ther count pulses come.
Counter status
Load value
Time
Periodic Counting In periodic counting, the counter starts from the load value. When the
counter reaches the upper limit when counting up, and if a another count
pulse comes, it jumps to the load value and starts to add the count pulses
again.
2 If a counter reaches the lower limit when counting down, and if another
count pulse comes, it jumps to the load value and continues to count down
from there.
Counter status
Load value
Time
Counting with Many applications require that the count be started or stopped at a defined
Gate Functions time depending on other events. This starting and stopping of the count is 2
done in the case of the FM 450-1 via a gate function. If the gate is opened,
count pulses can reach a counter and the count is started. If the gate is closed,
count pulses can no longer reach the counter and the count is stopped.
Software Gate and The module has two gate functions for each counter
Hardware Gate
S A software gate controlled via the user program in the CPU.
S A hardware gate controlled via digital inputs 1I0 and 1I1 (counter 1) or
2I0 and 2I1 (counter 2) on the module. When assigning parameters to the
FM 450-1, you define whether the hardware gate is to operate with level
control or with edge control.
Example The gate is opened and the count pulses are counted by setting the gate sig-
nal. If the gate signal is removed, the gate is closed and the count pulses are
no longer captured by the counter. The counter status remains constant.
Figure 2-4 shows the opening and closing of a gate and the counting of the
pulses.
Counter status
1 2 3 4
Count pulses 4
Gate signal
Open Close
gate gate
Terminating a When counting with the software gate and when counting with the hardware
Count with the gate, you can terminate the count in each case using the gate stop function.
Gate Stop For this purpose, set the input parameter GATE_STP of the FC CNT_CTRL.
Function
Defining the Slots The FM 450-1 function module can, like a signal module, be installed in a
central rack or in an expansion unit.
Mechanical Manual /1/ describes the possibilities open to you for mechanical installation
3 Configuration and how to proceed when configuring.
Determining the The starting address of the FM 450-1 is required for communications be-
Starting Address tween the CPU and the FM 450-1. The starting address is entered in the DB
of the FC CNT_CTRL (see Chapters 6 and 11). The entry is made either with
the help of the program editor or from the user program.
You specify the starting address for the module under STEP 7.
Important Safety There are important rules you must observe for integrating an S7-400 with an
Rules FM 450-1 into a plant or a system.
These rules and regulations are explained in manual /1/.
Rules No special protection measures (ESD guidelines) are required for installing
an FM 450-1.
Tools Required You require a 4.5 mm screwdriver for installing and removing the FM 450-1. 3
Installation Proceed as follows to install an FM 450-1:
Procedure
1. Hook the FM 450-1 in at the top and swing it down into position.
2. Tighten the screw on the FM 450-1
(torque approximately 0.8 to 1.1 Nm).
3. Label the FM 450-1 with its slot number. For this purpose, use the nu-
merical wheel enclosed with the mounting rack.
The numbering scheme and the procedure for determining the slot num-
ber are described in manual /1/.
Further Notes Manual /1/ contains further notes on installing and removing modules.
Front Connector You connect the count signals, the digital inputs and outputs, the encoder
supply and the auxiliary voltage and load voltage via the 48-pin front con-
nector. Figure 4-1 shows the front side of the front connector, the strip with
the printed pin assignments and the labeling strips.
Note
The circuits for the counter inputs (encoder supply, encoder signals) are non-
isolated to the ground of the CPU, that is, terminal 4 (1M) must have a low-
resistance connection to CPU ground.
If you supply the encoders externally, you must also connect the ground of
this external voltage with the ground of the CPU.
Auxiliary Voltage Connect a direct voltage of 24 V to the 1L+ and 1M terminals for the voltage
1L+, 1M supply of the 5 V and 24 V encoders.
An integral diode protects the module from reverse polarity of the auxiliary
voltage.
The module monitors the connection of the auxiliary voltage.
5.2 VDC Encoder The module generates a voltage of 5.2 V from the auxiliary voltage 1L+/1M
Supply at a maximum current of 300 mA per counter channel that is available at
each 5.2 VDC connection for the voltage supply of a 5 V encoder. This is
short-circuit proof. 4
24 VDC Encoder For the 24 V voltage supply of an encoder, the voltage 1L+/1M is made
Supply available and short-circuit proof at the 24 VDC output. The encoder supply
is monitored for short-circuit.
5 V Encoder To each encoder you can connect incremental encoders with 5 V differential
Signals A, A, B, B, signals in accordance with RS 422, that is, incremental encoders with the
N and N differential signals, A, A, B, B, N and N.
The signals A, A, B, B, N and N are connected via the terminals so labeled.
The signals N and N are only connected if you want to set the counter to the
zero mark of the encoder.
The inputs are not galvanically isolated from the S7-400 bus (see note fol-
lowing Table 4-1).
Input Filter for For the purpose of suppressing interference, you can parameterize input fil-
24 V Encoder ters (RC elements) with a uniform filter time for the 24 V inputs A*, B* and
Signals N. The following two input filters are available:
4
Digital Inputs You can use the relevant digital inputs 1I0 and 1I1 (counter 1) or 2I0 and 2I1
(counter 2) for the gate control of the two counters. The gate control can be
both level-controlled and edge-controlled (see Chapter 9).
Digital input 1I2 is used for setting counter 1 to the load value.
Digital input 2I2 is used for setting counter 2 to the load value.
The digital inputs are operated with a nominal voltage of 24 V.
The digital inputs are galvanically isolated from the bus and the counter in-
puts.
Input Filter for For the purpose of suppressing interference, you can parameterize input fil-
Digital Inputs ters (RC elements) with a uniform filter time for digital inputs 1I0, 1I1 and
1I2 or 2I0, 2I1 and 2I2. The following two input filters are available:
Digital Outputs The FM 450-1 has the digital outputs 1Q0 and 1Q1 (for counter 1) and 2Q0
and 2Q1 (for counter 2) for direct triggering of control actions. These outputs
are supplied via the load voltage 2L+.
The digital outputs are galvanically isolated from the S7-400 bus and the
counter inputs.
The digital outputs are source outputs and can be loaded with a load current
of 0.5 A. They are protected from overload and short-circuit.
Note
Relays and contactors can be connected direct without external circuitry.
Load Voltage
2L+/ 2M
For supplying the digital outputs 1Q0 and 1Q1 or 2Q1 and 2Q2, the module
must be supplied with a load voltage of 24 V via terminals 2L+ and 2M.
4
An integral diode protects the module from polarity reversal of the load volt-
age.
The load voltage 2L+/2M is not monitored by the FM 450-1.
Cables There are some rules for you to observe when selecting cables:
S The cables for the digital inputs must be shielded.
S The cable for the counter signals must be shielded.
S You must apply the shields of the counter signal cables both at the pulse
encoder and in the immediate vicinity of the module via the shield attach-
4 ment, for example.
S The cables A, A, B, B and N, N of the incremental 5 V encoder must be
twisted in pairs.
Figure 4-2 shows details of connecting incremental 5 V encoders.
Shield on Shield on
shield attachment housing
Front connector
Counter 1
A
5
A
6
B
7
8 B
N
9
10 N
1M
14
15 5.2 VDC
Counter 2
A
17
A
18
B
19
20 B
N
21
22 N
1M
26
5.2 VDC
27
Shield on Shield on
shield attachment housing
Twisted wires
Shield on Shield on
shield attachment housing
Front connector 4
Counter 1
A*
11
B*
12
N*
13
1M
14
24 VDC
16
Counter 2
A*
23
B*
24
N*
25
1M
26
24 VDC
28
Shield on Shield on
shield attachment housing
Note
If the encoders are supplied via the module, the cable cross-section must be
large enough to carry the required voltage to the encoder despite voltage
drops over the cable. This applies especially in the case of incremental 5 V
encoders.
4 S A wire end ferrule is not required. If you use wire end ferrules then use
only those without insulation collar in accordance with DIN 46228 Form
A, short version!
Warning
! There is a danger of personal injury.
If you wire the front connector of the FM 450-1 when the power is switched
on, you are in danger of injury from electric shock.
Wire the FM 450-1 only when the power is switched off!
Features The status of the module after the power supply has been switched on and
before any data has been transferred, is characterized by the following fea-
tures:
S Counter inputs default for 5 V differential signals, track B not inverted;
single evaluation (see Section 10-4);
S Count mode 32 bits
S Counter status zero
4
S Setting of counter with digital input 1I2 or 2I2 (and zero mark) disabled
S Input delay for the digital inputs: typically 1 s
(max. frequency: 200 kHz, minimum pulse width: 2.5 s)
S Input delay for 24 V counter inputs: typically 1 s
(max. frequency: 200 kHz, minimum pulse width: 2.5 s)
S Outputs 1Q0 and 1Q1 or 2Q0 and 2Q1 switched off
S Pulse duration = 0
S No process interrupts set
S Operating mode Continuous count set
S Gate function switched off (that is, gate opened)
S Status signals are updated
This setting corresponds to the default setting of the module.
RESET Status This module status (default setting) is also referred to as the RESET status.
Marginal The following conditions apply for transferring parameter assignment data to
Conditions the CPU:
S STEP 7 must be correctly installed on your programming device
S The programming device must be correctly connected to the CPU
S The CPU must be in STOP
Note
You must not plug in or remove any S7-400 modules during data exchange
over the MPI!
Form of Supply The software is supplied in the form of 3.5 diskettes, MS-DOS operating
system, 1.44 Mbytes. The following information is available on the supply
diskettes:
S Diskette format
S Diskette number and quantity
S Product designation, version and year
Creating a Backup Create a copy of each original diskette and install the parameter assignment
Diskette screen forms from this copy. Keep the original diskettes in a safe place. See
your MS-DOS description or your WINDOWS description to learn how to
copy diskettes.
Installing the Call the SETUP.EXE program on the backup copy of your installation dis-
Parameter kette. This installs not only the parameter assignment screen forms but also
Assignment FC CNT_CTRL and the FC DIAG_INF on your programming device. The
Screen Forms FCs are inserted in the standard library in the catalog FM_CNT_L. Follow
the instructions displayed in the SETUP menu on the screen.
Reading the The READ ME file may contain important up-to-date information concern-
READ ME File ing the software supplied. You can read this file with the WORDPAD Editor
under Windows.
Calling the The parameter assignment screen forms are displayed automatically after a
Parameter successful installation, if you parameterize the FM 450-1 within the hardware
Assignment configuration.
Screen Forms
Calling the Integral There is an integral Help function for the parameter assignment screen forms
Help Function that you can call in any phase of parameter assignment either with the F1 key
or with the Help button.
Block Number Block Name Meaning
FC 0 CNT_CTRL Controlling the counters of the FM 450-1
FC 1 DIAG_INF Read diagnostics data set 1 from the
FM 450-1
Prerequisite The data required for the FC CNT_CTRL are stored in a DB on the CPU.
The FC CNT_CTRL transfers data cyclically from this DB to the FM and
fetches data from the FM.
You create the DB under STEP 7 as a data block with assigned user-specific
data type. Select UDT 1 as the source. UDT 1 has been copied into the block
library for the counters (FM_CNT) during installation of the FCs. You must
not modify UDT 1. Copy UDT 1 together with the FCs into your project.
Before programming the FM 450-1, the following valid data must be as-
signed to the DB of the FC CNT_CTRL:
S Module address
You set the module address (base address of the FM 450-1) when config-
uring your hardware.
6 S Channel address
The channel address of counter channel 1 is the same as the module ad-
dress in pointer format. The channel address of counter channel 2 is the
same as the module address + 32 in pointer format.
S User data length
The user data length is 32.
Example You will find below an example of how to implement the transfer of the
module address, the channel address and the user data length in OB10. The
symbol table contains the following assignments for this example:
STL Description
Channel 1
L 512 // Module address = 512
T FM450_DB_K1.MOD_ADR // Transfer of module address
L P# 512.0 // Module address in pointer format
T FM450_DB_K1.CH_ADR // Transfer of the channel address for channel 1
L 32 // User data length = 32
T FM450_DB_K1.U_D_LGTH // Transfer of the user data length
Channel 2
L 512 // Module address = 512
T FM450_DB_K2.MOD_ADR // Transfer of module address
L P# 544.0 // Module address + 32 in pointer format
T FM450_DB_K2.CH_ADR // Transfer of the channel address for channel 2
L 32 // User data length = 32
T FM450_DB_K2.U_D_LGTH // Transfer of the user data length
given below.
STL method of representation LAD method of representation
CALL CNT_CTRL,(
DB_NO := , CNT_CTRL
SW_GATE
GATE_STP
:=
:=
,
,
EN
DB_NO
ENO
OT_ERR
OT_ERR_A
OT_ERR
:=
:=
,
,
SW_GATE
GATE_STP
L_DIRECT := , OT_ERR_A
L_DIRECT
L_PREPAR := ,
L_PREPAR 6
T_CMP_V1 := ,
T_CMP_V2 := , T_CMP_V1
RES_SYNC
RES_ZERO
:=
:=
,
)
T_CMP_V2
RES_SYNC
RES_ZERO
Table 6-1
FC CNT_CTRL Parameters
Name
Declaration
Type
Data Type Meaning The User... The Block...
DB_NO INPUT BLOCK_DB Number of the data block enters this scans this
SW_GATE INPUT BOOL
with the counter data
Counter control bit SW sets and resets scans this
gate (start/stop) this
GATE_STP INPUT BOOL Counter control bit Gate sets and resets scans this
stop this
OT_ERR_A INPUT BOOL Acknowledge operator er- sets and resets scans this
ror this
OT_ERR OUTPUT BOOL Operator error occurred scans this sets and resets
6 this
L_DIRECT IN-OUT BOOL Initiation bit for direct sets this scans and resets
loading of a counter this
L_PREPAR IN-OUT BOOL Initiation bit for Prepara- sets this scans and resets
tory loading of a counter this
T_CMP_V1 IN-OUT BOOL Initiation bit for transfer sets this scans and resets
Comparison value 1 this
T_CMP_V2
IN-OUT
BOOL Initiation bit for transfer
Comparison value 2
sets this scans and resets
this
RES_SYNC IN-OUT BOOL Delete Synchronization sets this scans and resets
RES_ZERO IN-OUT BOOL
status bit
Delete Zero pass status sets this
this
scans and resets
bit this
You make a job request for the FM 450-1 via the relevant FC parameters
L_DIRECT, L_PREPAR, T_CMP_V1, T_CMP_V2, RES_SYNC,
RES_ZERO, OT_ERR_A and GATE_STP.
Depending on the job request, you must enter the load value or a comparison
value in the instance DB before calling the FB.
A set in/out parameter (L_DIRECT, L_PREPAR, T_CMP_V1, T_CMP_V2,
RES_SYNC and RES_ZERO) is deleted again by the FC CNT_CTRL after
completion of the job.
Error Messages If an operator error occurs in the case of an FC call, this is reported in the
OT_ERR parameter. The error information can then be read out in DB1
(OT_ERR_B variable). With the help of the OT_ERR_A parameter, you can
then acknowledge operator errors. No new operator error will be reported
until you have acknowledged the previous one.
Functionality The FC DIAG_INF function reads data set DS1 from the FM 450-1 and
makes it available to you in the DB of the FC CNT_CTRL. The transfer
works as follows:
S If the initiation parameter is set (IN_DIAG = TRUE), DS1 is read out
from the FM 450-1.
S DS1 is entered in the DB of the FC CNT_CTRL from DW 54. DS1 is
transferred with the help of the SFC RD_REC.
S The return code of the SFC (RET_VAL) is copied to the RET_VAL pa-
rameter of the FC DIAG_INF.
S As soon as the function has been executed, the IN_DIAG initiation pa-
rameter is reset and the transfer is reported to be complete.
Manual /2/ contains a full description of the SFC RD_REC.
6
Call The FC DIAG_INF can be called in the cycle and in the interrupt program.
There is no point in calling it in the time-controlled program.
The FC DIAG_INF call is given in the STL and LAD methods of representa-
tion below.
STL method of representation LAD method of representation
CALL DIAG_INF(
DB_NO := , DIAG_INF
RET_VAL
IN_DIAG
:=
:=
,
);
EN
DB_NO RET_VAL
ENO
IN_DIAG
FC DIAG_INF Table 6-2 lists the FC DIAG_INF parameters.
Parameters
Table 6-2
FC DIAG_INF Parameters
Name
Declaration
Type
Data Type Meaning The User... The Block...
DB_NO
INPUT
BLOCK_DB Number of the FC enters this scans this
CNT_CTRL data block
RET_VAL
OUTPUT
WORD Returncode of the SFC 59 scans this enters this
IN_DIAG
IN-OUT
BOOL Initiation bit read diagnos- sets and scans
tics data set DS1 this
resets this
Introduction The example below shows how the FC CNT_CTRL can be used for the func-
tions Transfer load value to FM 450-1 and Start counter. These functions
are representative of all functions here.
STL Explanation
L +1000; // Enter load value in
T CHANNEL1.LOAD_VAL; // the DB.
A INITIATE;
S LOAD_DIRECT; // DIRECT input parameter
6 R INITIATE;
Description of the Table 6-3 lists the symbols used in the example. You define your own symbol
Symbols assignments in the S7 Symbol Table.
Table 6-3
Symbols in the User Program
Symbol Absolute (Example) Comments
CHANNEL1 DB 1 Data block for FC CNT_CTRL
CHANNEL1.LOAD_VAL DB1.DBB14 Counter value specified in DB1
INITIATE M 10.0 Initiation memory bit generated as a result of the technological
requirement
LOAD_DIRECT M 20.0 Load counter value direct
START M 20.1 Start counter
GATE_STOP M 20.2 Close counter gate
ERR_ACKN
M 20.3
LOAD_INDIRECT M 20.4
Acknowledge operator error
Preparatory loading of counter value
6
COMP1_LOAD
M 20.5
Load comparison value 1
COMP2_LOAD M 20.6 Load comparison value 2
RES_SYNCHRON M 20.7 Reset synchronization status bit
RES_ZERO M 21.0 Zero pass status bit, reset overflow and underflow
OPERATOR_ERR M 21.1 Operator error occurred
CHANNEL1.OT_ERR_B DB1.DBX40.0 Operator error information in DB1
Description of the When the FC is called, the load value of a channel is transferred to the
Sequence FM 450-1. The load value must have previously been entered in the DB1.
Calling the FC CNT_CTRL selects either the parameter L_DIRECT or
L_PREPAR. The selection bit L_DIRECT defines that the load value is trans-
ferred directly into the counter (L_DIRECT=1). The selection bit L_PREPAR
defines that the load value is stored in the load register (L_PREPAR=1). The
load value in the load register is then transferred to the counter when the
counter is next set. A new counter value is prepared L_PREPAR=1. Transfer
of the load value lasts at least 3 FC calls.
The FC must be called until it has reset the selected initiation bit
(L_DIRECT or L_PREPAR). While the job is in progress, the in/out parame-
ter remains set. The FC CNT_CTRL does not output any error messages with
regard to data exchange with the FM.
If the parameter you set is reset by the FC CNT_CTRL, the FM 450-1 has
accepted the FM 450-1. The read-back load value stored in DB1 is updated
by the FC CNT_CTRL.
You must generate the Initiation bit in accordance with your technological
requirements. This bit must only remain at 1 for one cycle. Please note that
the FC must be called until the in/out parameter is reset by the FC
CNT_CTRL.
7.1 Overview
Overview of the The counter function library offers you functions with which you can do the
Functions following:
S Initialize and parameterize the counter channel
S Transfer the load value and the comparison values
S Start and stop the counter channel
S Control digital inputs and outputs of the counter module
S Scan and reset the counter status
S Read the counter value
S Scan the diagnostics and error information
The table below lists the functions in alphabetical order:
Function Description
7
M7CntDisableOut Disable outputs
M7CntDisableSet Disable SET input
M7CntEnableOut Enable outputs
M7CntEnableSet Enable SET input
M7CntInit Initialize counter channel
M7CntLoadAndStart Load and start counter channel
M7CntLoadComp Transfer comparison values
M7CntLoadDirect
M7CntLoadPrep
Load counter channel
Prepare loading
M7CntPar
M7CntRead
Parameterize counter channel
Read counter value
M7CntReadDiag
M7CntReadLoadValue
Read diagnostics information
Read load value
M7CntReadParError
Read parameterization error
M7CntReadStatus Read counter status
M7CntResetStatus Reset counter status
M7CntStart Start counter channel
M7CntStop Stop counter channel
M7CntStopAndRead Stop counter channel and read counter
value
In the following sections you will learn how to use these functions in the user
program.
This chapter does not contain a detailed description of the individual parame-
ters or function arguments. Please see Chapter 12 for these.
Programming All the system functions and standard functions of the M7-300/400 system
Environment software are available to you for programming in the Borland C/C++ devel-
opment environment in STEP 7.
System functions support you in the following, for example:
S Task management
S Memory management
S Communications
S Interrupt processing
S Diagnostics processing
S Responding to system states
S Accessing process I/O
In addition, you can use the standard functions of the RMOS CRUN library.
You will find descriptions of these functions in the M7-300/400 system soft-
ware manuals.
7
Header File When creating a C program for counter control, you must link in the header
file M7CNT.H in the declaration section. All other necessary header files are
already linked when you work with Borland C programs.
Sequence The program structure for the counter module must be adapted to the require-
ments of your application. In most cases however, the program will contain
the following functions in the sequence given, with most of the functions
being optional.
The only strict requirement is that you call the M7CntInit function once per
channel before all other funcitons in the count library.
Function Explanation
1 M7LinkIOAlarm Trigger and handle process interrupts. Otherwise, no
(from M7-API) process interrupts are reported.
2 M7LinkDiagAlarm Trigger and handle diagnostics interrupts. Otherwise,
(from M7-API) no diagnostics interrupts are reported.
7
3
M7CntInit
Initialize counter channel (mandatory)
M7CntPar
4 Parameterize counter channel via the program. Other-
wise, you can parameterize the counter channel under
STEP 7 (see Parameter Assignment chapter).
5 M7CntLoadDirect Communicate a load value to the counter channel.
Otherwise, the counter channel starts with the value
0.
6
M7CntLoadComp
Communicate comparison values to the counter
channel. Otherwise, the comparison values are at 0.
7
M7CntEnableOut
Enable outputs if you want to use the digital outputs
of the counter channel.
8 M7CntStart Start counter channel if you have set an operating
mode with software gate. In the case of operating
modes with hardware gate, you start the counter
9
M7CntStop
channel via the START digital input.
Stop counter channel
10
M7CntRead
Read counter value, for example, for test purposes or
further processing.
You can use all further functions of the counter function library if required in
the user program in the sequence necessary for your application.
The first two functions belong to the M7-API library.
Example The software package includes an example program that clearly illustrates
use of the counter functions and makes it easier for you to start programming.
M7CntInit Counter channels are initialized via the M7CntInit function. The M7CntInit
Initializing the function must be called once for each counter channel used. It assigns a log-
Counter Channel ical channel number to the address of the counter channel. You specify the
address of the counter channel as a parameter. It consists of the following:
S The module starting address. With M7-300, you can specify the slot-de-
pendent default starting address or an address parameterized with STEP 7.
With M7-400, you specify the starting address parameterized with
STEP 7.
If you have assigned a symbol to the address, you can import this symbol
into your user program (see ProC/C++ for M7-300/400 User Manual).
S Input type (always M7IO_IN or M7IO_OUT, it doesnt matter which)
S Channel number. The channel number can take the following values:
in the FM 350-1 and IF counters the value is equal to 1 (1 channel)
in the FM 450-1 the value is {1/2} (2 channels) 7
Logical Channel The function supplies the logical channel number that you use for all fur-
Number ther accesses to this counter channel.
Parameterizing the Parameterizing sets the counter module to the requirements of your applica-
Counter Channel tion. You select the following, for example:
S The operating mode (with software gate or hardware gate)
S The sensor type (24 V or 5 V)
S The interrupt characteristics of the counter channel, etc.
See Chapter 9 for explanations of the settings.
The counter module must be parameterized. If a counter channel is not para-
meterized, you will receive an error message. There are two basic methods of
parameterizing the counter channel:
S With STEP 7
S With the M7CntPar function
Parameterizing You can parameterize the counter module in a user-friendly manner via
with STEP 7 screen forms in STEP 7 (see Chapter 5). The parameterization data set with
STEP 7 are transferred to the counter module when the M7-300/400 is started
up. This means that you must execute a SIMATIC M7 restart each time you
change the parameterization data.
Note
The parameters valid at any one time cannot be read out using STEP 7.
Parameterizing the You can parameterize and reparameterize a counter channel via the user pro-
Counter Channel gram using the M7CntPar function. You specify the new parameterization
with M7CntPar data in the M7CNT_PARAM structure when you call the M7CntPar function
(see the function library). The function transfers the parameterization data to
the counter module and the new settings become effective immediately.
Note
When you call the M7CntPar function, all the current parameterization data
are always completely overwritten and no part parameterizations can be
made.
When reparameterizations are made, any previously stored input or output
7 enables are lost. This means that the M7CntEnableSet and, for example,
M7CntEnableOut functions may have to be called again after M7CntPar.
Reparameterization overwrites already set comparison values and the load
value.
When reparameterizing with the M7CntPar function, counter pulses can also
be lost.
Reparameterization does not affect the other counter channel in the
FM 450-1.
Parameterization Table 12-1 (page 12-26) shows you the assignments between the components
Data of the M7CNT_PARAM structure and the parameterization data, data type,
value range and default value.
Load Value You can specify a starting value, the load value (LoadVal) to the counter
channel. The default load value is 0.
M7CntLoadDirect The load value can be transferred direct to the counter channel or it can be
M7CntLoadPrep stored temporarily in the counter-internal load register.
The counter channel can be loaded direct with the M7CntLoadDirect func-
tion.
With the M7CntLoadPrep function, the load value is not transferred direct to
the counter channel, but stored temporarily in the counter channel. The
counter channel accepts the load value if:
S a hardware pulse exists at the SET or START input
S an overflow or underflow takes place and a periodic operating mode is set
S the M7CntStart function is called 7
Comparison You can use the comparison values to control the digital outputs and to trig-
Values ger interrupts: As soon as the comparison value has been reached, an output
can be set, thus triggering a control action. In addition, you can stipulate that
a process interrupt is to be triggered as soon as a specific comparison value
has been reached. You determine the behavior of the digital outputs via para-
meterization. Appendix A contains a description of the possible settings and
their effects.
If you control the digital outputs with the comparison values, you must en-
able the digital outputs with the M7CntEnableOut function. This call is also
required after reparameterization of the counter channel.
M7CntLoadComp You can transfer one or two comparison values to the counter channel with
the M7CntLoadComp.
Digital Inputs The counter module has the digital inputs START, STOP, RESET (IF
961-CT1 only) and SET.
If an operating mode with hardware gate control has been set, you can con-
trol the counter module via hardware signals.
Using the SET digital input, the counter channel can be set to the load value
via an external signal (see Chapter 9).
M7CntEnableSet The SET input is enabled with the M7CntEnableSet function. The SET input
(or the associated loading of the counter channel) can be enabled for the up
count direction, the down count direction or both count directions with only
one function call.
M7CntDisableSet Analogously, the SET input can be disabled via the M7CntDisableSet func-
7 tion. The SET input can be disabled for the up count direction, the down
count direction or both count directions with only one function call in the
same way as it could be enabled.
Digital Outputs The counter module has two digital outputs (per counter channel) that you
can use to trigger responses in the process independently of the CPU.
M7CntEnableOut With the M7CntEnableOut function, one output or two of two possible out-
puts can be enabled with a single function call. The function enables the
physical output.
M7CntDisableOut With the M7CntDisableOut function, each output can be disabled individu-
ally or both outputs can be disabled simultaneously with a single function
call.
Starting the Depending on the operating mode, with hardware or software gate control,
Counter Channel there are two methods of starting the counter channel:
1. Via the software gate with the M7CntStart function
2. Via the hardware gate by a signal at the START digital input.
You set the operating mode via parameterization.
M7CntStart Using the M7CntStart, the counter channel is started via the software gate.
The function opens the software gate.
M7CntLoadAnd- In addition, the counter channel can be started via the M7CntLoadAndStart
Start function. When called, this function transfers a load value direct to the
counter channel. Like M7CntStart, this function also starts the counter chan-
nel via the software gate. 7
Note
In the case of the operating modes with hardware gate control, the
M7CntStart and M7CntLoadAndStart functions initiate a message pointing
out an operator error.
Stopping the There are two methods of stopping the counter channel:
Counter Channel
1. Via the software gate with one of the M7CntStop or M7CntStopandRead
functions.
2. Via the hardware gate by a signal at the STOP digital input
M7CntStop The counter channel is stopped with the M7CntStop function. The gate stop
function of the counter channel is switched on with this function. The func-
tion operates independent of the method of gate control (hardware gate or
software gate).
Note
If a counter channel with hardware gate control is stopped with the
M7CntStop function, the counter channel cannot be started until parameter-
ization or reparameterization (M7CntPar function) has taken place.
M7CntStopAnd- The counter channel can also be stopped via the M7CntStopAndRead func-
Read tion. This function stops the counter channel and reads the counter status.
The function is possible in all operating modes with gate control.
7.7 Reading the Counter Value and the Load Value, Scanning and Re-
setting the Status
Scanning The functions listed below are used for scanning information such as
Information
S Counter value
S Load value and
S Counter status
The counter status can be reset if required.
M7CntRead The counter status can be read with M7CntRead. The current status of the
counter channel is read and stored in the pActCntV return parameter.
M7CntStop The M7CntStopAndRead function stops the counter channel and reads the
7 AndRead counter status simultaneously. The current counter status is then stored in
pActCntV.
M7CntRead The load value of a counter channel can be read with M7CntReadLoadValue.
LoadValue
Scanning the You can scan the status of the counter channel with the M7CntReadStatus
Counter Status function. The function returns the counter status. See the description of
M7CntReadStatus in Appendix 12 for the meaning of the individual bits in
the counter status. The function can be used, for example, to scan the zero
pass to see if the counter channel is running, if the counter overflow has
taken place, which counter direction is in force, etc.
Resetting the Bits that have been set in M7CntReadStatus can be reset again via the
Counter Status M7CntResetStatus, in order, for example, to detect a renewed zero pass or a
renewed counter synchronization (multiple setting via SET digital input).
Registering at the Depending on the parameters assigned, the counter module can initiate pro-
Interrupt Server cess interrupts and/or diagnostics interrupts. In order to receive process inter-
rupts and diagnostics interrupts, the counter channel must be registered with
the interrupt server. For this purpose, you must call the following functions:
S M7LinkIOAlarm, to receive process interrupts
S M7LinkDiagAlarm, to receive diagnostics interrupts
See the System Software for M7-300 and M7-400 Programming Manual for
details of how to work with the interrupt server.
M7CntReadDiag By calling the M7CntReadDiag function, you can scan additional informa-
tion on the channel error. When the function is called, the diagnostics data set
DS1 is read. Data set DS1 contains the additional channel-specific diagnos-
tics information. The first 4 bytes of DS1 contain the current DS0 data set.
The diagnostics interrupts and data sets DS0 and DS1 are explained in
Chapter 13.
M7CntRead If the cause of the diagnostics interrupt is a parameter assignment error, you
ParError can scan more detailed information with the M7CntReadParError function.
The M7CntReadParError function returns an error number that indicates a
data error in the M7CNT_PARAM structure. From this you can determine
which parameterization datum contains the error or has been assigned an ille-
gal value and you can reparameterize the counter module accordingly.
Error Messages If an error occurs during execution of a function, the function supplies an
error number as a return value. You can determine the exact cause of the er-
ror with the help of this error number. See Chapter 13 for exact descriptions
of the error numbers.
Error Numbers The table shows the ranges of the error numbers and tells you where you can
find more detailed information on evaluating the error numbers:
Return Value Meaning Description in..
0
1 to 99
No error
Operator error Chapter 13
200 to 400
Parameter assignment error Chapter 13
7
1 to 999
M7API function error (e.g. System Software for
I/O configuration error) M7-300 and M7-400
Reference Manual
1000 to 1100 Error in the counter func- Chapter 13
tion library (e.g. channel
number invalid)
Checklist Use the checklist below to check and document the working steps for me-
chanical installation of the FM 450-1.
8 8
9
B
N
Encoder signal B
Encoder signal N
10 N Encoder signal N
Counter 2: Terminal Name Function
Incremental 5 V encoder 26 1M Encoder supply ground
with differential signals 27 5.2 VDC 5.2 V encoder supply
A, A, B, B, N and N
17 A Encoder signal A
18 A Encoder signal A
19 B Encoder signal B
20 B Encoder signal B
21 N Encoder signal N
22 N Encoder signal N
Connect 24 V Counter 1: Terminal Name Function
encoders Incremental 24 V 14 1M Encoder supply ground
encoder 16 24 VDC 24 V encoder supply
11 A* Encoder signal A *
12 B* Encoder signal B *
13 N* Encoder signal N *
Checklist Use the checklist below to check and document the working steps for para-
meterizing the FM 450-1. Parameterize the FM 450-1 counters one after the
other according to the checklist.
9.1 Definitions
Which Operating When you specify one of the three operating modes, you select the function-
Modes are ality with which you want to operate the FM 450-1. Table 9-1 gives an over-
Available? view of these operating modes.
Name Description
Continuous counting The FM 450-1 counts continuously from the current counter
(with or without gate) status.
Single counting with The FM 450-1 counts on opening the gate from the load
software gate or hard- value to the count limit.
ware gate
Periodic counting with The FM 450-1 counts on opening the gate between the load
software gate or with value and the count limit.
hardware gate
You can parameterize the two counters of the FM 450-1 in different modes.
The default setting is the Continuous counting mode.
The selection of the count mode, the behavior of the two digital outputs, the
pulse duration, the evaluation of the count signals and the choice of signal for
setting the counter are independent of the operating mode.
9
What Settings are You can adapt the FM 450-1 to your counting task with five settings.
Available? Table 9-2 gives an overview of these settings.
Name Description
Count mode With the count mode, you select the counting range
and so the count limits.
Behavior of digital outputs You can choose between six possibilities for the be-
Q0 and Q1 havior of the outputs on reaching the comparison
value.
Pulse duration The pulse duration indicates the time for which the
output is to be set.
Initiating process interrupts The FM 450-1 can initiate a process interrupt in the
case of a variety of selectable events.
Encoder You must specify different settings for the encoder
used. These settings are described in Appendix B.
Which Commands You can influence the count in the FM 450-1 with two commands. Table 9-3
are Available? gives an overview of these commands.
Name Description
Open and close gate The count is started by opening a gate and stopped by
closing the gate.
Set counter The counter can be set to the load value via different
signals.
Basic Parameter You carry out basic parameter assignment for each FM 450-1 when you con-
Assignment figure the hardware. Table 9-4 gives the meanings of the relevant parameters.
Continue
Termination of count
The module continues
9
Terminate cur- In the case of operating modes with hardware
rent job gate, the single count continues until it termi-
nates itself or until it is terminated by closing
of the hardware gate.
The periodic count is reparameterized to a
single count and terminated in the same way.
How Do You Select You select the operating modes and settings in the parameter assignment
the Operating screen forms of the FM 450-1.
Modes and
The parameter assignment data are saved automatically on the programming
Settings?
device and transferred automatically to the rack SDB.
You will find notes on installing the parameter assignment screen forms and
on parameterizing the FM 450-1 in the chapter on Assigning Parameters to
the FM 450-1 and in the integral Help.
How Do You You can change an operating mode or setting in the parameter assignment
Change Operating screen forms. The new operating mode or setting becomes valid after the
Modes and next FM 450-1 start-up.
Settings?
How Do You Give The commands are given either via hardware signals connected to the front
Commands? connector, or you set the relevant input parameter of the FC CNT_CTRL in
the user program in order to influence the count. The input parameters are
stored as control bits in the DB of the FC CNT_CTRL.
Control Bits and In addition to the control bits, there are status bits in the DB that signal the
Status Bits in the status of the count. The DB has two bytes for the control bits and two bytes
9 DB for the status bits (see Chapter 11).
Transferring the You transfer the status bits and the control bits to and from the module with
Status Bits and the the FC CNT_CTRL that you must link into your user program:
Control Bits
The control bits and status bits should, if possible, be addressed symbolically
in the user program. The symbolic names are used in the description of the
FC in this chapter.
You will find the precise description of the FC CNT_CTRL in Chapter 6
Programming the FM 450-1 and you will find the DB assignments in
Chapter 11.
Definition In this operating mode, the counter of the FM 450-1 counts continuously
from the current counter status. If the counter reaches the upper limit when
counting up, it jumps to the lower limit and continues to count from there
without any pulse losses. If the counter reaches the lower limit when count-
ing down, it jumps to the upper limit and continues to count without any
pulse losses.
Selecting the Gate You can select the gate function in this mode. The following possibilities are
Function available to you:
S Without gate (default)
S Software gate
S Hardware gate, level-controlled or edge-controlled
Counter status
Opening and You open and close the software gate of the counter in each case with the
Closing the input parameter SW_GATE of the FC CNT_CTRL.
Software Gate
Opening and You open and close the hardware gate of each counter by applying the rele-
Closing the vant signals to or removing the signals from the inputs 1I0 and 1I1 (counter
Hardware Gate 1) or 2I0 and 2I1 (counter 2).
When the hardware gate opens, the counter begins to count again from the
current counter status.
Terminating the You can also terminate the count when counting with the software gate or
Count with the hardware gate by using the gate stop function of the relevant counter. For this
Gate Stop purpose, set the input parameter GATE_STP of the FC CNT_CTRL (see
Function Chapter 6.2).
Definition In this mode, the counter of the FM 450-1 counts once from the load value to
the count limit.
Selecting the Gate You can select the gate function in this mode. The following possibilities are
Function available to you:
S Software gate
S Hardware gate, level-controlled or edge-controlled
Counter status
STS_OFLW
Upper count limit
Load value
Figure 9-2 Single Counting with Load Value and Gate Function
Opening and
Closing the
You open and close the software gate and set the counter to the load value
with the input parameter SW_GATE of the FC CNT_CTRL.
9
Software Gate
Behavior at the If the counter has reached the upper or lower count limit and a further count
Count Limits, pulse is received, the counter is set to the other count limit, the gate is closed
Software Gate and the count is terminated even if the SW_GATE parameter is still set. The
relevant bit is set in the DB of the FC CNT_CTRL.
If you want to restart the counter, you must reset the SW_GATE parameter.
The counter then begins to count from the load value.
Opening and You open and close the hardware gate and set the counter to the load value
Closing the by applying the relevant signals to or removing the signals from the inputs
Hardware Gate 1I0 and 1I1 (counter 1) or 2I0 2I1 (counter 2).
In the case of a level-controlled hardware gate, the gate is reopened and each
counter is set to the load value by a signal at input 1I0 (2I0).
If a positive edge is applied again to input 1I0 (2I0) in the case of an edge-
controlled hardware gate, the counter begins to count again from the load
value, regardless of whether the gate is closed or still open (retriggering),
provided input 1I1 (2I1) is not set.
Behavior at the If the counter has reached the upper or lower count limit and a further count
Count Limits, pulse is received, the counter is set to the other count limit, the gate is closed
Hardware Gate and the count is terminated even if the hardware gate is still open. The rele-
vant bit is set in the DB.
If you want to restart the counter, you must reset input 1I0 (2I0). The counter
then begins to count from the load value.
Terminating the You can also terminate the count at any time with the gate stop function. For
Count with the this purpose, set the input parameter GATE_STP of the FC CNT_CTRL.
Gate Stop
Function
Definition In this mode, the counter of the FM 450-1 counts from the load value to the
count limit, jumps back to the load value and continues to count.
Selecting the Gate You can select the gate function in this mode. The following possibilities are
Function available to you:
S Software gate
S Hardware gate, level-controlled or edge-controlled
Counter status
Load value
Figure 9-3 Periodic Counting with Load Value and Gate Function
Opening and
Closing the
You open and close the software gate and set the counter to the load value by
setting or resetting the relevant bit in the DB of the FC CNT_CTRL in the
9
Software Gate user program (see Chapter 11). When you open the software gate, the
FM 450-1 begins to count from the load value.
If you want to restart the counter, you must reset the bit. The counter then
begins to count from the load value.
Behavior at the If a counter reaches the upper or lower count limit, it begins to count from
Count Limits, the load value. The count is continued without pulse losses. The relevant bit
Software Gate is set in the DB:
Opening and You open and close the hardware gate and set the counter to the load value
Closing the by applying the relevant signals to or removing the signals from the inputs
Hardware Gate 1I0 and 1I1 (counter 1) or 2I0 and 2I1 (counter 2).
If a positive edge is applied again to input 1I0 (2I0) in the case of an edge-
controlled hardware gate, the counter begins to count again from the load
value, regardless of whether the gate is closed or still open (retriggering),
provided input 1I1 (2I1) is not set.
Behavior at the If a counter reaches the upper or lower count limit, it begins to count from
Count Limits, the load value. The count is continued without pulse losses. The relevant bit
Hardware Gate is set in the DB:
9
Terminating the You can also terminate the count at any time with the gate stop function. For
Count with the this purpose, set the input parameter GATE_STP of the FC CNT_CTRL.
Gate Stop
Function
Introduction There is a 32 bit-wide count register on the module. With the count mode,
you select whether the module is to count only in the positive range or
whether the 32nd bit is interpreted as a sign bit thus allowing negative num-
bers to be represented. Both count modes, 32 bit and +31 bit, are de-
scribed in this section.
Counting Ranges In both count modes, the FM 450-1 counts in different counting ranges. In
each case, an overflow or underflow is detected at the range limits.
In the +31 bit count mode, the counter status is represented in 2s comple-
ment.
"31 bit 2,147,483,648 to When the counter status changes When the counter status changes
2,147,483,647 from +2,147,483,647 to from to 2,147,483,648 to
2,147,483,648 +2,147,483,647
8000 0000H to 7FFF FFFFH
9
Overflow, In both count modes, a bit is set in the DB of the FC CNT_CTRL in the
Underflow and event of overflow and underflow (see Chapter 11).
Zero Pass
In the case of the +31 bits count mode, a bit is also set in the DB in the
event of a zero pass.
In the the 32 bits count mode, , overflow or underflow is additionally indi-
cated with zero pass, depending on the direction of count.
Event Bit in DB
Overflow STS_OFLW is set
Underflow STS_UFLW is set
Zero pass STS_ZERO is set
Initiating Process You can also signal the overflow, underflow and zero pass events via process
Interrupts interrupts.
Introduction You can store two comparison values (comparison value 1 and 2) on the
module for each counter. These comparison values are assigned to the two
digital outputs (comparison value 1: 1Q0 or 2Q0, comparison value 2: 1Q1 or
2Q1). The comparison values are compared with the current counter status. If
the counter status reaches a comparison value, the relevant output can be set.
Comparison You enter the two comparison values in the DB of the FC CNT_CTRL
Values 1 and 2 (CMP_V1, CMP_V2) and transfer them to the FM 450-1 by setting the bits
T_CMP_V1 or T_CMP_V2 (see Chapter 11). The count is not affected by
this.
The comparison values must be within the count range of the count mode set
in each case. The comparison value is interpreted in accordance with the
count mode selected. If you give FFFF FFFF H, for example, as the compari-
son value, the number is interpreted as 4,294,967,295 in 32 bit mode, and as
1 in +31 bit mode.
Enabling the Before the outputs can be set, you must enable them first by setting the rele-
Outputs vant bits in the DB (see Chapter 11). If you reset one of these bits the
associated output is switched off immediately even if you have parameterized
a pulse duration for them.
Status of the You can see the status of the two outputs from the green status LEDs and
Outputs from the relevant bits in the DB.
Behavior of the
O For both outputs, you can program one of 6 possible responses to reaching
Outputs the comparison value. The various possibilities are shown in the table below.
The output remains deactivated and is not affected by the comparison value, zero pass, over-
flow or underflow events.
Active between com-
parison value and
overflow Underflow Comparison value Overflow
The output is activated if the counter is in the range between the comparison value and over-
flow. Setting the counter to a value between the comparison value and overflow activates the
output.
Active between com-
parison value and un-
derflow Underflow Comparison value Overflow
The output is activated if the counter is in the range between the comparison value and under-
flow. Setting the counter to a value between the comparison value and underflow activates
the output.
Active for Pulse t
duration when com-
parison value is
Underflow Comparison value Overflow
9
reached in up direc-
tion The output is activated when the comparison value is reached in the up direction for the ex-
tent of the pulse duration.
Active for Pulse t
duration when com-
parison value is
Underflow Comparison value Overflow
reached in down
direction The output is activated when the comparison value is reached in the down direction for the
extent of the pulse duration.
Active for Pulse Up t t Down
duration when com-
parison value is Underflow Comparison value Overflow Underflow Comparison value Overflow
reached in up or
down direction The output is activated when the comparison value is reached for the extent of the pulse dura-
tion regardless of count direction.
= output active
t = pulse duration
Marginal If you parameterize the behavior of the digital outputs, you must observe the
Conditions following marginal conditions.
If... Then...
...you want to parameterize an output ac- ...you must ensure that the time between
tive between comparison value and over- these events is greater than the minimum
flow or underflow switching time of the outputs (switching
time: 300 s); otherwise, the control pulses
at the outputs are lost.
If the counter status reaches the compari-
son value again while the output is still
active, no new pulse is initiated. A further
pulse can only be initiated when the out-
put is no longer active.
...you want to parameterize an output ac- ...you must not enable a process interrupt
tive for the pulse duration in the up direc- on Reaching comparison value 1 or 2
tion down.
...you want to parameterize an output ac- ...you must not enable a process interrupt
tive for the pulse duration in the down on Reaching comparison value 1 or 2
direction up.
Switching Off the The outputs are switched off by the following events regardless of the param-
Outputs eter assignments:
S Module watchdog triggered (internal error)
9 S Removal of enable bits (CTRL_DQ0 for Q0 and CTR_DQ1 for Q1 in the
DB, see Chapter 11)
Default Setting The outputs are switched off in the default setting.
Introduction To adapt to the actuators used in your process (contactors, final control ele-
ments, etc.), you can specify the pulse duration during which the outputs are
set when a comparison value is reached. This section describes what you
must observe if you want to define a pulse duration for the outputs.
Using the Pulse The pulse duration defines the minimum time the output must be set. This
Duration setting only takes effect if you preselect the behavior of the output accord-
ingly. The pulse duration is not effective if the output is to be set between the
comparison value and the overflow or underflow.
The pulse duration begins when the output is set. The inaccuracy of the pulse
duration is less than 1 ms.
Value Range You can specify a value between 0 and 500 ms for the pulse duration. This
value applies for both outputs.
Note
If you specify zero as the pulse duration, you must ensure that the count
pulse times are greater than the minimum switching times of the digital out-
puts (switching time: 300 s, that is, count frequency less than 3333 Hz);
otherwise the control pulses at the outputs will be lost.
Check whether your actuator can respond with the switching time of 300 s to 9
cover this eventuality.
Selecting the Gate When you select the operating mode (see Section 9.1), you define which
gate you want to use for the count.
The figures below represent the different methods of opening and closing the
gates of the FM 450-1.
Level-Controlled Figure 9-4 shows level-controlled opening and closing of the hardware gate
Opening and of counter 1.
Closing of the
Hardware Gate
Counter status
1 2 3 4
Count pulses 4
9 Input 1I0
Open gate Close gate
Figure 9-4 Level-Controlled Opening and Closing of the Hardware Gate of Counter 1
As long as input 1I0 is set, the count signals can reach counter 1 and be
counted. If you remove input 1I0, the gate is closed. The count pulses are no
longer counted and counter 1 remains stopped.
If the gate of counter 1 is closed by an overflow or underflow, you must first
reset input 1I0 and apply a positive edge to input 1I0 in order to open the
gate again.
Edge-Controlled Figure 9-5 shows edge-controlled opening and closing of the hardware gate
Opening and of counter 1.
Closing of the
Hardware Gate
Counter status
1 2 3 4
Count pulses 4
Input 1I0
Open gate
Input 1I1
Close gate
Figure 9-5 Edge-Controlled Opening and Closing of the Hardware Gate of Counter 1
In the case of the edge-controlled gate function, the hardware gate of counter
1 is opened by a positive edge at input 1I0. The gate is closed by a positive
edge at input 1I1.
In the event of positive edges occurring simultaneously at inputs 1I0 and 1I1,
an opened gate is closed or a closed gate remains closed. If input 1I1 is set, a
positive edge at input 1I0 cannot open the gate.
The same applies analogously for counter 2 (inputs 2I0 and 2I1).
Status of Inputs The status of the inputs 1I0 (2I0) and 1I1 (2I1) are indicated by the green 9
1I0 (2I0) and LEDs CH1 IN 0 (CH 2 IN 0) and CH 1 IN 1 (CH 2 IN 1) and within the user
1I1 (2I1) program in bit STS_STA and STS_STP of the DB of the FC CNT_CTRL.
Opening and Figure 9-6 shows opening and closing of the software gate of counter 1.
Closing the
Software Gate
Counter status
1 2 3 4
Count pulses 4
SW_GATE
Bit set Bit reset
The software gate is opened and closed by setting and resetting the
SW_GATE input parameter of the FC CNT_CTRL.
The closed gate can be opened again by setting the SW_GATE input parame-
ter again.
Status of the The status of the software gate is indicated in bit STS_SW_G of the DB of
Software Gate the FC CNT_CTRL.
9 Terminating the
Count with the
You can also terminate the count with the gate stop function of the relevant
counter regardless of the signals applied or the status of the software gate.
Gate Stop For this purpose, set the GATE_STP input parameter of the FC_CNT_CTRL.
Function
If you reset this parameter, you can only open the gate for the relevant
counter again by a positive edge either at input 1I0 or 2I0 (hardware gate) or
by setting the SW_GATE (software gate) input parameter again.
Process Interrupt Opening and closing of a gate (hardware or software) can be used to initiate a
process interrupt (see Chapter 9.11).
Default Setting In the default setting, all gates are open and the count pulses are counted.
Introduction If you want to start or continue the count from a specific value (the load
value), you must parameterize the signal that is to be used to set this counter
to the load value. You can set the counter as follows:
S With the L_DIRECT input parameter of the FC_CNT_CTRL
S With an external signal either via input 1I2 (2I2) or via the input in con-
junction with the zero mark of the encoder.
This section describes the different methods and the time sequence when set-
ting a counter.
Load Value For the load value of a counter, you can parameterize a number within the
count limits of the count mode.
The load value is interpreted in accordance with the count mode selected.
If you specify FFFF FFFF H as the load value, for example, the number is
interpreted as 4,294,967,295 in 32 bit mode, and as 1 in +31 bit mode.
The load value is entered in the DB of the FC CNT_CTRL.
Setting the You can set a counter with the FC CNT_CTRL using the L_DIRECT input
Counter via the parameter regardless of external events. This can also be done while a count
User Program is in progress.
If you set the counter via the FC_CNT_CTRL call, this can initiate a process
interrupt.
9
Setting the You can select two different external signals with which you can set a
Counter with an counter to the load value.
External Signal
S Input 1I2 (2I2) only
S Input 1I2 (2I2) and zero mark of the encoder
You use the zero mark of the encoder if you want to synchronize the counter
to a specific counter status at a specific point in your process. This achieves
greater accuracy in the count.
The counter is set independently of the operating mode.
After the counter has been set with an external signal, bit STS_SYNC in the
DB is set.
Note
Synchronization of a counter with zero mark only makes sense if the gate is
open.
If you have only enabled one count direction when setting a counter with an
external signal, you must note that when the gate is closed the current count
direction is saved (frozen). This enables synchronization of the counter
against the enabled count direction.
Process Interrupt Setting the counter with an external signal can be used to initiate a process
interrupt.
Setting the A counter can be set with the load value via a rising edge at input 1I2 (2I2).
Counter with Input
You can determine the behavior of a counter of the FM 450-1 in the case of a
1I2 (2I2)
positive edge at input 1I2 (2I2) via the ENSET_UP and ENSET_DN vari-
ables in the DB of the FC CNT_CTRL and via parameterization.
Note
You must always set one of the two variables ENSET_UP and/or EN-
SET_DN so that the relevant counter can be set via input 1I2 (2I2).
Single Setting with Figure 9-7 shows single setting of counter 1 with input 1I2. The same applies
Input 1I2 (2I2) for counter 2 with input 2I2. In the situation represented, only ENSET_UP is
set, that is, the counter is set in the case of up counting.
With the first rising edge at input 1I2, the relevant counter is set as long as
ENSET_UP is set. If you want to reset this counter you must first reset the
relevant ENSET_UP and set it again. The next positive edge at input 1I2 then
results in the setting of the counter.
Count pulses
Input 1I2
ENSET_UP
Counter set Counter not set Counter not set Counter set
Multiple Setting Figure 9-8 shows multiple setting of counter 1 with input 1I2. The same ap-
with Input 1I2 (2I2) plies for counter 2 with input 2I2. In the situation represented, only EN-
SET_UP is set, that is, the counter is set in the case of up counting. 9
With every rising edge at input 1I2, the relevant counter is set as long as EN-
SET_UP is set. If you reset ENSET_UP, the counter will not be set by input
1I2. Only when you have set ENSET_UP again, will the next positive edge at
input 1I2 result in the setting of the counter.
Count pulses
Input 1I2
ENSET_UP
Setting the If you parameterize setting of a counter with the zero mark of the encoder,
Counter with the the relevant counter will be set with the rising edge of the zero mark.
Zero Mark
Setting is only carried out if input 1I2 (2I2) of the relevant counter is set at
the time of the rising edge of the zero mark.
You can determine the behavior of a counter of the FM 450-1 in the case of a
rising edge of the zero mark via the ENSET_UP and ENSET_DN variables
in the DB of the FC CNT_CTRL and via parameterization.
9 Note
You must always set one of the two variables ENSET_UP and/or EN-
SET_DN and input 1I2 (2I2) so that the relevant counter can be set with the
zero mark.
Single Setting with Figure 9-9 shows single setting of counter 1 with the zero mark. In the situa-
Zero Mark tion represented, only ENSET_UP is set, that is, the counter is set in the case
of up counting.
With the first rising edge at input 1I2, the relevant counter is set as long as
ENSET_UP and input 1I2 are set.
If you want to set counter 1 again, you must reset ENSET_UP and then set it
again. If input 1I2 is not set, setting takes place with the first zero mark after
setting of 1I2. If input 1I2 is set, setting takes place with the next zero mark.
The same applies for counter 2 with input 2I2.
Count pulses
Zero mark
Input 1I2
ENSET_UP
Multiple Setting Figure 9-10 shows multiple setting of counter 1 with the zero mark. In the
with the Zero Mark situation represented, only ENSET_UP is set, that is, the counter is set in the
case of up counting.
With every rising edge of the zero mark, the counter is set as long as EN-
SET_UP and input 1I2 are set.
The same applies for counter 2 with input 2I2.
9
Count pulses
Zero mark
Input 1I2
ENSET_UP
Counter set Counter set Counter Counter set Counter Counter set
not set not set
Introduction For the individual counters of the FM 450-1, you can set which events are to
initiate a process interrupt. For this purpose, parameterize the counter inter-
rupts in the parameter assignment screen forms.
What is a Process If you want to program a response to a specific event independently of the
Interrupt CPU cycle, each counter of the FM 450-1 can initiate a process interrupt. The
CPU interrupts the cyclic program on receiving the interrupts and executes
the process interrupt OB.
Which Events Can The following events in counter operation of the FM 450-1 can initiate a pro-
Initiate a Process cess interrupt (for each of the two counters independently of the other):
Interrupt?
S Opening of the gate (in the operating modes with hardware or software
gate)
S Closing of the gate (in the operating modes with hardware or software
gate)
S Overflow
S Underflow
S Reaching comparison value 1 in the up direction
S Reaching comparison value 1 in the down direction
9 S Reaching comparison value 2 in the up direction
S Reaching comparison value 2 in the down direction
S Zero pass
S Setting the counter with an external signal
You can select any number of events for process interrupt initiation, provided
the marginal conditions are observed.
Enabling the You enable the interrupts for the module in the parameter assignment screen
Process Interrupt forms when configuring the hardware and you decide whether the module is
to initiate a diagnostics interrupt and/or a process interrupt.
Process Interrupt If a process interrupt occurs, the user program is interrupted, the data is trans-
OB, OB 4x ferred from the module to the start information of OB4x and OB4x is called.
The process interrupt is acknowledged by exiting OB4x.
If there is no OB4x programmed, the CPU goes to STOP. If you then switch
back to RUN, the process interrupt requirements are deleted.
Start Information The temporary variable OB4x_POINT_ADDR is written in the start informa-
tion of OB4x.
The variable OB4x_POINT_ADDR (bytes 8 to 11) consists of four bytes.
The information concerning the event that has initiated the process interrupt
is entered in these four bytes. The table below shows which bits are set for
which interrupt. All unlisted bits are not significant and are set at zero.
Lost Process If an event occurs that is to initiate a process interrupt and the same previous
Interrupt event has not yet been acknowledged, no further process interrupt is initiated;
the process interrupt is lost.
This can result in the diagnostics interrupt Process interrupt lost depending
on the parameterization.
10.1 Overview
Introduction The count signals that the counters of the FM 450-1 can process are rectangu-
lar signals generated either by incremental encoders or pulse encoders.
Incremental encoders scan a grating and so generate rectangular electrical
pulses. They differ in pulse height and in the number of signals.
Pulse encoders such as light barriers or initiators (BEROs) supply only a rect-
angular signal with a specific voltage level.
Connecting You can connect different encoders to the counters of the FM 450-1 for sup-
Different Encoders plying the pulses for the count signals. Table 10-1 gives an overview of the
different encoders and the corresponding signals.
Encoder Signal
Incremental 5 V encoder Differential signals A, A, B, B and N, N
Incremental 24 V encoder A*, B* and N*
24 V pulse encoder 24 V with direction level
24 V pulse encoder 24 V without direction level
10
Signal A
Signal A
Signal B
Signal B
Signal N
Signal N
Direction of count Up Down
The module recognizes the direction of count from the ratio of signal A to B.
The figures in the next section (Pulse Evaluation) show which edges of sig-
nals A and B are counted in the down or up direction.
10
Changing the You can change the signals B and B via parameterization and so change the
Count Direction count direction without having to change the wiring.
How are the The module monitors for cable connection and for wirebreak or short-circuit.
Signals
Via parameterization, you can determine which of the three signal pairs are
Monitored?
monitored. You therefore need not wire unused signals if diagnostics for this
signal pair has been switched off via parameterization (set counter with zero
mark).
If all three signals report errors, either the encoder is defective, there is a
short-circuit in the 5.2 VDC encoder supply or there is no encoder connected.
If the module detects an error after you have assigned your parameters, an
entry is made in the diagnostics data sets DS0 and DS1. This can result in a
diagnostics interrupt if the relevant parameters have been assigned.
10.3 24 V Signals
24 V Incremental The incremental 24 V encoder supplies the signals A*, B* and N* in the
Encoder same time ratio as the signals A, B and N in the case of the 5 V incremental
encoder. Signals with a voltage of 24 V are indicated with an asterisk (*).
The signals A* and B* are phase-shifted by 90 each.
Encoders that do not supply inverse signals are known as asymmetric encod-
ers.
In the case of the inputs of 24 V encoder signals, you decide via parameter-
ization whether you connect source outputs or sink outputs to the counters.
See the encoder description for further information on this point.
You can also change the count direction via the Invert, not invert parameter
in the same way as for the incremental 5 V encoder.
24 V Pulse The encoder, for example an initiator (BERO) or a light barrier, supplies only
Encoder one count signal that must be connected to terminal A* of the front connec-
Without/With tor.
Direction Level
Additionally to this, you can connect a signal for direction detection to termi-
nal B*. If your encoder does not supply a corresponding signal, you can gen-
erate and connect a corresponding ID within the S7 or you can use a corre-
sponding process signal.
Figure 10-2 shows the sequence over time of the signals of a 24 V pulse en-
coder with direction level and the resulting count pulses.
10 Signal A*
Signal B * as Down
direction
Up
level
Up count
pulses
Down count
pulses
The count direction is defined via the parameterization of the encoder inputs.
Table 10-2 shows how the count direction changes in dependence on the in-
put parameterization.
When selecting the encoder, you must select the Frequency and direction
parameter.
Changing direction by inverting the B* signal is not possible with these count
signals.
Note
With this type of evaluation, the count value in the case of an oscillating
count signal can run away at the edge since all the signals are added to-
gether.
Input Filters for To suppress interference, you can parameterize input filters (RC elements)
24 V Count Inputs with a uniform filter time for the 24 V inputs A*, B* and N* and for the digi-
tal inputs. The following two input filters are available:
How are the 24 V count signals are not monitored for wirebreak or short-circuit.
Signals
Monitored?
Introduction The counters of the FM 450-1 can count the edges of the signals. Normally,
the edge at A (A*) is evaluated (single evaluation). To achieve a higher reso-
lution, you can decide via parameterization whether the signals are to have
single, double or quadruple evaluation.
Multiple evaluation is only possible in the case of incremental 5 V encoders
with signals A and B displaced by 90, or in the case of incremental 24 V
encoders with signals A* and B* displaced by 90.
Single Evaluation Single evaluation means that only one edge of A is evaluated; up count
pulses are captured on a rising edge of A and low level at B, and down count
pulses are captured on a falling edge of A and low level at B.
Figure 10-3 shows single evaluation of the signals.
Signal A (A*)
Signal B (B*)
Up count
pulses
Down count
pulses
Up Down
Signal A (A*)
Signal B (B*)
Up count
pulses
Down count
pulses
Up Down
Quadruple Quadruple evaluation means that the rising and falling edges of A and B are
Evaluation evaluated; whether up or down count pulses are generated, depends on the
levels of signals A and B.
Figure 10-5 shows quadruple evaluation of signals.
Signal A (A*)
Signal B (B*)
Up count
pulses
Down count
pulses Up Down
10
10
11
Overview 12.1 M7CntDisableOut Disable outputs 12-2
12.2
12.3
M7CntDisableSet
M7CntEnableOut
Disable SET input
Enable outputs
12-3
12-4
12.4
12.5
M7CntEnableSet
M7CntInit
Enable SET input
Initialize counter channel
12-5
12-6
12.6
12.7
M7CntLoadAndStart
M7CntLoadComp
Load and start counter channel
Transfer comparison values
12-8
12-9
12.8 M7CntLoadDirect
Load counter channel
12-11
12.9 M7CntLoadPrep Prepare loading 12-12
12.10 M7CntPar Parameterize counter channel 12-13
12.11 M7CntRead Read counter value 12-15
12.12 M7CntReadDiag Read diagnostics information 12-16
12.13 M7CntReadLoadValue Read load value 12-17
12.14 M7CntReadParError Read parameterization error 12-18
12.15 M7CntReadStatus Read counter status 12-19
12.16
12.17
M7CntResetStatus
M7CntStart
Reset counter status
Start counter channel
12-20
12-21
12.18 M7CntStop
Stop counter channel 12-22
12.19
12.20
M7CntStopAndRead
M7CNT_DIAGINFO
Stop counter channel and read
counter value
Contains diagnostics informa-
12-23
12-24
tion
12.21 M7CNT_PARAM Contains parameterization data 12-25
12.22 M7CNT_STATUS Contains status information 12-28
12.23 Error codes Error messages 12-29
12.1 M7CntDisableOut
Parameter Meaning
LogChannel
Logical channel number, detected by
M7CntInit
SelOut0
SelOut1
Selection bit for output 0
Selection bit for output 1
Description The two outputs of the counter channel can be disabled with this function.
The two bits SelOut0 and SelOut1 define which of the two outputs is to be
disabled. To disable an output, the desired bit must be set (= TRUE) when
the function is called. Both outputs can also be disabled in just one function
call. If the bit of an output = FALSE, the status of the output will not be
changed: an enabled output remains enabled and a disabled output remains
disabled.
Default: both outputs are disabled.
12.2 M7CntDisableSet
Parameter Meaning
LogChannel
Logical channel number, detected by
M7CntInit
SelSetUp
SelSetDn
Disable SET input for up count direction
Disable SET input for down count direc-
tion
Description The SET digital input for setting each counter channel is disabled with this
function. The two bits SelSetUp (up) and SelSetDn (down) determine for
which count direction the SET input is to be disabled. To implement the dis-
able function, the desired bit must be set (= TRUE) when the function is
called. Both count directions can also be disabled with just one function call
(SelSetUp = TRUE and SelSetDn = TRUE). If the bit of a count direction =
FALSE, the status of the SET input is not changed: an enabled SET input
remains enabled and a disabled SET input remains disabled.
Default: the SET input is disabled in both directions.
12.3 M7CntEnableOut
Parameter Meaning
LogChannel
Logical channel number, detected by
M7CntInit
SelOut0
SelOut1
Selection bit for output 0
Selection bit for output 1
Description The two outputs of the counter channel in each case can be enabled with this
function. The two bits SelOut0 and SelOut1 (down) determine which of the
two outputs is to be enabled. To enable an output, the desired bit must be set
(= TRUE) when the function is called. Both outputs can also be enabled with
just one function call. If the bit of an output = FALSE, the status of the out-
put is not changed: an enabled output remains enabled and a disabled output
remains disabled.
Default: both outputs are disabled
12.4 M7CntEnableSet
Parameter Meaning
LogChannel
Logical channel number, detected by
M7CntInit
SelSetUp
SelSetDn
Enable SET input for up count direction
Enable SET input for down count direc-
tion
Description The SET digital input for setting the counter channel in each case is enabled
with this function. The two bits SelSetUp (up) and SelSetDn (down) deter-
mine for which count direction the SET input is to be enabled. To implement
the enable function, the desired bit must be set (= TRUE) when the function
is called. Both count directions can also be enabled with just one function
call (SelSetUp = TRUE and SelSetDn = TRUE). If the bit of a count direction
= FALSE, the status of the SET input is not changed: an enabled SET input
remains enabled and a disabled SET input remains disabled.
The actual setting of the counter channel is carried out, depending on para-
meterization, either with the rising edge at the SET input or with the zero
mark signal with simultaneously active SET signal.
Default: the SET input is disabled in both directions.
12
Return Value 0 The function has been executed successfully
00 An error has occurred
12.5 M7CntInit
Parameter Meaning
Baddr
Base address of the interface submodule or the counter
module
PType I/O type of the counter channel. (Please specify one of the
values M7IO_IN or M7IO_OUT, it does not matter which)
Channel Channel number:
In the case of single-channel counter modules/submodules,
this is always 1
In the case of multi-channel counter modules, this is the
number of the counter channel
pLogChannel Logical channel number (return signal)
Description The function must be called once for each counter channel used.
Baddr, Ptype and Channel identify a counter channel. The function assigns a
logical channel number to this counter channel. This logical channel number
is used to access this channel by all other functions of the counter function
library.
12
Return Value 0 The function has been executed successfully
00 An error has occurred
M7CNT_LOGCHANNEL Ch5;
12
12.6 M7CntLoadAndStart
Function Load and start counter channel (for operating modes with software gate
control)
Parameter Meaning
LogChannel
Logical channel number, detected by
M7CntInit
LoadVal
Load value
Description The function transfers the load value specified at the time of calling direct to
the counter channel. Thereafter, the counter channel is started via the soft-
ware gate.
The function only works error-free in the counter operating modes with soft-
ware gate control. In the operating modes with hardware gate control, an op-
erating error is signaled but the load value is transferred anyway.
In the case of the operating modes with hardware gate control, use the
M7CntLoadDirect or M7CntLoadPrep functions to load the counter channel.
Default: the counter channel is preset with 0 and stopped.
Note The load value is interpreted depending on the count mode set for the counter
channel. Please ensure that the load value specified is within the count range
of the count mode set (cf. Table 12-1).
12
Return Value 0 The function has been executed successfully
00 An error has occurred
12.7 M7CntLoadComp
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
CmpV1 Comparison value 1
CmpV2 Comparison value 2
SelCmp1 Selection bit for comparison value 1
SelCmp2 Selection bit for comparison value 2
Description You can transfer the two comparison values CmpV1 and CmpV2 to the
counter channel in each case using this function. The selection bits SelCmp1
and SelCmp2 determine whether the associated comparison value is to be
transferred (SelCmpx = TRUE) or not (SelCmpx = FALSE). - If SelCmp1 =
TRUE and SelCmp2 = TRUE, both comparison values can also be transferred
simultaneously in one function call. If one selection bit is FALSE, the
associated comparison value will not be transferred and the old value is re-
tained.
Default setting: The comparison values are set to 0 as default.
12
Note The comparison values are interpreted in accordance with the count mode set
for the counter channel. Please ensure that the load value specified is within
the count range of the count mode set (cf. Table 12-1).
12
12.8 M7CntLoadDirect
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
LoadVal
Load value
Description The function transfers the load value (LoadVal) specified when the call was
made, direct to the counter channel in each case. The function is also
executed while the counter channel is operating.
Default: the counter channel is set to 0 and stopped as default.
Note The load value is interpreted in accordance with the count mode set for the
counter channel. Please ensure that the load value specified is within the
count range of the count mode set (cf. Table12-1).
12.9 M7CntLoadPrep
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
LoadVal
Load value
Description The function transfers the load value (LoadVal) specified when the call was
made, into the counter-internal load register. From there, the load value is
transferred into the counter channel and counted further from there if:
S a hardware pulse is present at the SET or START input
S an overflow or an underflow occurs (and a periodic operating mode is set)
S the M7CntStart function is called
Note The load value is interpreted in accordance with the count mode set for the
counter channel. Please ensure that the load value specified is within the
count range of the count mode set (cf. Table 12-1).
You can then read the current load value with the M7CntReadLoadValue
function. However, the function only supplies the new load value when one
of the three conditions has occurred and one count pulse has been received.
12
Return Value 0 The function has been executed successfully
00 An error has occurred
12.10 M7CntPar
Parameter Meaning
LogChannel Logical channel number, detected by M7CntInit
pCntParam Pointer to the structure M7CNT_PARAM with
the parameterization data
Description The function is called if the current parameters of the counter channel are to
be changed. Before calling the function, you must enter the desired parame-
terization data in the M7CNT_PARAM structure. After this, the function is
called to parameterize the counter channel specified. The new settings be-
come effective immediately.
Note When the M7CntPar function is called, the current parameterization data are
always completely overwritten and part parameterizations cannot be made.
Any previously stored enable of the inputs or outputs will also be lost as a
result of reparameterization. This means that the M7CntEnableSet and, for
example, M7CntEnableOut functions may need to be called again after
M7CntPar.
Reparameterization overwrites already set comparison values and the load
value.
In addition, counter pulses may be lost when reparameterizing with the 12
M7CntPar function.
In the FM 450-1, the other channel remains unaffected by reparameterization.
Errors in parameter assignment result in initiation of a diagnostics interrupt.
M7CNT_LOGCHANNEL LogChannel;
M7CNT_PARAM DS128;
if (M7CntPar(LogChannel,&DS128)!=M7CNT_DONE)
{ /*error handling*/ }
12
12.11 M7CntRead
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
pActCntV Pointer to current counter status
Description The current counter status of the counter channel is read and stored in
pActCntV.
Note The macros M7InitISADesc and M7LoadISADWord from the M7-API are
available for reading the counter status of an IF counter submodule. Access is
via the high-speed ISA bus. 12
See Also Function: M7CntInit, M7CntStopAndRead
12.12 M7CntReadDiag
Parameter Meaning
LogChannel Logical channel number, detected by M7CntInit
pDiagInfo Pointer to M7CNT_DIAGINFO structure with
the diagnostics information
Description When this function is called, the diagnostics data set DS1 is read and stored
in pDiagInfo. You should then call the M7CntReadDiag function if you re-
ceive a diagnostics interrupt Error on the channel (diagnostics byte 0, bit
3=1). The M7CNT_DIAGINFO structure supplies you with the diagnostics
data set DS1 which contains additional channel-specific diagnostics informa-
tion.
The structure of the diagnostics data set DS1 is explained in Chapter 13.
12.13 M7CntReadLoadValue
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
pActLoad Pointer to the ActLoad load value
Description The function reads the current load value of the counter channel and stores it
in pActLoad.
12.14 M7CntReadParError
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
pParError
Pointer to pParError parameterization er-
ror
Description You call this function if you have received a diagnostics interrupt (diagnos-
tics byte 0, bit 7=1) due to a parameterization error. The function reads the
last occurring parameterization error and stores it in pParError.
See Table 12-4 for the meanings of the parameterization errors.
12
See Also Function: M7CntInit, M7CntPar, M7CntReadDiag
Structure: M7CNT_DIAGINFO
Error Codes, Tabelle 12-4.
12.15 M7CntReadStatus
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
pCntStatus
Pointer to the M7CNT_STATUS structure
with the counter status
Description When this function is called, the counter status byte and the status of the in-
puts and outputs are read and stored in the M7CNT_STATUS structure. The
structure is designed so that you can access the information bit-by-bit.
12.16 M7CntResetStatus
Parameter Meaning
LogChannel Logical channel number, detected by M7CntInit
SelSynr
The Counter synchronization reached status bit is reset
(TRUE) or not reset (FALSE)
SelCmpStatus
The Zero pass, Overflow, Underflow status bits are
reset (TRUE) or not reset (FALSE)
Description The Counter synchronization reached, Zero pass, Overflow, and Under-
flow status bits of the counter channel can be reset using this function.
12
See Also Function: M7CntInit, M7CntReadStatus
Structure: M7CNT_STATUS
12.17 M7CntStart
Function Start Counter Channel - for Operating Modes with Software Gate
Control
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
Description The counter channel is started via the software gate with this function. The
function only works error-free in the counter modes with software gate con-
trol. In the case of the operating modes with hardware gate control, an opera-
tor error is signaled.
12.18 M7CntStop
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
Description The counter channel is stopped with this function. The function is effective in
all operating modes with gate control (hardware and software gate control).
In the continuous counting without gate control mode, an operator error is
signaled. In the operating modes with software gate control, the counter
channel can be restarted with the M7CntLoadAndStart or M7CntStart func-
tions. The counter channel then starts with
S the load value (M7CntStart) already in the load register, or
S the load value transferred when the M7CntLoadAndStart function was
called
Note When the M7CntStop function is called in the operating modes with hard-
ware gate control, the counter channel cannot be started until the parameters
have been reassigned.
12.19 M7CntStopAndRead
Parameter Meaning
LogChannel Logical channel number, detected by
M7CntInit
pActCntV Pointer to current counter status
Description This function stops the counter channel and reads the counter status. The
function is effective in all operating modes with gate control (hardware and
software gate control). In the continuous counting without gate control mode,
an operator error is signaled. In the operating modes with software gate con-
trol, the counter channel can be restarted with the M7CntLoadAndStart or
M7CntStart functions. The counter channel then starts with
S the load value (M7CntStart) already in the load register or
S the load value transferred when the M7CntLoadAndStart function was
called
Note When the M7CntStopAndRead function is called in the operating modes with
hardware gate control, the counter channel cannot be started until the param-
eters have been reassigned.
12.20 M7CNT_DIAGINFO
Function The structure is used for evaluating diagnostics messages with the
M7CntReadDiag function.
Syntax struct {
unsigned MdlDef:1; /* Module fault */
unsigned IntFlt:1; /* Fault, internal */
unsigned ExtFlt:1; /* Fault, external */
unsigned PntInfo:1; /* Fault in one channel */
unsigned ExtVolt:1; /* Ext. aux. voltage */
unsigned FldConn:1; /* Front connector missing */
unsigned NoConfig:1; /* Parameterization missing*/
unsigned ConfigEr:1; /* Parameterization error */
unsigned MdlType:4; /* Type class */
unsigned ChInfo:1; /*Channel information*/
unsigned ModInfo:1; /* Module information */
unsigned :2; /* Reserve */
unsigned SubMdlEr:1; /*Wrong/missing interf. submod. */
unsigned CommFlt:1; /* Communications fault */
unsigned MdlStop:1; /* RUN/STOP operating state */
unsigned WtchDogF:1; /* Watchdog tripped */
unsigned IntPSFlt:1; /* Intern. volt. failure */
unsigned PrimBat:1; /* Battery empty */
unsigned BckupBat:1; /* Backup failed*/
unsigned :1; /* Reserve */
unsigned RackFlt:1; /* Rack fault */
unsigned ProcFlt:1; /* Processor fault*/
unsigned EpromFlt:1; /* EPROM fault */
unsigned RamFlt:1; /* RAM fault */
unsigned ADUFlt:1; /*ADC/DAC fault*/
unsigned FuseFlt:1; /* Fuse tripped */
unsigned HWIntrF:1; /* Process interrupt lost */
unsigned :1; /* Reserve */
UBYTE ChType; /* Channel type */
UBYTE LgthDia; /*Diagn. info length per channel*/
UBYTE ChNo; /* Channel number */
unsigned GrpErr1:1; /*Channel group error 1 */
12 unsigned GrpErr2:1;
unsigned :6;
/* Channel group error 2 */
/* Reserve */
unsigned Ch1SigA:1; /* Channel 1, signal A fault */
unsigned Ch1SigB:1; /* Channel 1, signal B fault */
unsigned Ch1SigZ:1; /* Channel 1, signal N fault */
unsigned Ch1Betw:1; /* Channel 1, fault between channels*/
unsigned Ch15V2:1; /* Channel 1, 5.2 V encoder supply */
unsigned :3; /* Reserve */
unsigned Ch2SigA:1; /* Channel 2, signal A fault */
unsigned Ch2SigB:1; /* Channel 2, signal B fault */
unsigned Ch2SigZ:1; /* Channel 2, signal N fault */
unsigned Ch2Betw:1; /* Channel 2, fault between channels*/
unsigned Ch25V2:1; /* Channel 2, 5.2 V encoder supply */
unsigned :3; /* Reserve */
UBYTE Reserved11; /* Reserve */
} M7CNT_DIAGINFO;
12.21 M7CNT_PARAM
Function The structure is used for parameterizing the counter channel with the
M7CntPar function.
Syntax struct {
UWORD IntMask; /* Interrupt mask bits */
/* Bit 0: IOpenGate Int. on opening the gate */
/* Bit 1: ICloseGate Int. on closing the gate */
/* Bit 2: Ioflw Int. on overflow*/
/* Bit 3: Iuflw Int. on underflow */
/* Bit 4: ICmp1Up Int. on reaching comp. val.1 up*/
/* Bit 5: ICmp1Dn Int. on reaching comp. val.1 down*/
/* Bit 6: ICmp2Up Int. on reaching comp. val.2 up*/
/* Bit 7: ICmp2Dn Int. on reaching comp. val.2 down*/
/* Bit 8: Izero Int. on zero pass */
/* Bit 9 bis 11: Reserve */
/* Bit 12: Isync Int. on synchronization */
/* Bit 13 bis 15: Reserve */
UWORD EncSel; /* Encoder selection */
UWORD WireBrk; /* Activate wirebreak detector*/
UWORD SigEval; /* Evaluation of the signals */
UWORD FilCnt; /* Input filter counter inputs*/
UWORD FilDI; /* Input filter digital inputs*/
unsigned CntMod:1; /* Count mode */
unsigned SynMod:1; /* Synchronization type */
unsigned SynZero:1; /* Zero mark on synchronization */
unsigned SigInv:1; /* Inv. of cnt inp. signals */
unsigned ModHWG:1; /* Gate setting HW gate */
unsigned ConGate:1; /* Gate contr. for cont. cnt*/
unsigned ConHWG:1; /* HW gate for cont. cnt */
unsigned ConSWG:1; /* SW gate for cont. cnt */
unsigned : 8; /* Reserve */
UWORD MethDQ0; /* Behavior of output Q0 */
UWORD MethDQ1; /* Bahavior of output Q1 */
UWORD PulsDur; /* Pulse duration */
UWORD HystVal; /* Hysteresis */
UWORD OpMod; /* Operating mode */
UWORD Reserved12;
UWORD Reserved13;
/* Reserve */
/* Reserve */
12
UWORD Reserved14; /* Reserve */
UWORD Reserved15; /* Reserve */
} M7CNT_PARAM;
Note The reserve bits and words of the structure must be initialized with 0, other-
wise the counter channel could enter an undefined state.
The hysteresis value cannot be set and the HystVal parameter is not eva-
luated.
Table 12-1
Detailed Specifications of the Parameterization Data
Parameter
Meaning
Data
Type
Value Range Coding De-
fault
Bit
Interrupt mask bits (word 0)
IOpen-
Gate
nal gate
Interrupt on opening the inter- BOOL
{masked | free} {0|1} 0 0
IClose-
Gate
Interrupt on closing the inter-
nal gate
BOOL {masked | free} {0|1} 0 1
Ioflw Interrupt on overflow BOOL {masked | free} {0|1} 0 2
Iuflw
Interrupt on underflow BOOL {masked | free} {0|1} 0 3
ICmp1Up
Interrupt on reaching compar- BOOL
ison value 1 in up direction
{masked | free} {0|1} 0 4
ICmp1Dn
Interrupt on reaching compar- BOOL
ison value 1 in down direc-
{masked | free} {0|1} 0 5
tion
ICmp2Up Interrupt on reaching compar- BOOL {masked | free} {0|1} 0 6
ison value 2 in up direction
ICmp2Dn Interrupt on reaching compar- BOOL {masked | free} {0|1} 0 7
ison value 2 in down direc-
tion
Izero
Interrupt on zero pass
BOOL
BOOL
{masked | free}
{masked | free}
{0|1}
{0|1}
0
0
8
12
Isync Interrupt on synchronization
EncSel Receiver selection WORD {5 V count signal | 24V count sig- {0|1} 0
nal} with IF 961-CT1
{5 V count signal | {0|1|2}
24 V count signal source output |
24 V count signal sink output}
with FM 450-1
WireBrk Diagnostics active for wire- WORD { A, B, N | A | A,B | {0|1| 0
break detection on signal pair no diagnostics} 2|3}
12
SigEval Evaluation of the signals WORD {single | double | quadruple | {0|1| 0
frequency direction} 2 |3}
FilCnt; Input filter for counter inputs WORD { 200 kHz | 50 kHz } {0|1} 0
with IF 961-CT1
{ 200 kHz | 20 kHz }
with FM 350-1, 450-1
FilDI
Input filter for digital inputs
WORD { 200 kHz | 50 kHz }
with IF 961-CT1
{0|1} 0
{ 200 kHz | 20 kHz }
with FM 350-1, 450-1
CntMod Count mode BOOL { 32 bit (w/o sign) | {0|1} 0 0
+/ 31 bit }
SynMod Synchronization type BOOL { single | periodic } {0|1} 0 1
Table 12-1
Detailed Specifications of the Parameterization Data, Continued
Parameter
Meaning
Data
Type
Value Range Coding De-
fault
Bit
SynZero
Zero mark on synchronization BOOL
{with zero mark |
without zero mark }
{0|1} 0 2
SigInv Change of direction with BOOL { not inverted | {0|1} 0 3
track B inverted }
ModHWG Gate setting hardware gate BOOL {level-controlled| {0|1} 0 4
edge-controlled}
ConGate
Gate control for continuous
counting mode
BOOL { disabled | enabled } {0|1} 0 5
ConHWG
counting mode
Hardware gate for continuous BOOL
{ disabled | free } {0|1} 0 6
ConSWG
Software gate for continuous
counting mode
BOOL { disabled | free } {0|1} 0 7
MethDQ0
Behavior of output Q0
WORD { switch off | {0| 0
active from comparison value to 1|
overflow |
active from comparison value to
underflow |
2|
active for Pulse duration on 3|
MethDQ1 Behavior of output Q1 WORD 0
overrange up direction |
active for Pulse duration on un- 4|
derrange down direction |
active for Pulse duration on over- 5}
range or underrange }*
PulsDur
Pulse duration
WORD { 0 : 500 } D {0:1F4}
H
0
HystVal
Hysteresis
WORD { 0 : 255 } D
cannot be set, the parameter is not
evaluated
{ 0:FF }
H
0
12
OpMod
WORD { Continuous counting (with or {0| 0
Operating mode
without gate) |
single counting with SW gate | 1|
single counting with HW gate|
2|
periodic counting with SW gate |
3|
periodic counting with HW gate }
4}
* See Section 9.7 Behavior of the Digital Outputs
12.22 M7CNT_STATUS
Function The structure is used for status scanning with the M7CntReadStatus function.
Syntax struct {
unsigned StsSet:1; /* Status: SET input 1 = active */
unsigned :1; /* Filler bit*/
unsigned StsSta:1; /* Status: START input 1 = active */
unsigned StsStp:1; /* Status: STOP input 1 = active */
unsigned StsCmp1:1; /* Status:Output comparator 1
1 = on */
unsigned StsCmp2:1; /* Status: Output comparator 2
1 = on */
unsigned :2; /* Reserve */
unsigned StsRun:1; /* Status: Counter is running */
unsigned StsDir:1; /* Status: Direction of count,
0 = up, 1 = down*/
unsigned StsZero:1; /* Status: Zero pass
1 = occurred*/
unsigned StsOflw:1; /* Status:Counter overflow
1 = occurred*/
unsigned StsUflw:1; /* Status: Counter underflow
1 = occurred */
unsigned StsSync:1; /* Status: Counter synchronization
1 = carried out */
unsigned StsGate:1; /*Status gate, 1 = open*/
unsigned StsSWG:1; /* Status SW gate, 1 = open */
} M7CNT_STATUS;
12
Return Value The success or failure of a function is indicated by the return value. The re-
turn value is of the M7ERR_CODE data type. The function supplies the fol-
lowing return values:
M7CNT_DONE: Function completed successfully
!=M7CNT_DONE: Error in execution
If an error occurs, the return value will not equal 0. The cause of the error
can be limited with the help of this value. Definitions for the error codes are
stored in the header file M7CNT.H.
Return Value Meaning
0
1 to 99
No error
Operator error
200 to 400
1 to 999
Parameterization error
M7API function error (e.g. I/O configuration error)
1000 to 1100 Error in the counter function (e.g. invalid channel number)
12
12
Error Code No. Meaning Remedy
M7CNTE_PAR_ENC_SEL 201 Coding for receiver selection Please change the relevant param-
wrong eter of the M7CNT_PARAM*
structure or in the case of the
FM 350-1 the coding key.
M7CNTE_PAR_WIRE_BRK
202 Coding for diagnostics of the sig-
nal pair wrong
M7CNTE_PAR_SIG_EVAL
203 Coding for the evaluation of the
signals wrong
M7CNTE_PAR_FIL_CNT
204 Coding for input filter counter in-
put 24 V wrong
M7CNTE_PAR_FIL_DI 205 Coding for input filter digital in-
puts wrong
M7CNTE_PAR_SIG_INV 206 Change of direction not permissi-
ble
M7CNTE_PAR_METH_DQ0 207 Coding for behavior of Q0 wrong
M7CNTE_PAR_METH_DQ1 208 Coding for behavior of Q1 wrong Please change the relevant param-
eter of the M7CNT_PARAM
M7CNT PARAM
M7CNTE_PAR_PULS_DUR 209 Pulse duration too long structure*
st uctu e
M7CNTE_PAR_HYST_VAL
M7CNTE_PAR_OP_MOD
210
211
Hysteresis too great
Wrong operating mode
M7CNTE_PAR_SW_HW_GATE 212
Both gate types or no gate type
specified
M7CNTE_PAR_DIR_IMP_AL
215 Direction for pulse output and
process interrupt must be same
M7CNTE_PAR_AL_GATE
216 Interrupts from internal gate only
possible in operating mode with
gate
M7CNTE_PAR_AL_METH_DQ 217 Output behavior and interrupt
12
Where is the Fault If one of the two red diagnostics LEDs lights up, a fault has occurred either
Indicated? on the module (internal fault = INTF diagnostics LED) or at the cable con-
nections (external fault = EXTF diagnostics LED).
Which Faults are The following faults are indicated by the diagnostics LEDs lighting up:
Indicated?
Initiating a All faults except the EPROM test fault, can initiate a diagnostics interrupt
Diagnostics provided you have enabled the diagnostics interrupt in the relevant parameter
Interrupt assignment screen form. You can see which fault has caused the LED to light
up from the diagnostics data sets DS0 and DS1. The assignments of the diag-
nostics data sets DS0 and DS1 are described in the next section.
13
What is a If a user program is to respond to an internal or external fault, you can para-
Diagnostics meterize a diagnostics interrupt that stops the cyclical program of the CPU
Interrupt? and calls the diagnostics interrupt OB (OB82).
Which Events Can The list shows you which events can initiate a diagnostics interrupt:
Initiate a
S Fault in external auxiliary voltage 1L+/1M
Diagnostics
Interrupt? S 5.2 VDC encoder supply short-circuited or overloaded
S Error in module parameterization
S Watchdog tripped
S RAM defective
S Process interrupt lost
S Fault in signal A (wirebreak, short-circuit, cable missing)
S Fault in signal B (wirebreak, short-circuit, cable missing)
S Fault in signal N (wirebreak, short-circuit, cable missing)
Enabling the Diag- You disable or enable the interrupts for the module in the parameter assign-
nostics Interrupt ment screen forms and you decide there whether the module is to initiate a
diagnostics interrupt and/or a process interrupt.
Responses to a If an event occurs that can initiate a diagnostics interrupt, the following hap-
Diagnostics pens:
Interrupt
S The diagnostics information is stored in diagnostics data sets DS0 and
DS1.
S A fault LED lights up.
S The diagnostics interrupt OB is called (OB82).
S The diagnostics data set DS0 is entered in the start information of the
diagnostics interrupt OB.
13
S The count continues unchanged.
If OB82 has not been programmed, the CPU goes to STOP.
Diagnostics Data The information as to which event has initiated a diagnostics interrupt is
Set DS0 and DS1 stored in the diagnostics data sets DS0 and DS1. The diagnostics data set
DS0 comprises four bytes; DS1 comprises 12 bytes with the first four bytes
being identical to DS0.
Reading the Data The diagnostics data set DS0 is automatically transferred to the start informa-
Set from the tion when the diagnostics OB is called.These four bytes are stored there in
Module the local datum (bytes 8 to 11) of OB82.
You can read out diagnostics data set DS1 (and so also the contents of DS 0)
from the module with the FC DIAG_INF. It only makes sense to do this, if a
fault in a channel is signaled in DS0.
Assignments of Table 13-1 shows the assignments of diagnostics data set DS0 in the start
the Diagnostics information. All unlisted bits are insignificant and take the value zero.
Data Set DS0 in
the Start
Information
Table 13-1 Assignments of Diagnostics Data Set DS0
13 2
3
3
3
Watchdog tripped
RAM defective
8:x:33
8:x:43
6 Process interrupt lost 8:x:46
Diagnostics Data The diagnostics data set DS1 consists of 12 bytes. The first 4 bytes are identi-
Set DS1 cal with diagnostics data set DS0. Table 13-2 shows the assignments of the
remaining bytes. All unlisted bits are insignificant and take the value zero.
This data set is entered in DB1 from DW54 by the FC DIAG_INF.
How Does the If you want to enter the diagnostics message in the diagnostics buffer, you
Diagnostics Text must call the SFC 52 Enter user-specific message in diagnostics buffer in
Appear in the the user program. The event number of the diagnostics message in each case
Diagnostics
Buffer?
is specified in the input parameter EVENTN. The interrupt is entered in the
diagnostics buffer with x=1 as incoming and with x=0 as outgoing. The diag- 13
nostics buffer contains the relevant diagnostics text in the Meaning column
as well as the time of the entry.
When Do Data If new parameters are transferred to the module, the FM 450-1 checks these
Errors Occur? parameters. If errors occur during this check, the module signals these data
errors.
Wrong parameters are not accepted by the module.
Where are Data The data errors are entered with their error numbers in DB1 by the FC
Errors Indicated? CNT_CTRL. You can access this data word in the user program via variable
identifier DA_ERR_W. Table 13-3 shows the number of the data errors and
the meaning of these errors.
No. Meaning
0 No error
201 Value too great for receiver selection
202 Value too great for diagnostics signal pair
203 Value too great for signal evaluation
204 Value too great for input filter of the 24 V counter signals
205 Value too great for the input filter of the digital inputs
206 Change of direction not permissible
207 Value too great for behavior of the digital output 1Q0 (2Q0)
208 Value too great for behavior of the digital output 1Q1 (2Q1)
209 Pulse duration wrong or too long
211 Wrong operating mode selected
212 No gate specified or both gates specified
215 When parameterizing the process interrupt Reaching the comparison value in
up or down count direction, a different count direction was specified to that
specified in the parameterization of the behavior of the outputs Output active
for one pulse duration in up or down direction. The directions must agree.
13 216 Interrupts from the gate control only possible in the operating modes with gate
control.
217 In the case of the behavior of the digital outputs Active between the compari-
son value and overflow or Active between comparison value and underflow,
no interrupt is permissible on reaching the comparison values.
How are Data Correct the values for the parameters in accordance with the specifications.
Errors Transfer the corrected parameter set again to the FM 450-1. The FM 450-1
Acknowledged? checks the parameters again and deletes the data error in DB1.
When Do Operator Operator errors occur when you operate the module wrongly by setting incor-
Errors Occur? rect control signals.
Where are the The operator error numbers are entered in DB1 by the FC CNT_CTRL. You
Operator Errors can access this data word in your program via the variable identifier
Indicated? OT_ERR_B.
What Operator Table 13-4 shows the possible numbers of the operator errors and their mean-
Errors Exist? ing.
How are Operator Acknowledge the error with the OT_ERR_A parameter in DB1.
Errors
Acknowledged?
13
13
FM Approval The following FM approval has been issued for the SZ-400:
FM approval to Factory Mutual Approval Standard Class Number 3611,
Class I, Division 2, Group A, B, C, D.
Warning
! Personal injury or property damage can result.
In hazardous areas, personal injury or property damage can result if plug-in
connections are interrupted during operation of an S7-400.
The S7-400 must always be de-energized prior to separating plug-in connec-
tions in hazardous areas.
Warning
! WARNING - DO NOT DISCONNECT WHILE CIRCUIT IS LIVE
UNLESS LOCATION IS KNOWN TO BE NONHAZARDOUS
Area of SIMATIC products have been designed for use in the industrial area.
Application
They can also be used in the domestic environment (household, business and
trade area, small plants) with individual approval. You must acquire the indi-
vidual approval from the respective national authority or testing body.
Observing the SIMATIC products meet the requirements if you observe the installation
Installation guidelines described in the manual when installing and operating the equip-
Guidelines ment.
Asymmetric Asymmetric signals are two pulse trains phase-shifted by 90 degrees and with
Signals a zero mark signal if required.
Configuration Assignment of modules to mounting racks, slots and addresses. When config-
uring the hardware, the user fills in a configuration table under STEP 7.
Double Evaluation Double evaluation means that the rising edges of pulse trains A and B are
evaluated on an incremental encoder.
Encoders Encoders are used for precise acquisition of, among others, rectangular sig-
nals, paths, positions, velocities, rotational speeds, dimensions, etc.
Encoders with Encoders with asymmetric output signals generate two pulse trains phase-
Asymmetric Ouput shifted by 90 degrees and with a zero mark signal if required.
Signals
Encoders with Encoders with symmetric output signals generate two pulse trains phase-
Symmetric Output shifted by 90 degrees, with a zero mark signal if required, and the corre-
Signals sponding inverted signals.
Function (FC) In accordance with IEC 1131-3, a function (FC) is a code block without static
data. A function makes it possible to transfer parameters in the user program.
This makes functions suitable for programming frequently recurring complex
functions.
Function Module A function module (FM) is a module that offloads the CPU of the S7 and M7
(FM) programmable controllers of time-critical or memory-intensive process signal
handling tasks. FMs normally use the internal communications bus for high-
speed data exchange with the CPU. FM applications include: Counting, posi-
tioning, closed-loop control.
Incremental Incremental encoders capture paths, positions, speeds, rotational speeds, di-
Encoders mensions, etc., by counting small increments.
Increments per Increments per encoder revolution specifies the number of increments that an
Encoder encoder gives in one revolution.
Revolution
Power Control The power control drives the motor and can consist, for example, of a simple
contactor circuit.
Pulse Duration The pulse duration specifies the minimum time for which an output is to be
set.
Quadruple Quadruple evaluation means that all edges of the pulse trains A and B are
Evaluation evaluated on an incremental encoder.
Single Evaluation Single evaluation means that the rising edge of pulse train A is evaluated on
an incremental encoder.
Zero Mark The zero mark is located on the second track of an incremental encoder. The
zero mark supplies a zero mark signal after each revolution.
Zero Mark Signal The zero mark signal is output by an incremental encoder after every revolu-
tion.
D
Numbers
Data errors, 13-6
24 V encoder signals, 4-5
Diagnostic data set DS0, assignments, 13-4
input filter, 1-3, 4-5, 10-5
Diagnostics data set DS1, assignments, 13-5
24 V signals, 10-4
Diagnostics interrupt, 13-2, 13-3
24 VDC encoder supply, 4-5
enabling, 13-3
5 V differential signals, 10-3
OB 82, 13-3
Diagnostics LEDs, 13-2
Digital input I0, status, 9-17
A Digital input I1, status, 9-17
Approbation. Siehe Approvals Digital input modules, A-3
Approvals Digital inputs, 4-6
CSA, A-1 input filter, 4-6
FM, A-1 Digital outputs, 4-6
UL, A-1 behavior, 9-13
Auxiliary voltage 1L+, 1M, 4-5 enabling, 9-12
status, 9-12
switching off, 9-14
B
Basic parameter assignment, 9-3
Behavior of the digital outputs, marginal condi- E
tions, 9-14 ENSET_DN, 9-20
ENSET_UP, 9-20
External faults, 13-2
C
CE, marking, A-2
Checklist F
mechanical installation, 8-2 FM 350-1
parameterization, 8-4 overview of commands, 9-3
Command: open and close gate, 9-16 overview of settings, 9-2
Command: set counter, 9-19 FM 450-1
Commands, 9-3 overview of operating modes, 9-2
give, 9-4 S7400 configuration, 1-7
Comparison value, 1-2, 2-2, 9-12 Front connector, 1-6, 4-2
Continuous counting, 2-3 terminal assignments, 4-2
Control bits, 9-4 Front connector of the FM 450-1, 4-2
G P
Gate stop function, 9-8, 9-10, 9-18 Parameter assignment screen forms
calling, 5-2
installing, 5-2
H integral help function, 5-2
Periodic counting, 2-4
Hardware gate, 2-5
Process interrupt, 1-2, 9-24
edge-controlled opening and closing, 9-17
enabling, 9-24
level-controlled opening and closing, 9-16
initiate, 9-24
status, 9-17
OB 40, 9-24
Hysteresis, 1-3
Pulse duration
default value, 9-15
value range, 9-15
I
Input delay, 4-6
Input filter, 4-6 Q
Internal faults, 13-2
Q0. Siehe Digital outputs
Q1. Siehe Digital outputs
Quadruple evaluation, 10-7
L
Labeling strips, 1-6
LEDs, meaning, 1-6 R
Load value, 1-2, 2-2, 9-19
READ ME file, 5-2
RESET status, 4-11
M
Main application area, 1-4 S
Marking, CE, A-2
Selecting the gate function, 9-5, 9-7, 9-9
SET, 9-19
Siehe auch Digital inputs
O Setting the counter
OB 40, 9-24 via the user program, 9-19
OB 4x, start information, 9-25 with an external signal, 9-19
OB82, 13-3 with input I2, 9-20
Opening and closing the hardware gate, 9-10 with the zero mark, 9-22
Opening and closing the software gate, 9-5, 9-7, Setting: behavior of the digital outputs, 9-12
9-9 Setting: counting mode, 9-11
Operating mode continuous counting, 9-5 Setting: pulse duration, 9-15
Operating mode periodic counting, 9-9 Settings, 9-2
Operating mode single counting, 9-7 select, 9-4
Operating modes, 9-2 Single counting, 2-3
select, 9-4 Software gate
Operator errors, 13-7 opening and closing, 9-18
Order number, 1-5 status, 9-18
stliche Rheinbrckenstr. 50
D76181 Karlsruhe
Federal Republic of Germany
From:
Your Name: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Your Title: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Company Name: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Street: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
City, Zip Code_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Country: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Phone: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Automotive Pharmaceutical
Chemical Plastic
Electrical Machinery Pulp and Paper
Food Textiles
Instrument and Control Transportation
Nonelectrical Machinery Other _ _ _ _ _ _ _ _ _ _ _
Petrochemical
C79000-G7076-C450-01 1
Remarks Form
Your comments and recommendations will help us to improve the quality and usefulness
of our publications. Please take the first available opportunity to fill out this questionnaire
and return it to Siemens.
Please give each of the following questions your own personal mark within the range
from 1 (very good) to 5 (poor).
1. Do the contents meet your requirements?
2. Is the information you need easy to find?
3. Is the text easy to understand?
4. Does the level of technical detail meet your requirements?
5. Please rate the quality of the graphics/tables:
6.
7.
8.
Additional comments:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _