You are on page 1of 16

SIMATIC S7-300 Getting Started - Commissioning a CPU 31xC: Counting

1 Introduction ______________ 2 Preparation ______________ 3 Learning units ______________ 4 Further Information ______________

SIMATIC S7-300 Getting Started - Commissioning a CPU 31xC: Counting


Getting Started

12/2006

A5E00105536-02

Safety Guidelines
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are graded according to the degree of danger. Danger indicates that death or severe personal injury will result if proper precautions are not taken. Warning indicates that death or severe personal injury may result if proper precautions are not taken. Caution with a safety alert symbol, indicates that minor personal injury can result if proper precautions are not taken. Caution without a safety alert symbol, indicates that property damage can result if proper precautions are not taken. Notice indicates that an unintended result or situation can occur if the corresponding information is not taken into account. If more than one degree of danger is present, the warning notice representing the highest degree of danger will be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property damage.

Qualified Personnel
The device/system may only be set up and used in conjunction with this documentation. Commissioning and operation of a device/system may only be performed by qualified personnel. Within the context of the safety notes in this documentation qualified persons are defined as persons who are authorized to commission, ground and label devices, systems and circuits in accordance with established safety practices and standards.

Prescribed Usage
Note the following: Warning This device 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. Correct, reliable operation of the product requires proper transport, storage, positioning and assembly as well as careful operation and maintenance.

Trademarks
All names identified by are registered trademarks of the Siemens AG. The remaining trademarks in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.

Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in this publication is reviewed regularly and any necessary corrections are included in subsequent editions.

Siemens AG Automation and Drives Postfach 48 48 90437 NRNBERG GERMANY

Order No.: A5E00105536-02 01/2007

Copyright Siemens AG 2006. Technical data subject to change

Table of contents
1 2 3 Introduction............................................................................................................................................. 1-1 Preparation ............................................................................................................................................. 2-1 Learning units ......................................................................................................................................... 3-1 3.1 3.2 3.3 3.4 3.5 4 4.1 1. Step: Wiring the power supply and CPU ............................................................................... 3-1 2. Step: Installing the sample project......................................................................................... 3-3 3. Step: Setting parameters ....................................................................................................... 3-4 4. Step: Linking to the user program.......................................................................................... 3-5 5. Step: Trial run ........................................................................................................................ 3-6 Further Information .................................................................................................................... 4-1

Further Information ................................................................................................................................. 4-1

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

iii

Table of contents

iv

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

Introduction
Contents of this Getting Started Manual

The sample in this Getting Started manual takes you through five steps, showing you how to commission a fully functional counter application. You are going to familiarize yourself with the basic hardware and software functions and learn how to operate the counting function. The references to the manual will also help you to get a general overview of the information it contains. Additional notes relating to the frequency-measurement and pulse-widthmodulation applications are found on the sample project CD. This process will take 1 to 2 hours, depending on your experience.

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

1-1

Introduction

1-2

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

Preparation
Scope
This guide applies to the following CPUs:
CPU 312C 313C 313C-2 PtP 313C-2 DP 314C-2 PtP 314C-2 DP Order no. 6ES7 312-5BE03-0AB0 6ES7 313-5BF03-0AB0 6ES7 313-6BF03-0AB0 6ES7 313-6CF03-0AB0 6ES7 314-6BG03-0AB0 6ES7 314-6CG03-0AB0 SIMATIC Micro Memory As of version Card required for operation? Firmware Yes Yes Yes Yes Yes Yes V2.0.12 V2.0.12 V2.0.12 V2.0.12 V2.0.12 V2.0.12

Prerequisites
You have an S7-300 station comprising a power supply module and a CPU 31xC. STEP 7 as of V5.2 + SP 2 is correctly installed on your PG. You have the CD with the sample projects or you have downloaded the sample projects from the Internet. You have set up a project for the S7-300 station. The PG is connected to the CPU. You are set up with all the required accessories, e.g., front connector and wiring material. The CPU is correctly connected to a power supply.

