You are on page 1of 79

Configuring the SIMATIC FM 350-2

Counter Module in SIMATIC PCS 7

SIMATIC PCS 7

Application Description December 2013

Applikationen & Tools


Answers for industry.
Warranty and liability

Warranty and liability

Note The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These application examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these Application Examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these
application examples and other Siemens publications e.g. Catalogs the
contents of the other documents have priority.

We do not accept any liability for the information contained in this document.

Any claims against us based on whatever legal reason resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
Siemens AG 2013 All rights reserved

not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (Produkthaftungsgesetz), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
deficiency or breach of a condition which goes to the root of the contract
(wesentliche Vertragspflichten). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change of the burden of
proof to your detriment.
Copyright

Any form of duplication or distribution of these Application Examples or excerpts


hereof is prohibited without the expressed consent of Siemens Industry Sector.

Caution
The functions and solutions described in this article confine themselves to the
realization of the automation task predominantly. Please take into account
furthermore that corresponding protective measures have to be taken up in the
context of Industrial Security when connecting your equipment to other parts of the
plant, the enterprise network or the Internet. Further information can be found
under the item ID 50203404.
http://support.automation.siemens.com/WW/view/en/50203404

Siemens Industry Online Support


This article is taken from the Siemens Industry Online Support. The following link
takes you directly to the download page of this document:
http://support.automation.siemens.com/WW/view/en/83146298

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 2
Table of contents

Table of contents
Warranty and liability ............................................................................................... 2
1 Task................................................................................................................. 4
1.1 Task .................................................................................................. 4
1.2 Solution ............................................................................................. 5
1.3 Hardware and software components .................................................. 6
1.3.1 Validity .............................................................................................. 6
1.3.2 Components used ............................................................................. 6
2 Basic principles of the counter module ........................................................ 8
2.1 Hardware information ........................................................................ 8
2.2 "Pcs7Cnt1" driver block ..................................................................... 9
2.3 Gate function of the counter channels Activating, interrupting
and canceling a channel .................................................................. 10
2.3.1 Overview ......................................................................................... 10
2.3.2 Interrupting and canceling a counting mode ..................................... 11
2.3.3 Interrupting a measuring mode ........................................................ 12
2.4 Counting rages of the module channels ........................................... 13
2.5 Operating modes for the channels ................................................... 14
2.5.1 Introduction to counting.................................................................... 14
2.5.2 Continuous counting ........................................................................ 15
2.5.3 Single Counting ............................................................................... 16
Siemens AG 2013 All rights reserved

2.5.4 Periodic counting ............................................................................. 17


2.5.5 Frequency measurement ................................................................. 18
2.5.6 Rotational speed measurement ....................................................... 18
2.5.7 Time period measurement ............................................................... 19
3 Configuration ................................................................................................ 20
3.1 Requirements for configuring the counter module ............................ 20
3.2 Configuring the counter module in HW Config .................................. 26
3.3 Creating data areas in the symbol table ........................................... 30
Copyright

3.4 Adding a driver block in the master data library ................................ 33


3.5 Connecting a channel data area to the driver block .......................... 35
3.6 Configuring the counter module channels ........................................ 40
3.6.1 Continuous counting ........................................................................ 40
3.6.2 Single/Periodic counting .................................................................. 44
3.6.3 Measurements................................................................................. 49
3.6.4 Hardware gate ................................................................................. 54
3.6.5 Canceling or interrupting the counting function ................................. 58
3.6.6 Count direction ................................................................................ 62
3.6.7 Loading values ................................................................................ 66
3.6.8 Comparing the counter reading with a value .................................... 68
3.6.9 Extending the counter limits ............................................................. 72
4 Related literature .......................................................................................... 79
5 History .......................................................................................................... 79

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 3
1 Task

1 Task
1.1 Task
Every automated system involves counting, dosing, or measuring. Sensors and
actuators supply signals that are read and evaluated by an automation
system (AS).
Every CPU can load inputs and outputs into the internal memory when an
operation block (OB) is called. This internal memory is named process image.
When an OB is started, the process image output (PIQ) is outputted and the
process image input (PII) is updated before the processing of the code is starting.
The other way is to read the signals via the address range of the peripherals.
In this case, the module data is loaded and processed when the block or a function
is called. Just as with the inputs, the outputs can also be directly written via the
peripherals.
The advantage of peripheral addresses is that changes can also be processed
after the process image has been read.
Figure 11 shows the execution of an OB. It illustrates the writing of the outputs
(PIQ) and reading of the inputs into the PII at the start of the cycle. After this the
program code is edited for example by a function block (FB).
Siemens AG 2013 All rights reserved

If an input signal changes during program processing, this change is not applied
to the process image. For the called FB (Figure 11), this means that the block is
processed using the values from the process image.
If you use a peripheral address for the input, the input is read by the call of the FB,
and the function block will have the current value.

Figure 11: Signal processing in an OB cycle


Copyright