Warning Operation of an S7-300 in plants or systems is defined by special set of rules and regulations, based on the relevant field of application. Please observe the current safety regulations for the prevention of accidents, for example IEC 204 (EMERGENCY-OFF equipment). Non-compliance with these regulations can result in serious injury and damage to both machinery and equipment.

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

2-1

Preparation

Layout of the example


1 2 3 4

(1) (2) (3) (4) (5) (6) (7) (8)

For setting the line voltage Mode selector Mounting rail Programming device with STEP 7 software PG cable Connecting cable Clamp for strain relief Power supply ON/OFF

2-2

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

Learning units
3.1 1. Step: Wiring the power supply and CPU
Warning

You can come into contact with live wires if the PS 307 power supply module is turned on or the power supply cable to the PS is connected to the main power supply. Perform any wiring work on the S7-300 only when the power is off!

Procedure
1. Fit the front connector to the CPU and tighten the securing screws. 2. Wire the connections for the "Count 1 First Steps" sample project as follows:

Connector pin assignment


The pin assignments described below relate only to the connectors relevant for the positioning type.
CPU 312C connection: X1 2 3 4 8 12 13 16 17 18 19 20 Name/address DI+0.0 DI+0.1 DI+0.2 DI+0.6 2M 1 L+ DO+0.2 DO+0.3 DO+0.4 DO+0.5 1M Sample function Pulse input Direction bit Hardware gate Latch input Reference potential of the supply voltage 24 V DC supply voltage Simulation: Pulse input -> connect to DI+0.0 Simulation: Direction bit -> connect to DI+0.1 Simulation: Hardware gate -> connect to DI+0.2 Simulation: Latch input -> connect to DI+0.6 Reference potential of the supply voltage

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

3-1

Learning units 3.1 1. Step: Wiring the power supply and CPU
Pin CPU 313C-2 DP/PtP: X1 CPU 313C, 314C-2 DP/PtP: X2 1 2 3 4 16 20 21 24 25 26 27 30 Name/address Function

1 L+ DI+0.0 DI+0.1 DI+0.2 DI+1.4 1M 2 L+ DO+0.2 DO+0.3 DO+0.4 DO+0.5 2M

24 V power supply of the inputs Pulse input Direction bit Hardware gate Latch input Reference potential of the supply voltage 24 V power supply of the outputs Simulation: Pulse input -> connect to DI+0.0 Simulation: Direction bit -> connect to DI+0.1 Simulation: Hardware gate -> connect to DI+0.2 Simulation: Latch input -> connect to DI+1.4 Reference potential of the supply voltage

The figure shows, as an example, the CPU 314C with a standard plug arrangement for CPUs with two connectors (X1 and X2).

RUN STOP MRES

L+ M

Reference
You will find information on the remaining connectors in the documentation of the S7-300.

3-2

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

Learning units 3.2 2. Step: Installing the sample project

3.2

2. Step: Installing the sample project

Introduction
When installing the sample project, you have the following options:

Installing from CD
1. Start the installation program on the CD by double-clicking on the SETUP.EXE file in the SETUP folder. The installation program is started. 2. Now follow the instructions in the installation program.

Installing from the Internet


1. Open the directory with the sample projects and start the installation program by doubleclicking on the SETUP.EXE file. The installation program is started. 2. Now follow the instructions in the installation program.

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

3-3

Learning units 3.3 3 . Step: Setting parameters

3.3
Procedure

3. Step: Setting parameters

1. Open your project in SIMATIC Manager. A window, divided into two parts, opens with the title of your project. 2. In your project, call the configuration table HW Config.

3. Double-click on the submodule "Counting". The "Counting properties" dialog opens. 4. Select channel 0 and "Infinite count" mode. Make the following settings in the parameter assignment screen forms (do not modify any other settings, as they are not required for commissioning): Input: Hardware gate Output reaction: Counter value Comparison value 5. Confirm your settings with "OK". The "Counting properties" dialog closes. 6. Save your configuration to your project with "Station > Save and compile". Your changes are now stored in your project. 7. When the CPU is in STOP, select "PLC > Load to module..." to download the configuration. The data are now downloaded from the PG to the CPU. 8. Close HW Config with "Station > Close". You are returned to SIMATIC Manager.

3-4

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

Learning units 3.4 4. Step: Linking to the user program

3.4
Procedure

4. Step: Linking to the user program

1. Open the project "ZEn26_02_TF_____31xC_Cnt" in the catalog \Siemens\STEP7\Examples via "File > Open... > Sample projects" in SIMATIC Manager. A two-part window opens showing the title of the project. 2. Double-click on the S7 program "Count 1 First Steps". In the right-hand window, you can see the "Sources", "Blocks" and "Symbols" folders. 3. Double-click on the "Blocks" container. This displays all the blocks of the S7 program. 4. Copy all the blocks from this folder to your project in "SIMATIC 300 Station > CPU3xx > S7 Program > Blocks".
Chip OB1 FB11 DB11 SFB47 DB16 VAT Name (in the toolbar) CYCLE_EXC GETST_C DI_GETST_C COUNT DI_COUNT VAT_GETST_C Description Cyclic program Example 1: COUNT, first steps Instance DB for GETST_C SFB COUNT Instance DB for SFB COUNT Variable table

1. Copy the symbol table to your project in "SIMATIC 300 Station > CPU3xx > S7 Program". The symbol table is stored in your project. 2. In SIMATIC Manager, select "SIMATIC 300 Station > CPU3xx > S7 Program > Function blocks". This displays all the blocks of the S7 program. 3. Download all of the S7 blocks it contains to your CPU via "PLC > Download" (CPU in STOP mode). The program and configuration are downloaded from the PG to the CPU.

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

3-5

Learning units 3.5 5 . Step: Trial run

3.5
Procedure

5. Step: Trial run

1. In the "Function blocks" directory, double-click on the variable table "VAT_GETST_C" in your project. The variable table for monitoring and modifying is displayed. 2. Go online with "PLC > Connect to > Configured CPU". At the bottom right, you will see that the CPU is set to "Stop" mode. 3. Activate monitoring with "Variable > Monitor". The current values of the addresses are displayed in the "Status Value" column. 4. Switch the CPU to RUN. At the bottom right, you will see that the CPU is set to "RUN" mode. 5. In the variable S_IMP_H of the VAT, select the count pulse source: S_IMP_H = 0: The pulse source is a programmed SW clock generator. Its frequency is adjustable via the T_PULSE variable. The clock is connected to the pulse input via a digital output. S_IMP_H = 1: Specify the count pulses by manually setting and resetting the S_IMP_T variable in the VAT. 6. You can perform the following tests:
Starting/stopping the counter: Start the counter by setting the variables SW_GATE (SFB parameter SW gate) and S_HWT (simulation of HW gate) in the VAT to 1 (logical AND). Stop the counter by resetting S_HWT or SW_GATE to zero. JOB_ID = 01 hex ("Write counter directly") JOB_VAL = Count value (-231 to +231-1) JOB_REQ = 1, Job initiates at the positive edge You can monitor the actual counter value at the SFB output parameter COUNTVAL. You can view the status of the SW or HW gate in the variables STS_GATE or STS_STRT.

Loading a count value to the counter: You can view the loaded count value at the SFB output parameter COUNTVAL. If no load error has occurred, the status at the output parameters is JOB_DONE = 1 and JOB_ERROR = 0.

3-6

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

Further Information
4.1 Further Information

Diagnostics/Correction of Errors
Incorrect operator input, faulty wiring or inconsistent configuration data may lead to errors. For information on how to analyze such errors and messages, refer to the S7-300 documentation.

Example:
The "ZEn26_02_TF_____31xC_Cnt" project contains further samples you can use for orientation. You can customize all samples according to your personal applications.

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

4-1

Further Information 4.1 Further Information

4-2

Getting Started - Commissioning a CPU 31xC: Counting Getting Started, 12/2006, A5E00105536-02

You might also like