In tasks with very frequently edges, it is possible the edges get lost as a result of
an exceedingly long OB processing time.
In the case that a positive and a negative edge occurs during processing, this
fluctuation is very difficult to record even when using peripheral inputs. The AS has
to read the input whenever the signal changes.
The following figure illustrates how a changing input signal provides the same
measurement result every time the input is read.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 4
1 Task

Figure 12: Reading the input signal

The challenge is to find a solution that provides an undistorted result of


a measurement. This means that every edge must be registered by the AS while
counting, for example, beverage crates do not contain one bottle too many or too
few.

1.2 Solution
One possibility for the measurement of signals is the use of the SIMATIC FM 350-2
counter module. With its integration you can realize the following tasks for process
automation:
Siemens AG 2013 All rights reserved

Measurement of flow quantity


Measurement of rotational speed

Typical tasks for counter modules are:


Continuous counting up/down
Single counting up/down
Copyright

Periodic counting up/down


Frequency measurement
Rotational speed measurement
Time period measurement
Dosing
You can start and stop the count process either via the user program (software)
or via external signals (hardware). Count, gate and direction signals can be
connected directly to the counter module.

Advantages of the counter module


The counter module can measure signals independent of the CPU.
All edges up to 20 kHz are reliably detected.
The current counter values can be read out by the automation system at any
time.
The independent configuration of up to eight channels is possible.
The current counter reading can be compared to a value within the module. In
the case of true comparison, the counter module output is activated.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 5
1 Task

Delimitation
The following components of the FM 350-2 counter module and the accompanying
driver are not covered in this application:
Dosing counter
Triggering hardware interrupts
Rotary encoder
Substitute values

Note Additional project-specific information can be found in the "SIMATIC S7-300 FM


350-2 Counter Module" manual.
The link to the entry in the Industry Online Support is as follows:
http://support.automation.siemens.com/WW/view/en/1105178

1.3 Hardware and software components


1.3.1 Validity
Siemens AG 2013 All rights reserved

This application applies to:


SIMATIC PCS 7 V8.0 SP1
SIMATIC FM 350-2 firmware version V6.0 and higher

1.3.2 Components used

The application has been created with the following components:


Copyright

Hardware components
Table 11: Hardware components used
Component No. Order no. Note
FM 350-2 1 6ES7 350-2AH00-0AE0 Alternatively, newer versions
of the module can be used.
CPU 417-4 H with 1 6ES7 417-4HT14-0AB0 The CPU was not used
CP 443-1 6GK7 443-1EX20-0XE0 redundantly, but rather as an
individual automation station
for the test environment.
ET 200M 1 6ES7 153-2BA01-0XB0 Test environment component

DO8xDC24V/2A 2 6ES7 322-1BF01-0AA0 Test environment component

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 6
1 Task

Software components
Table 12: Software components used
Component No. Order no. Note
SIMATIC PCS 7 1 6ES7658-5AX08-0YA5 V8.0 SP1
V8.0
FM Configuration 1 - The configuration interface is
Package supplied with the counter
module or can be found in the
following entry:
http://support.automation.si
emens.com/WW/view/en/6
0237759
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 7
2 Basic principles of the counter module

2 Basic principles of the counter module


This chapter contains the essential information on the counter module.

Note Further information about the FM 350-2 counter module can be found in the
"S7-300 Counter Module FM 350-2" manual.
The link to the entry in the Industry Online Support is as follows:
http://support.automation.siemens.com/WW/view/en/1105178

2.1 Hardware information


Each of the counter module's eight channels has three digital inputs and one digital
output.
The counter module's signal inputs are labeled with the letter A, the direction input
with the letter B, the hardware gate with the letter I and the output with the letter Q.
The number after the letter indicates the channel to which the connection is
assigned. For example, B5 is the direction input of the counter module's 5th
channel.
Siemens AG 2013 All rights reserved

The inputs for direction, hardware gate and output are optional and do not need to
be connected.

Figure 21: Hardware scheme of the counter module


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 8
2 Basic principles of the counter module

2.2 "Pcs7Cnt1" driver block


The "Pcs7Cnt1" driver block (FB1833) is the interface between SIMATIC PCS 7
and the FM 350-2 counter module. You will need this block for each channel that
you wish to use.
In Figure 22 below, you can see the driver block with labels for the most important
inputs and outputs.

Figure 22: "Pcs7Cnt1" FB1833


User-defined name

Counter channel
data connection

Feedback for
Software gate module channel
state
Load value

Comparison value

Input for load Output counter


command value
Siemens AG 2013 All rights reserved

Output measured
value

Connection
to upstream
diagnostic block
Copyright

NOTICE If you do not assign the Connect input, the compiler of the CFC editor generates
an error.

In order to compile and load your project, you must assign this input.
The configuration instructions for this can be found in chapter 3.5.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 9
2 Basic principles of the counter module

2.3 Gate function of the counter channels Activating,


interrupting and canceling a channel
2.3.1 Overview

In order to activate the function of a counter module channel, the internal gate must
be set. The internal gate consists of a software gate and a hardware gate that are
connected by a logical AND. The software gate is an interface of the "Pcs7Cnt1"
driver block, and the hardware gate is a digital input on the module.
The hardware gate is deactivated in the basic setting and can be separately
activated for each channel in the hardware configuration.
The software gate does not have a deactivation function similar to the one
available for the hardware gate.

Figure 23: Digital logic with function table for the gate function
Siemens AG 2013 All rights reserved
Copyright

Note The configuration instructions for activating the hardware gate can be found in
chapter 3.6.4.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 10
2 Basic principles of the counter module

2.3.2 Interrupting and canceling a counting mode

The operating modes for counting are: continuous, single and periodic counting.
These modes are active as long as the internal gate setting is TRUE. By default,
the counting modes are canceled when the internal gate is set to FALSE.
When the gate is set to FALSE, the function of the channel is canceled by default.
Canceled means that the value currently being counted is overwritten by the start
value when the channel is re-activated. The default start value is 0.
It is possible to set the properties to interrupt instead of cancel in the configuration
interface. This only applies to the counting functions.
If the setting is configured to interrupt, then counting will continue from the existing
value in the counter when a reactivation occurs.

Table 21: Overview of counter behavior when the internal gate is set and the hardware
gate has not been activated in the configuration.
Configuration SW gate Internal Behavior
gate
The start value is loaded. Counting begins
Canceling
Set to from this value.
Siemens AG 2013 All rights reserved

TRUE
Interrupting Counting continues from the current count.

= positive edge

If you wish to also use the hardware gate, there is an anomaly in the canceling
behavior of the counter channel. Here, the current count is only overwritten
if a positive edge causes the internal gate to be set at the hardware gate.
Copyright

Table 22: Overview of counter behavior when the internal gate is set. The hardware gate
has been activated in the configuration.
Configuration SW gate HW gate Internal Behavior
gate
Counting continues from
1 the current count.
Canceling
The start value is loaded.
1 Counting begins from this value.
Set to
TRUE
1
Counting continues from
Interrupting
the current count.
1

- positive edge

Note A description of the configuration can be found in chapter 3.6.4.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 11
2 Basic principles of the counter module

2.3.3 Interrupting a measuring mode

The operating modes for measuring are: frequency, rotational speed and time
period measurement.
A measurement is activated as long as the internal gate is active. When the
internal gate is set to FALSE, the channel is deactivated. The driver block's
measurement output provides the old measured value until the next activation
of the channel.
Here, the selection of interrupt or cancel is not possible.

Note In the first measuring cycle, the measured value output is "-1". The reason for
this feature is so that the first measuring cycle can be differentiated from the real
system values that are either "0" or greater.
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 12
2 Basic principles of the counter module

2.4 Counting rages of the module channels


Channels 0-3
Channels 0-3 are read via the process image input of the called OB.
The counting range of these channels can be changed in the HW configuration
of the counter module.

Note The instructions for the configuration can be found in chapter 3.6.9

In the default setting, all four channels are assigned to a WORD data area.
It is possible to combine two channels that have a WORD data format in one
DWORD channel. This configuration option is available for channels 0 and 2.
For example, if you assign channel 0 to a DWORD data area, you can no longer
use channel 1. The reason for this is that channel 0 blocks the process image data
area that was reserved for channel 1. The same thing applies to channel 2 with
respect to channel 3.

Table 23: Possible configurations of channels 0-3


WORD only Mixed configurations DWORD only
Siemens AG 2013 All rights reserved

Channel 0 Channel 0 Channel 0 Channel 0


Channel 1 Channel 1
Channel 2 Channel 2 Channel 2 Channel 2
Channel 3 Channel 3

Note Counting range in WORD (16-bit) and DWORD (32-bit)


Copyright

WORD = -32,768 to 32,767


DWORD = -2,147,483,648 to 2,147,483,647

Channels 4-7
Channels 4-7 are read via the peripheral input words and counted in the DWORD
area.
Here, configurations of the counter range similar to those for channels 0-3 are not
possible.

Note DWORD (32-bit) counting range


DWORD = -2,147,483,648 to 2,147,483,647

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 13
2 Basic principles of the counter module

2.5 Operating modes for the channels


2.5.1 Introduction to counting

In the sections below, the following counting functions are explained in greater
detail:
Continuous counting
Single count
Periodic counting
Each time a positive edge is registered by the counter module, the module
increases the value by a count of one. If the count direction "down" is selected,
it decreases the value by one.
Below you can see a diagram with the input signal and the counter reading.
This is an example intended to illustrate that irregular signals can also be present.
In the following chapters, the count will be portrayed using regular signals.

Figure 24: Behavior of the counter reading in relation to the input signal
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 14
2 Basic principles of the counter module

2.5.2 Continuous counting

In this mode, the FM 350-2 counter module counts continuously starting at the
current counter reading. The default start value is 0. The start value can be
changed by loading a value.
If the counter reaches the high count limit when counting up and another count
pulse is received, it jumps to the low count limit and continues to count from
there without any pulse losses.
If the counter reaches the low count limit and another count pulse is received,
it jumps to the high count limit and continues to count from there without any
pulse losses.

Figure 25: Time diagram for continuous counting, up and down


Siemens AG 2013 All rights reserved
Copyright

Note The configuration instructions for continuous counting can be found in


chapter 3.6.1, and the instructions for loading values are in chapter 3.6.7.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 15
2 Basic principles of the counter module

2.5.3 Single Counting

In this mode, the counter module performs the following counts once when the
internal gate is activated:
Between 0 and the assigned end value in the main count direction "up."
Between the assigned start value and 0 in the main count direction "down."
Once the count process has been completed, it is only repeated when the internal
gate is set again.

Figure 26: Time diagram for single counting, backward and forward
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 16
2 Basic principles of the counter module

2.5.4 Periodic counting

In this mode, the counter module performs the following counts:


From the start value 0 to the (end value 1) in the main count direction "up."
From the assigned start value to the end value (0 + 1) in the main count
direction "down."
If one of the assigned count limits is reached, the counter jumps back to the start
value when the next pulse is received. The counter channel continues to count
from there. For example, if you have assigned the value 100 as an end value for
counting up, the counter module counts to 99 and then jumps to the value 0 when
the next edge occurs.

Figure 27: Time diagram for periodic counting, up and down


Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 17
2 Basic principles of the counter module

2.5.5 Frequency measurement

In this mode, the FM 350-2 counter module counts the pulses received within
a predetermined time window. This is then used to calculate the frequency.
It is important to note that the calculated value is only available and able to be
output after the first measuring cycle. During the first time window, the output is -1.
The reason for this feature is so that the first measuring cycle can be differentiated
from the real system values that are either "0" or greater.
The measured value is output in mHz at the driver block.

Figure 28: Time diagram for frequency measurement


Siemens AG 2013 All rights reserved
Copyright

2.5.6 Rotational speed measurement

In this mode, which is virtually identical to the "frequency measurement" mode,


the FM 350-2 counts the pulses received from a signal transmitter within
a predetermined time window and uses this to calculate the rotational speed.
Here, the measured value from the first cycle is once again only available in
the second time window.
The rotational speed is output in 10-3 min-1 at the driver block.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 18
2 Basic principles of the counter module

2.5.7 Time period measurement

In this mode, the counter module measures the exact time between two positive
edges of the count signal by counting pulses of an internal reference frequency
(1 MHz) with quartz accuracy. The measured value is only written to the output
after the assigned time in the second cycle of the time window.
The driver block outputs the measured value in ms.

Figure 29: Time diagram for time period measurement


Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 19
3 Configuration

3 Configuration
3.1 Requirements for configuring the counter module
Overview
In order to configure the FM 350-2 counter module in the SIMATIC Manager, you
must install a configuration package. This package is provided with the counter
module and can be downloaded from the Industry Online Support Portal.
The link to the entry in the Industry Online Support Portal is as follows:
http://support.automation.siemens.com/WW/view/en/1105178.

Installing the configuration package


1. Start the self-extracting archive by double-clicking the configuration package.

Figure 3-1: Self-extracting configuration package


Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 20
3 Configuration

2. Select the destination file at the dialog window.


3. Start the file extraction by clicking on the "Unzip" button.
Once the extraction has been successfully completed, the "WinZip Self-
Extractor" dialog window opens.

Figure 3-2: Extracting the installation files

4. Click the "OK" button.


Siemens AG 2013 All rights reserved

Close the dialog window for the file extraction by clicking on the "Close" button.

Figure 3-3: Dialog window following successful extraction


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 21
3 Configuration

5. Launch the setup.exe file by double-clicking it in the destination folder.

Figure 3-4: Setup.exe after extraction of the configuration package


Siemens AG 2013 All rights reserved

6. Select the setup language and then click the "Next >" button.

Figure 3-5
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 22
3 Configuration

7. Read the installation instructions and then click the "Next >" button.

Figure 3-6
Siemens AG 2013 All rights reserved

8. Read the product notes in the readme file and click the "Next >" button.

Figure 3-7: Product information


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 23
3 Configuration

9. Read the license agreement. If you agree to the conditions, select the check
box and click the "Next >" button.

Figure 3-8: License agreement


Siemens AG 2013 All rights reserved

10. Select the check box for the FM 350-2 counter module from the list and then
click the "Next >" button.
Installation begins.
Copyright

Figure 3-9: Selection of modules for installation

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 24
3 Configuration

1. Once the installation has been successfully completed, click the "Finish"
button.

Figure 310: Successfully completing installation


Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 25
3 Configuration

3.2 Configuring the counter module in HW Config


Requirements
SIMATIC PCS 7 project
Your hardware is configured outside of the FM 350-2 counter module.

Procedure

Note The hardware pictured below may differ from your own.

1. Open the SIMATIC Manager.


2. Open your PCS 7 project/multiproject

Figure 311: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 26
3 Configuration

4. Select the ET 200M into which the counter module is to be integrated.

Figure 312: HW Config Selected interface module (IM)


Siemens AG 2013 All rights reserved

5. In the "PCS7_V80" profile of the hardware catalog, search for the FM 350-2
counter module.
6. Drag the FM 350-2 counter module from the catalog to the next free slot of the
ET 200M.

Figure 3-13 Counter module in the HW Config


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 27
3 Configuration

7. Open the module configuration window by double-clicking the FM 350-2


counter module. When you first open the configuration window, the "Specify
Channels" menu interface is displayed. Keep the default settings and click on
the "OK" button.

Figure 314: Channel specification for the FM 350-2 counter module


Siemens AG 2013 All rights reserved
Copyright

Note If the following window is displayed when you open the configuration interface for
the FM 350-2 counter module, click the "OK" button:

When you click the "OK" button, the configuration is saved and the configuration
interface opens.
If you click "Cancel," the interface does not open.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 28
3 Configuration

8. Save the default settings and close the window.

Figure 315: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

9. Save and compile your hardware configuration.


10. Load your configuration to your automation system.
Copyright

Figure 316: HW Config

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 29
3 Configuration

3.3 Creating data areas in the symbol table


Requirements
Hardware has been successfully configured.
Your modules do not have any errors after the hardware configuration is
loaded.

Addressing channels
The channels in the process image are addressed as described in the online help
for the "Pcs7Cnt1" driver block (FB1833). In the following example, the start
address 512 is used.

Note The start address can be found in the HW configuration.


Siemens AG 2013 All rights reserved
Copyright

It is the first address displayed in the input range.

Channels in the process image:


Channel 0: Start address + 8 bytes = EW 520
Channel 1: Start address + 10 bytes = EW 522
Channel 2: Start address + 12 bytes = EW 524
Channel 3: Start address + 14 bytes = EW 526

Note You can find information on the use of DWORD data formats in chapter 3.6.9.

Channels outside of the process image:


Channel 4: Start address + 4 bytes = EW 516
Channel 5: Start address + 5 bytes = EW 517
Channel 6: Start address + 6 bytes = EW 518
Channel 7: Start address + 7 bytes = EW 519

The following applies for the addressing of these channels (4-7): start address of
the counter module + channel number.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 30
3 Configuration

Procedure
2. Open the component view of your project.
3. Select the S7 program of your automation system.

Figure 317: Symbol table in the component view

4. Open the symbol table by double-clicking on the icon.


Siemens AG 2013 All rights reserved

5. Enter the channel addresses in the symbol table.

Note The contents of your symbol table may be different from the contents pictured.

Figure 318: Changes in the symbol table


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 31
3 Configuration

6. Save the symbol table and close the symbol editor.

Figure 319: Symbol Editor


Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 32
3 Configuration

3.4 Adding a driver block in the master data library


Requirements
You have a master data library.
"PCS 7 AP Library Vxx" is not used as the master data library.

Procedure
1. In the "File" menu, select the "Open" command.
The "Open Project" dialog box is displayed.
2. Open the "Libraries" tab.
3. Select the "PCS 7 AP Library V80" library and your master data library from the
list.

Figure 320: Library selection


Siemens AG 2013 All rights reserved
Copyright

4. Click the "OK" button. The libraries are opened in the component view.
5. In the tree view, select the entry labeled "PCS 7 AP Library V80\Blocks +
Templates\Blocks".

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 33
3 Configuration

6. In the menu bar, select the "View" menu and the "Details" menu command.

Figure 321
Siemens AG 2013 All rights reserved

7. Select the "Pcs7Cnt1" driver block (FB 1833) and "SelST16" (FC 369).
8. Open the context menu by right clicking the selection and select the "Copy"
menu command.

Figure 322: Detailed view of the APL V8.0


Copyright

9. In your master data library, switch to the folder labeled "S7 program(1)/Blocks".
10. Open the context menu by right clicking the selection and select the "Paste"
menu command.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 34
3 Configuration

3.5 Connecting a channel data area to the driver block


Requirements
Hardware has been successfully configured.
Addresses have been entered in the symbol table.
The driver block is in the master data library.

Procedure
1. Open the technology view of your project.
2. Optional: Generate your CFC chart for the driver block if it does not already
exist.
3. Open the CFC chart in which the driver block is to be used.
4. In the catalog, switch to the "Libraries" tab.
5. In the navigation pane, open the "S7 Program (1)/Blocks/Channel" folder in
your project library.
6. Drag the "Pcs7Cnt1" driver block to the desired location in the CFC chart.
Siemens AG 2013 All rights reserved

Figure 323: CFC editor Adding the driver block


Copyright

Note In the default setting, OB30 through OB38 are recommended for the use of the
"Pcs7Cnt1" driver block.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 35
3 Configuration

7. Open the context menu by right-clicking the "Connect" terminal and select the
"Interconnection to Address..."

Figure 324: CFC editor Interconnection to address


Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 36
3 Configuration

8. Select the data area of the channel you wish to interconnect with the driver
block.

Figure 325: Selecting the addresses


Siemens AG 2013 All rights reserved

Figure 326: Input word connected to the driver block


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 37
3 Configuration

9. Compile your CFC chart. If the connection was successful, you will not receive
any error messages and additional interconnections will be created as pictured
below.

Figure 327: Successful compilation of the driver block


Siemens AG 2013 All rights reserved

Note If the new interconnections are not immediately displayed, refresh the CFC chart
using the "F5" button.
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 38
3 Configuration

Note If you receive an error message stating that the FM_DATA connection cannot be
interconnected by your driver block, check your data area again and save and
compile your hardware settings for the FM 350-2 counter module.
Siemens AG 2013 All rights reserved

10. Once the compilation has been successfully completed, load the CFC chart to
Copyright

your automation system.

Figure 328: CFC editor Compiling and loading

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 39
3 Configuration

3.6 Configuring the counter module channels


The following nine chapters are comprised of selectable modular configurations for
the individual channels of the FM 350-2 counter module.

3.6.1 Continuous counting

Requirements
The FM 350-2 counter module has been added in the HW Config.
The driver block is connected to a channel.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 3-29: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 40
3 Configuration

5. Select the channel you wish to configure for continuous counting.


6. Open the "Operating Mode" menu by double-clicking the center button.

Figure 3-30: Configuration interface for the counter module Channel selection
Siemens AG 2013 All rights reserved

7. Select the "Continuous Counting" operating mode.


8. Click the "OK" button to close the window.
Copyright

Figure 3-31: Configuration interface for operating modes

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 41
3 Configuration

9. Save the changes to the configuration of the FM 350-2 counter module


and close the window.

Figure 3-32: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

10. Save and compile the HW Config.


Copyright

Figure 3-33: HW Config

11. Close the HW Config.


12. Open the CFC chart with the driver block.
13. Set the SwGateEn input to TRUE to activate the channel.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 42
3 Configuration

Figure 3-34: "Pcs7Cnt1" driver block


Siemens AG 2013 All rights reserved

NOTICE In order to use the gate function, both the software gate (channel driver)
and the hardware gate (digital input of the module) must be activated.
Copyright

Result
You have configured an FM 350-2 counter module channel for continuous
counting. The signals at the counter module will be processed in the channel.
You can monitor the counter reading on the driver module at the PV1 output.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 43
3 Configuration

3.6.2 Single/Periodic counting

Requirements
The FM 350-2 counter module has been added in the HW Config.
The driver block is connected to a channel.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 335: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 44
3 Configuration

5. Select the channel you wish to configure.


6. Open the "Operating Mode" menu by double-clicking the center button.

Figure 336: Configuration interface for the FM 350-2 counter module


Siemens AG 2013 All rights reserved

7. Select "Single Counting" or "Periodic Counting."


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 45
3 Configuration

8. The text box for the start and end value is now enabled and ready for
parameter assignment. The default value is the high count limit.

Figure 337: Configuration interface for operating modes


Siemens AG 2013 All rights reserved

Note When you assign the main count direction "up, the start value is 0 and you
define the end value.
Copyright

When you assign the main count direction "down, you define the start value and
the end value is 0.

9. Click the "OK" button to close the window.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 46
3 Configuration

10. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 338: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

11. Save and compile the HW Config.


Copyright

12. Load your configuration to your automation system.

Figure 339: HW Config

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 47
3 Configuration

13. Close the HW Config.


14. Open the CFC chart with the driver block.
15. Set the SwGateEn input to TRUE to activate the channel.

Figure 340: "Pcs7Cnt1" driver block


Siemens AG 2013 All rights reserved
Copyright

NOTICE In order to use the gate function, both the software gate (channel driver)
and the hardware gate (digital input of the module) must be activated.

Result
The FM 350-2 channel is configured for single or periodic counting. The function's
start/end value has been assigned. The count value can be read out via the PV1
output.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 48
3 Configuration

3.6.3 Measurements

Requirements
The FM 350-2 counter module has been added in the HW Config.
The driver block is connected to a channel.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 341: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 49
3 Configuration

5. Select the channel you wish to configure.


6. Open the "Operating Mode" menu by double-clicking the center button.

Figure 342: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

7. Select one of the channel's three measurement functions.


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 50
3 Configuration

8. The text box for the signal sampling time becomes active and can be
configured.

Figure 343: Configuration interface for operating modes


Siemens AG 2013 All rights reserved

Note Note that the first measured value is only calculated after the sampling time has
passed. In the first measuring cycle,the measured value output is "-1".
Copyright

9. Click the "OK" button to close the window.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 51
3 Configuration

10. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 344: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

11. Save and compile the HW Config.


Copyright

12. Load your configuration to your automation system.

Figure 345: HW Config

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 52
3 Configuration

13. Close the HW Config.


14. Open the CFC chart with the driver block.
15. Set the SwGateEn input to TRUE to activate the channel.

Figure 346: "Pcs7Cnt1" driver block


Siemens AG 2013 All rights reserved
Copyright

NOTICE In order to use the gate function, both the software gate (channel driver)
and the hardware gate (digital input of the module) must be activated.

Result
You have configured a channel with a measurement function. You can read off
the counted input signals at the PV1 output on the driver block. The PV2 output
provides the measured value.

Note Units for the PV2 output:


Frequency measurement = mHz
Rotational speed measurement = 10-3 min-1
Time period measurement = ms

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 53
3 Configuration

3.6.4 Hardware gate

Requirements
The FM 350-2 counter module has been added in the HW Config.
The driver block is connected to a channel.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 347: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the counter module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 54
3 Configuration

5. Select the channel you wish to configure.


6. Open the "Operating Mode" menu by double-clicking the center button.

Figure 348: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

7. Select the "Use Hardware Gate" check box.


Copyright

Figure 349: Configuration interface for operating modes

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 55
3 Configuration

8. Click the "OK" button to close the window.


9. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 350: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

10. Save and compile the HW Config.


Copyright

11. Load your configuration to your automation system.

Figure 351: HW Config

12. Close the HW Config.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 56
3 Configuration

Result
You have activated the channel's hardware gate. Now, the channel will only be
activated if the software and hardware gates are active.
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 57
3 Configuration

3.6.5 Canceling or interrupting the counting function

Requirements
The FM 350-2 counter module has been added in the HW Config.
The driver block is connected to a channel.
You have configured one of the counting functions on the channel.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 352: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 58
3 Configuration

5. Select the channel you wish to configure.


6. Open the "Operating Mode" menu by double-clicking the center button.

Figure 353: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

7. Select interrupt or cancel for a reset of the internal gate.

Figure 354: Configuration interface for operating modes


Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 59
3 Configuration

8. Click the "OK" button to close the window.


9. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 355: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

10. Save and compile the HW Config.


Copyright

11. Load your configuration to your automation system.

Figure 356: HW Config

12. Close the HW Config.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 60
3 Configuration

Result
You have configured the behavior of the counter channel. When the internal gate
is set again, the current value will continue to be used or the start value will be
reloaded, depending on your configuration.

Note An overview of the behavior of the counter module channels can be found in
chapter 2.3.2.
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 61
3 Configuration

3.6.6 Count direction

Introduction
For each channel, the FM 350-2 counter module has a digital input that determines
the count direction. The channel counts down for TRUE and up for FALSE.
Not connecting this input is equivalent to a FALSE signal, and the FM 350-2
counter module will count up. In this chapter, you will find the configuration
instructions for inverting this input.

Note The "Pcs7Cnt1" driver block does not have an input at which you can can
change the count direction.

Requirements
The counter module has been added in the HW Config.
The driver block is connected to a channel.
You have configured one of the counting functions on the channel.
Siemens AG 2013 All rights reserved

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 357: SIMATIC Manager


Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 62
3 Configuration

5. Select the channel you wish to configure.


6. Open the "Encoders" menu by double-clicking top left button.

Figure 358: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

7. Select the "Inverted Direction" check box.


Copyright

Figure 359: Configuration interface for encoders

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 63
3 Configuration

8. Click the "OK" button to close the window.


9. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 360: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

10. Save and compile the HW Config.


Copyright

11. Load your configuration to your automation system.

Figure 361: HW Config

12. Close the HW Config.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 64
3 Configuration

Result
You have negated the channel's direction input. The channel counts down for
FALSE and up for TRUE.
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 65
3 Configuration

3.6.7 Loading values

Requirements
The counter module has been added in the HW Config.
The driver block is connected to a channel.
You have configured one of the counting functions on the channel.

Note If one of the three measurement modes has been configured, then it is not
possible to load values.

Procedure
1. Open the CFC chart with the "Pcs7Cnt1" driver block.
2. Enter the desired value at the "LoadPV1_" input.

Note If the value exceeds the assigned counter limit, then the value is changed to the
negative or positive value.
Siemens AG 2013 All rights reserved

An overview of the channel counter limits can be found in chapter 2.4.

Figure 362: "Pcs7Cnt1" driver block


Copyright

3. When a positive edge is received at the "LoadDir" connection, the entered


value is used as the current counter reading.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 66
3 Configuration

Result
You have entered your load value at the corresponding input. Whenever you
send a positive edge to the "LoadDir" input, the current counter reading will be
overwritten by the load value. Counting resumes starting at this value in your
counter channel configuration.
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 67
3 Configuration

3.6.8 Comparing the counter reading with a value

Requirements
The counter module has been added in the HW Config.
The driver block is connected to a channel.
You have configured one of the counting functions on the channel.

Note If one of the three measurement modes has been configured, then it is not
possible to load values.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 363: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 68
3 Configuration

5. Select the channel you wish to configure.


6. Open the "Outputs" menu by double-clicking the bottom right button.

Figure 364: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved

7. Select the comparison type.


Copyright

Figure 365: Configuration interface Outputs

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 69
3 Configuration

8. Click the "OK" button to close the window.


9. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 366: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved
Copyright

10. Save and compile the HW Config.


11. Load your configuration to your automation system.

Figure 367: HW Config

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 70
3 Configuration

12. Close the HW Config.


13. Open the CFC chart with the "Pcs7Cnt1" driver block.
14. Enter a comparison value at the "CmpV0" input.

Figure 368: "Pcs7Cnt1" driver block


Siemens AG 2013 All rights reserved
Copyright

Result
You have assigned the comparison parameter for the channel's output. The output
provides a TRUE if the comparison is true. Otherwise, the output provides
a FALSE. You can monitor this on the driver block at the "CmpVal0" output.

Note If you haven not assigned a comparison parameter for the output, the output will
be permanently set to TRUE.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 71
3 Configuration

3.6.9 Extending the counter limits

Note This chapter refers to the extension of the counting range of channel 0 and
channel 2. For more information, please see chapter 2.4 of this document.

Requirements
The counter module has been added in the HW Config.
For the counter limit extension of channel 0, channel 1 must be unassigned.
For the counter limit extension of channel 2, channel 3 must be unassigned.

Procedure
1. Open the SIMATIC Manager.
2. Open your PCS 7 project/multiproject

Figure 369: SIMATIC Manager


Siemens AG 2013 All rights reserved
Copyright

3. Open the hardware configuration for your automation system.


4. Open the configuration interface by double-clicking the FM 350-2 counter
module.

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 72
3 Configuration

5. Open the following menu: "Edit > Specify Channels..."

Figure 3-70: HW Config "Edit" menu


Siemens AG 2013 All rights reserved

6. If you wish to extend the counting range for channel 0, set "User_Type1" to
DWord. For channel 2, set "User_Type2" to DWord.

Figure 3-71: Specifying channels DWord for "User_Type2" with a blocked


channel 3.
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 73
3 Configuration

7. Click the "OK" button to close the window.


8. Save the changes to the configuration of the FM 350-2 counter module
and close the window.

Figure 3-72: Configuration interface for the 350-2 counter module


Siemens AG 2013 All rights reserved
Copyright

9. Save and compile the HW Config.


10. Load your configuration to your automation system.

Figure 3-73: HW Config

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 74
3 Configuration

11. Close the HW Config.


12. Open the component view of your project.
13. Select the S7 program of your automation system in the project navigation
pane.

Figure 3-74: Symbol table in the component view

14. Open the symbol table by double-clicking on the icon.


Siemens AG 2013 All rights reserved

15. Change the input words (EW) of the channels on which you extended the
counting range into input double word (ED). Accordingly, delete the EW of the
blocked channel, e. . if you have extended the counting range of channel 0
(EW520). Change EW520 to ED520 and delete EW522.
16. Save the symbol table and close the symbol editor.
17. Open the CFC chart with the driver block.
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 75
3 Configuration

18. Left-click the "Connect" input and select the "Interconnection to Address..."
menu command.

Figure 3-75: CFC editor Interconnection to address


Siemens AG 2013 All rights reserved

19. Select the changed address from the list in accordance with the channel.
20. Compile your CFC chart.
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 76
3 Configuration

Note If you do not delete the necessary EW, or if it is still interconnected with
a channel driver, then the CFC compiler will generate an error during
compilation.
Siemens AG 2013 All rights reserved
Copyright

21. Once the compilation has been successfully completed, load the CFC chart to
your automation system.

Figure 3-76: CFC editor Compiling and loading

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 77
3 Configuration

Result
You have switched the counting range from Word to DWord. You have extended
the data area of the driver block in the symbol table. You have connected the new,
larger data area to the driver block. A larger data area is now available to the
channel for counting.
Siemens AG 2013 All rights reserved
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 78
4 Related literature

4 Related literature
Table 4-1
Subject area Title
\1\ Reference to the http://support.automation.siemens.com/WW/view/en/83146298
article
\2\ SIMATIC PCS 7 http://support.automation.siemens.com/WW/view/en/63481413
overview
(collection of links
for FAQ, manuals,
compendium,
forum, application
examples and
multimedia)
\3\ Manual http://support.automation.siemens.com/WW/view/en/1105178
FM 350-2 Counter
module
\4\ FM Configuration http://support.automation.siemens.com/WW/view/en/60237759
Package
Siemens AG 2013 All rights reserved

5 History
Table 5-1
Version Date Modifications
V1.0 12/2013 First edition
Copyright

Counter Module SIMATIC FM 350-2


V1.0, Item ID: 83146298 79

You might also like