plc counter instructions - edl€¦ · plc counter instructions are ... figure 1 shows the counter...

82
LEARNING ACTIVITY PACKET MECHATRONICS PLC COUNTER INSTRUCTIONS (SIEMENS S7-300/STEP 7) B25014-AA05UEN

Upload: trinhdat

Post on 29-Jul-2018

247 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

LEARNINGACTIVITYPACKETMECHATRONICS

PLC COUNTERINSTRUCTIONS(SIEMENS S7-300/STEP 7)

B25014-AA05UEN

Page 2: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

2

LEARNING ACTIVITY PACKET 5

PLC COUNTER INSTRUCTIONS

INTRODUCTIONThis LAP covers how to use counter instructions that are used in PLC applications.

Counters are important because they allow a PLC to keep track of production and other data as well as control functions that are based on counting.

ITEMS NEEDEDAmatrol Supplied 1 870-PS7313-AAU, 870-PS7314-AAU, or 870-PS7315-AAU Mechatronics Learning System-S7 1 87-IOSS7-AAX I/O Simulator Learning System 1 87-MS1 Pick and Place Feeding Station or 1 87-MS2 Gauging Station or 1 87-MS3 Orientation-Processing Station or 1 87-MS4 Sorting-Buffering Station or 1 87-MS5 Servo Robotic Assembly Station or 1 87-MS6 Torque Assembly Station or 1 87-MS7 Inventory Storage Station

Amatrol or School Supplied 1 82-900 Step 7 Programming Software 1 72024 PC Programming Interface for Siemens S7 PLCs

School Supplied 1 Computer 1 Printer

FIRST EDITION, LAP 5, REV. CAmatrol, AMNET, CIMSOFT, MCL, MINI-CIM, IST, ITC, VEST, and Technovate are trademarks or registered trademarks of Amatrol, Inc. All other brand and product names are trademarks or registered trademarks of their respective companies.Copyright © 2012, 2011 by AMATROL, INC.All rights Reserved. No part of this publication may be reproduced, translated, or transmitted in any form or by any means, electronic, optical, mechanical, or magnetic, including but not limited to photographing, photocopying, recording or any information storage and retrieval system, without written permission of the copyright owner.Amatrol,Inc., 2400 Centennial Blvd., Jeffersonville, IN 47130 USA, Ph 812-288-8285, FAX 812-283-1584 www.amatrol.com

Page 3: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

3

TABLE OF CONTENTS

SEGMENT 1 COUNT UP INSTRUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4OBJECTIVE 1 Describe the function of three types of Siemens counter instructionsOBJECTIVE 2 Describe three categories of counter instructions available in a Siemens STEP 7 projectOBJECTIVE 3 Describe the operation of an SFB count up instruction

SKILL 1 Enter and edit a PLC program that uses an SFB count up instructionSKILL 2 Design a PLC program using an SFB CTU instruction to control the number of production cycles

SEGMENT 2 COUNT DOWN INSTRUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41OBJECTIVE 4 Describe the operation of an SFB count down instruction

SKILL 3 Enter and edit a PLC program that uses an SFB count down instructionSKILL 4 Design a PLC program using an SFB CTD instruction to control the number of production cycles

SEGMENT 3 COUNT UP AND DOWN INSTRUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65OBJECTIVE 5 Describe the operation of an SFB count up/down instruction

SKILL 5 Enter and edit a PLC program that uses an SFB count up/down instructionSKILL 6 Design a PLC program that controls a conveyor queue station

Page 4: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

4

SEGMENT 1COUNT UP INSTRUCTION

OBJECTIVE 1 DESCRIBE THE FUNCTION OF THREE TYPES OF SIEMENS COUNTER INSTRUCTIONS

PLC counter instructions are internal output instructions used to provide count-based control logic. They provide the logic to change the state of output instruc-tions after a predetermined number of counts have been accumulated.

There are three types of counter instructions that can be used in a STEP 7 project. The three types are described as follows.

Count Up

The Count Up (CTU) instruction increases its Count Value by 1 each time the Count Up parameter of the instruction goes from false to true. When the instruc-tion’s Count Value is equal to or greater than the Preset Value, the CTU instruc-tion’s Output is energized.

Count Down

The Count Down (CTD) instruction decreases its Count Value by 1 each time the Count Down parameter of the instruction goes from false to true. When the instruction’s Count Value is equal to or less than 0, the CTD instruction’s Output status is energized.

Count Up/Down

The Count Up/Down (CTUD) instruction increases or decreases the Count Value by 1 each time the Count Up or Count Down parameters go from false to true.

When the instruction’s Count Value is equal to or greater than the Preset Value, the CTUD instruction’s Output Up status is energized.

Whenever the instruction’s CV value is equal to or less than 0, the CTUD instruction’s Output Down status is energized.

Counter instructions are often used in machine controls to provide a count of machine cycles for preventive maintenance applications and/or number of good parts produced. Three applications of PLC instructions are packaging, palletizing and production control.

Page 5: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

5

OBJECTIVE 2 DESCRIBE THREE CATEGORIES OF COUNTER INSTRUCTIONS AVAILABLE IN A SIEMENS STEP 7 PROJECT

There are three categories of counter instructions available in a Siemens STEP 7 project. The three categories are:

• STEP 5 Block Format Counters• STEP 5 Coil Format Counters • STEP 7 System Function Block Counters

STEP 5 Block Format Counters

Figure 1 shows the Counter folder in the LAD/STL/FBD Program Editor’s Program Elements window.

Figure 1. STEP 5 Counters

BLOCK FORMATSTEP 5

COUNTERS

COIL FORMATSTEP 5

COUNTERS

Page 6: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

6

All of the counters contained in this folder are STEP 5 counters. The counters are included in the STEP 7 software to make it easier to convert STEP 5 projects to STEP 7, and for programmers who are familiar with STEP 5 instructions. The fi rst three counters in the folder are the STEP 5 block format counters.

Block format counter instructions have the inputs and outputs inserted around a rectangular instruction block. Figure 2 shows a STEP 5 block format counter instruction.

Figure 2. Block Format Counter Instruction

Page 7: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

7

STEP 5 Coil Format Counters

The second set of counter instructions shown in fi gure 1 are coil format counter instructions. Coil format counter instructions are displayed on the right side of a network as output coils. The counter number and preset value are inserted above and below the coil. Figure 3 shows a STEP 5 coil format counter instruction.

Figure 3. Coil Format Counter Instruction

The SC output coil is the Set Counter instruction. It loads the preset value into the counter identifi ed by the instruction. For example, a preset value of 100 is loaded into counter C0 when input I0.0 is true in Network 1 of fi gure 3. Counter C0 counts down each time input I0.2 turns true because of the Count Down (CD) instruction on network 2. A contact (N.O. or N.C.) can be used with the counter address C0 in other parts of the program. A N.O. contact instruction with address C0 will be true when the count value in C0 is greater than zero.

PRESETVALUE

COUNTERNUMBER

Page 8: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

8

STEP 7 System Function Block Counters

The Standard Library in the Libraries folder in the Program Elements window contains a folder named System Function Blocks (SFBs), shown in fi gure 4. This folder contains STEP 7 SFB instructions.

Figure 4. STEP 7 System Function Block Counters

SFB instructions are a part of the processor’s operating system. This means that if an SFB counter instruction is used, it requires less processor memory than a STEP 5 counter. If a STEP 5 counter is used, the instruction and the data associated with the instruction are downloaded to the processor. If an SFB counter instruction is used, only the data associated with the counter is downloaded to the processor. The SFB instructions, including the counter instructions, are STEP 7 instructions that are IEC compliant.

IEC compliant means that the instructions conform to IEC Standard 1131-3, which is the international standard for PLC programming languages. It defi nes how instructions are to appear and operate for several PLC programming languages. The STEP 7 versions of these languages are Ladder Logic, Statement List, Func-tional Block Diagram, S7-Graph, and SCL (Structured Control Language).

One of the benefi ts of languages that follow the standard is that it allows multiple languages to be used in the same PLC and in the different blocks of a PLC project. This allows a programmer to select the best language for a partic-ular task. This is why a larger STEP 7 project will contain blocks that have been programmed using different languages.

STEP 7 SYSTEMFUNCTION BLOCK

COUNTERS

Page 9: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

9

OBJECTIVE 3 DESCRIBE THE OPERATION OF AN SFB COUNT UP INSTRUCTION

The System Function Block (SFB) Count Up (CTU) instruction increases its Count Value (CV) by one each time its Count Up (CU) input is energized. It ener-gizes its output contacts (Q) when the Count Value equals the Preset Value (PV).

Figure 5. SFB CTU Instruction

One application of the CTU instruction is to keep a running total of the parts produced by a machine. The count value could be used to provide production reports.

Page 10: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

10

The components of the SFB CTU instruction are shown in fi gure 6 and described as follows:

Figure 6. SFB CTU Instruction

•ENABLE INPUT (EN) - The CTU instruction’s Enable Input (EN) param-eter is used to enable the instruction’s operation. When the EN parameter is true the CTU instruction is enabled.

When EN is false, no inputs are accepted by the instruction, but the outputs retain their current value.

•ENABLE OUTPUT (ENO) - The CTU instruction’s Enable Output (ENO) parameter indicates when the instruction is enabled (EN is true). When the EN parameter is true the Enable Output (ENO) is energized.

•COUNT INPUT (CU) - The CTU instruction’s Count Input (CU) param-eter is the count input of the CTU instruction. The enabled CTU instruction increments the Count Value (CV) by 1 for a false to true change in the CU parameter.

•RESET - The CTU instruction’s Reset parameter resets the CTU instructions Count Value (CV) to 0. When the Reset parameter turns true, it changes the Count Value (CV) to the value 0 regardless of the current CV.

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

PARTIAL DATA BLOCK (DB1) FOR CTU INSTRUCTION

SFB CTU INSTRUCTION

Page 11: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

11

•PRESET VALUE (PV) - The CTU instruction’s Preset Value (PV) is the number of times the Count Input (CU) must go from false to true in order to energize the Output (Q).

•OUTPUT (Q) - The CTU instruction’s Output (Q) is energized when the value in the Count Value (CV) is greater than or equal to PV value.

•COUNT VALUE (CV) - The CTU instruction’s Count Value (CV) is the current count value of the CTU instruction. The possible value range is 0 to 32,767.

•DATA BLOCK (DB) - The CTU instruction’s Data Block (DB) is a “user accessible” block of PLC memory that stores the counter’s status data. The Data Block stores the status of the counter’s: Enable Input (EN), Enable Output (ENO), Count Input (CU), Reset, Preset Value (PV), Output (Q), and Count Value (CV). Each SFB CTU instruction requires a data block.

The table shown in the fi gures is a partial view of the Data Block that is used with the SFB counters, and is used to illustrate the operation of the Counter instructions.

Page 12: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

12

To understand how the CTU instruction works, look at the program in fi gure 7. The program is shown with the counter instruction and its Data Block in its initial condition.

At this time, the CTU instruction is disabled because the N.O. Contact (I0.0) instruction is false. The CTU instruction’s CV value (in Memory Word 1 or MW1) is initially 0. The CTU instruction’s PV value is 3. All input parameters are false and all output parameter’s are de-energized at this time, as shown in the table in fi gure 7.

In this example, the CV value is stored in MW1. The CV value can be stored in any Memory Word or Data Block Memory address.

Figure 7. PLC Program Using CTU Instruction

DB1

EN

CU

R

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTU"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNT UP

SWITCH 3

I0.2

RESET

0

0

0

0 Q5.5

INDICATOR 2

COUNTINPUT

RESETPRESETVALUE

INPUTS OUTPUTS

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

Page 13: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

13

In fi gure 8, Switch 2 is turned on causing N.O. Contact instruction I0.1 (CU parameter) to turn true and N.O. Contact instruction I0.0 (EN parameter) to remain false. The counter remains disabled and the CV value remains 0. The EN param-eter must be enabled to increase the Count Value.

Figure 8. CTU Instruction De-energized and CU Parameter True

DB1

EN

CU

R

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTU"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNT UP

SWITCH 3

I0.2

RESET

0

0

1

0 Q5.5

INDICATOR 2

INPUTS OUTPUTS

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

Page 14: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

14

In fi gure 9, Switch 1 is turned on causing N.O. Contact instruction I0.0 (EN) to turn true. This causes the CTU instruction to be enabled. The enabled CTU instruc-tion energizes output Q5.4. Switch 2 has been turned off and on causing the CV value to increase to 1.

Figure 9. CTU Instruction Energized and CU Parameter True

DB1

EN

CU

R

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTU"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNT UP

SWITCH 3

I0.2

RESET

0

1

1

0 Q5.5

INDICATOR 2

INPUTS OUTPUTS

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 1

Page 15: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

15

In fi gure 10, Switch 2 has been turned off and on two more times increasing the CV value to 3. The CV value is now equal to the PV value causing output Q5.5 to be energized. Turning Switch 2 on/off again will increase the CV value, but will not affect the status of the CTU instruction.

Figure 10. CV Value Equals PV Value

DB1

EN

CU

R

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTU"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNT UP

SWITCH 3

I0.2

RESET

1

3

1

0 Q5.5

INDICATOR 2

INPUTS OUTPUTS

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q TRUE

MW1 CV 3

Page 16: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

16

In fi gure 11, Switch 2 has been turned off. Notice that the output Q5.5 is still energized because the CV value is still 3. The output Q will remain energized until Switch 3 is turned on to reset the CV value to 0.

If Switch 1 is turned off, contact I0.0 and output Q5.4 are both turned off; however, both the Q and CV outputs retain their current state, output Q5.5 is still logic 1 and MW1 still has a value of 3.

Figure 11. Switch 2 Off

DB1

EN

CU

R

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTU"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNT UP

SWITCH 3

I0.2

RESET

1

3

1

0 Q5.5

INDICATOR 2

INPUTS OUTPUTS

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q TRUE

MW1 CV 3

Page 17: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

17

In fi gure 12, Switch 3 has been turned on. The value for CV is reset to 0. Because the CV is now less than the PV, output Q5.5 is de-energized.

Figure 12. Reset of CTU Instruction

DB1

EN

CU

R

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTU"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNT UP

SWITCH 3

I0.2

RESET

01

1 Q5.5

INDICATOR 2

0

INPUTS OUTPUTS

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 R TRUE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

Page 18: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

18

SKILL 1 ENTER AND EDIT A PLC PROGRAM THAT USES AN SFB COUNT UP INSTRUCTION

Procedure Overview

In this procedure, you will enter and run a PLC program that uses an SFB Count Up instruction. To do this you will setup and use your 87-IOS I/O Simulator Station.

1. Perform the following substeps to prepare the PLC for use.

A. Verify that the Portable Mounting Console and 87-IOS are connected.

B. Make sure that the PLC power cable is connected to the PLC and plugged into an outlet.

C. Verify that the PLC power cable’s toggle switch is in the off position.

D. Make sure that the interface cable is connected from the PC to the PLC.

E. Make sure that all of the 87-IOS Station’s switches are in the off (down) position.

2. Power up the PLC trainer.

WARNING

Most PLC applications require an organized startup and shutdown procedure to avoid personal injury and/or damage to the machinery. Be certain to follow these procedures when in the fi eld.

3. Start up the SIMATIC Manager.. 4. Create a Project named L5S1xxx where xxx represents your initials. 5. Create a SIMATIC 300 Station object for the trainer and confi gure its

hardware or upload the Station object from the processor. 6. Open Organizational Block OB1. Remember to delete the networks if you uploaded the Station object.

Page 19: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

19

7. Examine the PLC ladder logic program shown in fi gure 13. This program is similar to the one discussed in the previous objective. In the

next few steps, you will enter this program into Organizational Block OB1.

Figure 13. PLC Program Containing CTU Instruction

DB1

EN

CU

R

PV

ENO

Q

CV

I0.0

3

Q4.0

MW1

"CTU”Q4.0

SWITCH 1

I0.0

COUNT UP

SWITCH 2

I0.1

RESET

I0.1

L1

Page 20: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

20

8. Perform the following substeps to enter the Count Up Instruction (SFB CTU), shown in fi gure 13.

A. Make sure the Program Elements Window is visible on your Monitor. The Program Elements Catalog provides a list of Ladder elements or instructions.

B. Locate the Libraries folder, shown in fi gure 14.

Figure 14. Libraries Folder

The Program Elements window contains the following types of objects:• Standard Instruction Folders - The Standard Instructions folders contain the standard ladder logic instructions available for an S7 project.

The counters in this folder are the STEP 5 counters that were discussed earlier.• Family Blocks - The Family Blocks show the blocks of that type called in the project.• Libraries Folder - The Libraries folder contains blocks or instructions that can be used in a project in addition to the instructions contained in the Standard Instructions folder.

Many of the instructions in this folder are STEP 7 IEC compliant instructions.

STANDARDINSTRUCTION

FOLDERS

FAMILYBLOCKS

LIBRARIESFOLDER

COUNTERFOLDER

Page 21: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

21

C. Double-click the Libraries folder to open the folder, as shown in fi gure 15.

Figure 15. Standard Libraries Folder

D. Double-click the Standard Library folder to open the folder as shown in fi gure 16.

Figure 16. Standard Libraries Folder Opened

Page 22: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

22

E. Double-click the System Function Blocks folder to open the folder as shown in fi gure 17.

The System Function Blocks folder contains instructions that are already a part of the CPU’s operating system. This means that a project using an SFB counter instruction will be smaller in size than one using a standard counter instruction, because the SFB counter does not have to be loaded as part of the project. Only the data block associated with it is loaded.

The SFB instructions are IEC compliant instructions that are generally more sophisticated than the same type of instruction in the Standard Instructions folders.

Figure 17. System Function Blocks Folder Opened

F. Select Network 1 by clicking it so that a box appears around the network. If you uploaded the station object and deleted the network, you will need to insert a network rung.

Page 23: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

23

G. Double-click the SFB0 CTU IEC_TC icon to place a copy of the instruc-tion on Network 1, as shown in fi gure 18.

If the instruction appears with SFBO instead of “CTU” listed at the top of the block, select Display With > Symbolic Representation from the View menu.

Figure 18. System Function Block CTU instruction

H. Click on the red ??? and a text box will open.

I. Type DB1 in the box and press Enter twice.

A Data Block must be assigned with SFB counter instructions. For this counter, it will be assigned as DB1.

A dialog should appear asking if you wish to create an instance Data Block with the name DB1.

An instance Data Block is assigned to every Function Block (FB) or System Function Block that transfers data.

Page 24: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

24

J. Click Yes on the dialog to create the Data Block DB1.

The CTU instruction should appear as shown in fi gure 19.

If the software displays a message stating that no symbol table is present, it is probably because the Station object was uploaded from the PLC.

If a default symbol table is inserted into the S7 program folder in the SIMATIC Manager, “CTU” can be displayed the next time the block is opened.

Figure 19. Data Block DB1 Created for CTU Instruction

K. Click in the text box next to the CU parameter to place a cursor in the box.

L. Type I0.0 for the address of the CU parameter.

This is the same as placing a N.O. Contact instruction with address I0.0 next to the CU parameter. You could place a N.O. Contact instruction here, but it is not necessary. The program will function the same either way.

M. Press Enter twice to accept the value and move the text box to the Reset parameter.

N. Click the N.C. Contact button on the toolbar to place a N.C. Contact instruction next to the Reset parameter.

O. Click the red ??? above the N.C. Contact instruction to open a text box.

P. Type I0.1 into the text box.

Page 25: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

25

Q. Press Enter twice to accept the value and move the text box to the next parameter.

Your screen should appear as shown in fi gure 20.

Figure 20. N.C. Contact Instruction Added for Reset Parameter

R. Type 3 into the text box next to the PV parameter.

This is the value that the counter must count to before activating its output.

S. Press Enter twice to accept the value and move the text box to the Q parameter.

T. Type Q4.0 for the address of the Q parameter.

When the CV equals 3, output address Q4.0 will turn true.

This is the same as placing an output coil next to the Q parameter with an address of Q4.0. You could place an output coil next to the parameter, but it is not necessary. The program will function the same either way.

U. Press Enter twice to accept the value and move the text box next to the CV parameter.

V. Type MW1 into the text box.

The CV or Count Value will be stored in Memory Word 1.

Page 26: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

26

W. Press Enter twice to accept the value.

The instruction should appear on your screen as shown in fi gure 21.

Figure 21. SFB CTU Instruction

9. Save OB1. 10. Perform the following substeps to view Data Block DB1.

A. Display the SIMATIC Manager by selecting it from the taskbar.

B. Fully expand the project tree.

C. Select the Blocks folder so that its contents are displayed in the right-hand project window.

The right-hand side project window should contain at least four icons, similar to that shown in fi gure 22.

Figure 22. Blocks Folder with DB1

DB1

EN

CU

R

PV

ENO

Q

CV

I0.0

3

Q4.0

MW1

"CTU”

I0.1

DATA BLOCKDB1

SYSTEMFUNCTION

BLOCK(SFB0)

Page 27: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

27

The DB1 icon is the icon for the data block that was created when the counter instruction was added to OB1. DB1 will be downloaded with OB1 and the System Data when the Station object is downloaded to the processor. The SFB0 icon is the icon for the counter instruction itself. The SFB0 icon is present to indicate the SFBs used by the project. It is not downloaded to the processor since it is already a part of the processors operating system.

D. Double-click the DB1 icon to open DB1.

The dialog shown in fi gure 23 should appear.

Figure 23. Open Data Block Dialog

Page 28: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

28

E. Click Yes on the dialog to open the Data Block.

The Data Block Parameter Assignment application shown in fi gure 24 should open. The application can be used to create, edit, monitor, and download data blocks. Notice that the Data Block lists the Data Block address for each of the counters parameters, the declaration of the param-eter (input, output, or static), the type (in this case Boolean or integer), initial value, actual value, and optional comment. Also notice that toolbar buttons are available to download the data block and monitor the values in the data block while the project is running.

Figure 24. Data Block Parameter Assignment Application

11. Save your PLC project. 12. Perform a memory reset on the processor. 13. Download the SIMATIC 300 Station object to the PLC. 14. Use the PLC programming software to perform a Warm Restart and place

the PLC in RUN mode. 15. Go online with the processor and monitor the OB1 block.

DATA BLOCKADDRESS

PARAMETERNAME

DOWNLOADBUTTON

MONITORBUTTON

Page 29: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

29

16. Perform the following substeps to test the operation of the program.

A. Turn switch 2 on.

B. Examine the PLC program on your computer monitor.

The CTU instruction is energized because there is no conditional logic attached to the EN input. The PV is 3, and the CV is 0. Since CV is less than PV, the Q output is de-energized.

C. Turn switch 1 on and then off.

Doing this causes N.O. Contact instruction to turn true or to a logic 1, enabling the CU input of the counter instruction. This causes the CV output of the instruction to increase to 1. Since the CV is still less than PV, output Q remains de-energized.

D. Display the Data Block editor by selecting it from the PC’s taskbar.

E. Click the Monitor button on the toolbar to go online with the processor.

The application should appear similar to that shown in fi gure 25.

The Actual Value column of the Data Block editor indicates that the PV is 3, the CV is 1, and Q is false.

Figure 25. Online View of Data Block

E. Turn switch 1 on/off two more times.

Doing this causes N.O. Contact instruction I0.0 to turn to a logic 1 each time, enabling the CU input. The CV value increases to 3, the same value PV. Since CV and PV are equal, output Q is energized, which energizes Output Coil Q4.0, causing lamp L1 to turn on.

MONITORBUTTON

CLOSEBUTTON

Page 30: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

30

F. Turn switch 2 off and then on.

Doing this causes the N.C. Contact instruction I0.1 to turn true, applying a logic 1 to the reset input. This clears CV, returning it to 0. The PV is still 3. Since CV is less than PV, output Q has been de-energized.

G. Click the Monitor button on the Data Block editor’s toolbar to go offl ine.

H. Close the Data Block editor by clicking the large [X] in the top-right hand corner of the editor’s window.

17. Repeat step 16 several times to monitor the operation of the counter in the LAD/STL/FBD Editor until you feel comfortable with the operation of the instruction.

18. Click the Monitor button on the LAD/STL/FBD Editor’s toolbar to go offl ine from the processor.

19. Use PLC programming software to place the PLC into STOP mode. 20. Close the LAD/STL/FBD Editor. 21. Perform the following substeps to delete the Data block that was downloaded

to the processor. When a block has been downloaded to the processor, it stays in the processor

until it is manually deleted. A block’s contents can be changed by downloading a block with the same name to the processor, but the only way to remove it is to manually delete it.

A. If the SIMATIC Manager is not displayed on your screen, select it from the PC’s taskbar.

B. Select the Blocks folder.

Page 31: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

31

C. Click the Online button shown in fi gure 26.

The blocks displayed in the folder are either blocks that are a part of the operating system (SFCs and SFBs) or blocks that have been downloaded to the processor, in this case OB1 and DB1.

Figure 26. Online View of Blocks Folder

D. Click the DB1 icon in the right-hand project window to select DB1.

E. Right-click on the DB1 icon to display a shortcut menu.

F. Select Delete from the shortcut menu.

The dialog shown in fi gure 27 should appear.

Figure 27. Deleting DB1

ONLINEBUTTON

CLOSEBUTTON

Page 32: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

32

G. Click Yes to delete the DB1 block.

The SF (System Fault) indicator will turn on if the processor was not placed into STOP mode in Step 18. If this is the case, download DB1 to the processor and restart the processor. Then place the PLC into STOP mode and repeat Step 20.

H. Close the online project window by clicking the large [X] in the top right-hand corner of the window.

22. Close the SIMATIC Manager. 23. Perform the following substeps to power down the PLC trainer.

A. Turn off the PC and monitor.

B. Turn off the PLC trainer.

Page 33: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

33

SKILL 2 DESIGN A PLC PROGRAM USING AN SFB CTU INSTRUCTION TO CONTROL THE NUMBER OF PRODUCTION CYCLES

Procedure Overview

In this procedure, you will design a PLC program that controls the number of production cycles of an ink stamping machine. This program will require you to use the CTU instruction. You will use the single acting DCV and cylinder of your Mechatronics Station to do this. You may use any Mechatronics station except the 87-MS5 to perform this skill.

1. Examine the following information: Scenario: You are working as a technician for a company that produces

electrical transformers. A new ink stamping machine has just been added to the packaging line at the plant. The machine stamps the transformer’s identifi cation numbers on the side of a box. Ink is supplied by cartridges that must be refi lled from time to time.

Write a PLC program to control the new stamping machine. The general sequence, I/O diagram, and pictorial follow:

General Sequence• Pressing the Start pushbutton causes the stamping machine to begin opera-tion. The stamping mechanism then begins to extend.• The stamping mechanism extends until it stamps the box and activates LS2. The stamping mechanism then retracts.• When the stamping mechanism is fully retracted, it activates LS1. The machine delays for 2 seconds. This amount of time is required to move the next box into place.• After 2 seconds, the machine repeats its cycle.

Special Conditions This process continues for 20 cycles and then shuts down. A pilot light then

turns on indicating that the machine has completed 20 cycles and is out of ink.

Once the ink cartridge has been replaced, turning the selector switch to the Reset position resets the machine for 20 more cycles.

Pressing the Stop pushbutton at any time will cause the machine to stop. The count should be maintained so that the machine will complete the remaining cycles if the start pushbutton is pressed again.

Page 34: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

34

Figure 28. PLC I/O Diagram

Figure 29. Pictorial for Stamping Machine Application

2. Use the information from Step 1 to develop your program.

HINT

A counter instruction should be used to turn off the start rung after the 20 cycles have occurred. Some of the parameters of the CTU instruction can have multiple inputs.

SOL

L1

Q4.5

Q4.0

START

STOP

LS1

I0.0

I0.1

I1.0

I1.3

I1.2

STOP

RESET

EXT'D

RET'D

START

STAMPEXTEND

INKEMPTY

LS2

RESETMAIN

START

PNEUMATICCYLINDER

START

RESETSTOP

REFILL INDICATORLIGHT

SOLENOID OPERATEDDCV

EXTEND"STAMP"

LS2

LS1

CONTROLPANEL

BOXES

Page 35: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

35

3. Locate the 87-MS Mechatronics station that you will be using for this exercise.

4. Verify that this station is separated from all other stations. If it is not, perform the following substeps to separate it from the other

stations.

A. Verify that the station power cord has been disconnected from the wall outlet or any other station.

B. At the back of the station, unplug the adjoining station’s power cord from the underneath side of the work surface. Feed the cord through the hold in the adjoining panels.

Figure 30. Power Cord Removed

C. Remove the adjoining station’s pneumatic hose from the quick connect on the station. Feed the hose through the hole in the adjoining panels.

ADJOININGSTATION'S

POWER CORD

STATIONPOWERCORD

Page 36: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

36

Figure 31. Pneumatic Hose

D. In the right front of the station, on the top of the work surface is a 9-pin to 9-pin cable that connects handshaking communications between the two stations. Disconnect this cable from the other station.

Figure 32. 9-Pin Cable

ADJOININGSTATION'S

PNEUMATICHOSE

9-PIN CABLE

Page 37: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

37

E. Loosen the connecting fasteners, shown in fi gure 33, that hold the work surfaces together by turning the thumbscrews CCW.

Figure 33. Connecting Fasteners

F. Push the station away from the other station(s) to give yourself room to work.

5. Verify that the station contains a Portable PLC Mounting Console, if it does not, perform the following substeps install your Portable PLC Mounting Console in the Mechatronics Station.

A. Make sure that the PLC power cable is turned off.

B. Remove the PLC power cable from the Portable PLC Mounting Console.

C. Disconnect the 87-IOS from the Portable PLC Mounting Console

D. Remove the PC to PLC interface cable from the PLC.

E. Grasp the Portable Mounting Console’s handles and hang the Portable PLC Mounting Console onto the 87-MS Station’s receiving hooks.

F. Connect and fasten the Portable Mounting Console’s power cable to the Mechatronics station.

G. Feed the Portable Mounting Console’s DB connectors behind the operator panel and reconnect them to the station’s digital interface module. The cable marked I/O Port 1 should be connected to the left-most connector, the cable marked I/O Port 2 should be connected to the middle connector, and the cable marked I/O Port 3 should be connected to the right-most connector.

H. Make sure that the Interface cable is connected from the PC to the PLC.

I. Remove all stock material from the trainer’s feeder devices and store them in that station’s parts bin.

CONNECTINGFASTENER

Page 38: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

38

6. Plug the station’s power cable into a wall outlet. 7. Connect an air supply to the station’s air manifold quick connect. 8. Perform the following safety check before you begin working on the station.

Make sure that you can answer yes to each item before proceeding.

YES/NO SAFETY CHECKOUT

Remove all obstructions from the work area

Check for signs of damage to the equipment

Wear tight fi tting clothing, roll up long sleeves, remove ties, scarves, jewelry, etc.

Tie up long hair

Remove any robot teach pendants from the work area

Locate the emergency stop button

Ensure that safety glasses are worn by people in area

Ensure that all people are outside any work envelopes

Figure 34. Mechatronics Safety Check

9. Perform the following substeps to power up the station.

A. Place the Mode Selector switch in the Manual position.

B. Remove the lockout/tagout device from the electrical power source.

C. Remove the lockout/tagout device from the pneumatic power source.

D. Turn on the air to the station by shifting the lever on the lockout valve.

E. Set the station’s air supply regulator to 60 psi/414 kPa.

F. Turn the station’s Main Power switch to the On position.

G. Power up the PC and monitor.

H. Place the PLC’s Mode Selector switch into the RUN position. 10. Start the SIMATIC Manager. 11. Create a Project named L5S2xxx where xxx represents your initials. 12. Create a SIMATIC 300 Station object for the trainer and confi gure its

hardware or upload the Station object from the PLC. 13. Open Organizational Block OB1. Remember to delete the Networks in OB1 if you uploaded the Station object.

Page 39: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

39

14. Enter the PLC program that you developed in step 2 into Organizational Block OB1.

15. Save OB1. 16. Reset The PLC. 17. Download the SIMATIC 300 Station object to the PLC. 18. Use the PLC programming software to perform a Warm Restart and place

the PLC in RUN mode. 19. Go online with the processor and monitor the OB1 block. 20. Perform the following substeps to test the operation of the program.

A. Press Start on the Mechatronics Operator Station.

The cylinder should extend, retract, wait two seconds and then repeat the cycle.

After 20 cycles, the machine should turn off and the start button lamp should turn on.

B. Turn the selector switch to the Reset position.

C. Repeat substeps A and B.

Again the machine should operate for twenty cycles and then stop.

D. Repeat substep A, but after a couple of cycles, press Stop.

The cylinder should retract and stop.

E. Press Start.

The machine should run the remaining cycles and then stop. If it doesn’t stop, the system is not resetting properly.

21. Click the Monitor button to go offl ine from the processor. 22. Use PLC programming software to place the PLC into STOP mode. 23. Print out a copy of the ladder logic program and place it in your portfolio. It

will be used in your assessment. 24. Close the LAD/STL/FBD Editor. 25. Close the SIMATIC Manager. 26. Perform the following substeps to power down the PLC trainer.

A. Turn off the PC and monitor.

B. Turn off the PLC trainer.

C. Perform a lockout/tagout on the system’s electrical power source (if applicable).

D. Perform a lockout/tagout on the system’s pneumatic power source (if applicable).

Page 40: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

40

SEGMENT 1 SELF REVIEW

1. PLC counter instructions are internal output instructions used to provide ______ control logic.

2. The Count Down (CTD) instruction ________ its Count Value by 1 each time the Count Down parameter of the instruction goes from false to true.

3. The ______ ______ instruction increases or decreases the Count Value by 1 each time the Count Up or Count Down parameters go from false to true.

4. Block format counter instructions have the inputs and outputs inserted around a ______ instruction block.

5. If an SFB counter instruction is used, only the ______ associated with the counter is downloaded to the processor.

6. The System Function Block (SFB) Count Up (CTU) instruction increases its Count Value (CV) by one each time its Count Up (CU) input is energized. It energizes its ______ ______ when the Count Value equals the Preset Value (PV).

7. One application of the CTU instruction is to keep a running ______ of the parts produced by a machine.

Page 41: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

41

SEGMENT 2COUNT DOWN INSTRUCTION

OBJECTIVE 4 DESCRIBE THE OPERATION OF AN SFB COUNT DOWN INSTRUCTION

The System Function Block (SFB) Count Down (CTD) instruction decreases its Count Value (CV) by one each time its Count Down input is energized. It ener-gizes its output contacts (Q) when the Count Value has decreased to zero. The Count Value is initially loaded by energizing the LOAD input of the counter to load the Preset Value (PV) into the Count Value (CV).

Figure 35. SFB CTD Instruction

One application of the CTD instruction is palletizing, where a product is stacked to a certain height. As the automated material handing equipment stacks each layer, the counter decreases by one. When the counter reaches zero, a new stack is started.

Page 42: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

42

The components of the SFB CTD instruction are shown in fi gure 36 and described as follows:

Figure 36. SFB CTD Instruction

•ENABLE INPUT (EN) - The CTD instruction’s Enable Input (EN) param-eter is used to enable the instruction’s operation. When the EN parameter is true the CTD instruction is enabled.

•ENABLE OUTPUT (ENO) - The CTD instruction’s Enable Output (ENO) parameter indicates when the instruction is enabled (EN is true). When the EN parameter is true the ENO output is energized.

•COUNT INPUT (CD) - The CTD instruction’s Count Down (CD) parameter is the count input of the CTD instruction. The enabled CTD instruction is decremented by 1 for a false to true change in the CD parameter.

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 R FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

PARTIAL DATA BLOCK (DB1) FOR CTU INSTRUCTION

SFB CTU INSTRUCTION IN LADDER LOGIC

Page 43: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

43

•LOAD - The CTD instruction’s LOAD parameter loads the Preset Value (PV) into the Count Value (CV) when a positive pulse is applied to the LOAD input. The CD input is locked out when the LOAD input is a logic1.

•PRESET VALUE (PV) - The CTD instruction’s Preset Value (PV) is the number of times the CD parameter must go from false to true in order to energize the Output (Q) of the CTD instruction.

•OUTPUT (Q) - The CTD instruction’s Output (Q) is energized when the CD value is less than or equal to 0 otherwise the Q output is de-energized.

•COUNT VALUE (CV) - The CTD instruction’s Count Value (CV) is the current value of the CTD instruction. The CV decreases by 1 each time the CD parameter goes from false to true. The possible value range is -32,768 to 32,767.

•DATA BLOCK (DB) - The CTD instruction’s Data Block (DB) is a “user-accessible” block of PLC memory that stores the counter’s status data. The Data Block stores the status of the counter’s: Enable Input (EN), Enable Output (ENO), Count Input (CD), Load Input (LOAD), Preset Value (PV), Output (Q), and Count Value (CV). Each SFB CTD instruction requires its own data block.

The table shown in the fi gures is a partial view of the Data Block that is used with the SFB counters, and is used to illustrate the operation of the counter instruction.

Page 44: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

44

To understand how the CTD instruction works, look at the program in fi gure 37. This program contains an SFB CTD counter instruction and makes use of the instruction’s parameters EN, ENO, CD, LOAD and Q. The program is shown with the counter instruction and its Data Block in its initial condition.

At this time, the CTD instruction is disabled because the N.O. Contact (I0.0) instruction is false. The CTD instruction’s CV value (in Memory Word 1 or MW1) is initially 0. The CTD instruction’s PV value is 3. All input parameters are false and all output instructions are de-energized at this time, as shown in the table in fi gure 37.

Figure 37. PLC Program Using CTD Instruction

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

0

0

0

0 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CD FALSE

I0.2 SWITCH 3 L FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

Page 45: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

45

In fi gure 38, Switch 2 is turned on causing N.O. Contact instruction I0.1 (CD input) to turn true. N.O. Contact instruction I0.0 (EN parameter) is false. When the EN parameter is false, the CTD instruction is not enabled and the CV value remains unchanged. The CTD instruction must be enabled to change the Count Value.

Figure 38. CTD Instruction De-energized and CD True

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

0

0

1

0 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CD TRUE

I0.2 SWITCH 3 L FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 0

Page 46: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

46

In fi gure 39, Switch 1 is turned on enabling the CTD instruction. With the instruction enabled, outputs Q5.4 and Q5.5 are energized. The ENO output (output Q5.4) is energized because the CTD instruction is enabled. The Q output (Q5.5) is energized because the CV is less than or equal to 0.

Figure 39. CTD Instruction Energized and CV Decrease by 1

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

1

0

0

0 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CD FALSE

I0.2 SWITCH 3 L FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 Q TRUE

MW1 CV 0

Page 47: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

47

In fi gure 40, Switch 1 is turned on and Switch 3 is turned on causing the LOAD input to become true while the instruction is enabled. With the LOAD input true, a 3 is moved from the PV parameter into the Count Value (CV) in Memory Word 1 (MW1). The Q output (Q5.5) is de-energized because CV is greater than 0.

Figure 40. CV Equals PV

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

0

3

0

1 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CD FALSE

I0.2 SWITCH 3 L TRUE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 3

Page 48: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

48

Switch 3 is turned off and Switch 2 is turned on causing the CD input to turn true. This will decrease the CV in Memory Word 1 (MW1) by 1, as shown in fi gure 41.

Figure 41. CV Value Decrease by 1

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

0

2

1

0 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CD TRUE

I0.2 SWITCH 3 L FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 2

Page 49: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

49

Switch 2 is turned off and on two more times causing the CV to decrease to 0, as shown in fi gure 42. This causes Q5.5 to be energized because CV is less than or equal to 0. Turning Switch 2 off and on will decrease the CV value, but it will not affect the CTD instruction’s status.

Figure 42. CV Equal to 0

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

1

0

1

0 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CD TRUE

I0.2 SWITCH 3 L FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q TRUE

MW1 CV 0

Page 50: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

50

In fi gure 43, Switch 3 has been turned on resetting CV to 3 by loading the PV. Notice that the output Q (Q5.5) for the CTD instruction is de-energized.

Figure 43. CV Value Loaded into PV Parameter

DB2

EN

CD

LOAD

PV

ENO

Q

CV

I0.1

I0.2

3

Q5.5

MW1

"CTD"Q5.4

Q5.4I0.0INDICATOR 1SWITCH 1

I0.0

ENABLE

SWITCH 2

I0.1

COUNTDOWN

SWITCH 3

I0.2

LOAD

0

3

0

1 Q5.5

INDICATOR 2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CD FALSE

I0.2 SWITCH 3 L TRUE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 Q FALSE

MW1 CV 3

Page 51: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

51

SKILL 3 ENTER AND EDIT A PLC PROGRAM THAT USESAN SFB COUNT DOWN INSTRUCTION

Procedure Overview

In this procedure, you will enter and run a PLC program that uses an SFB Count Down instruction. This should familiarize you with how to enter the instruction as well as how the instruction operates. You will use your 87-IOS I/O Simulator Station in performing this skill.

1. Perform the following substeps to prepare the PLC for use.

A. Verify that the Portable Mounting Console and 87-IOS are connected.

B. Make sure that the PLC power cable is connected to the PLC and plugged into an outlet.

C. Verify that the PLC power cable’s toggle switch is in the off position.

D. Make sure that the interface cable is connected from the PC to the PLC.

E. Turn switch 2 of the 87-IOS on (up), all other switches should be in the off position.

2. Power up the PLC trainer.

WARNING

Most PLC applications require an organized startup and shutdown procedure to avoid personal injury and/or damage to the machinery. Be certain to follow these procedures when in the fi eld.

3. Start up the SIMATIC Manager. 4. Create a Project named L5S3xxx where xxx represents your initials. 5. Create a SIMATIC 300 Station Object for the trainer and confi gure its

hardware or upload the Station object from the PLC. 6. Open Organizational Block OB1 and the LAD/STL/FBD Editor. Remember to delete the Networks if you uploaded the Station object.

Page 52: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

52

7. Examine the PLC ladder logic program shown in fi gure 44. This is very similar to the program discussed in the previous objective. In the

next few steps, you will enter this program into Organizational Block OB1.

Figure 44. PLC Program Containing CTU Instruction

8. Perform the following substeps to enter the Count Down Instruction (SFB CTD), shown in fi gure 39.

A. Make sure the Program Elements Window is visible on your monitor. The Program Elements Window provides a list of Ladder elements or instructions.

B. Locate the Program Elements Window’s Libraries folder, shown in fi gure 45.

Figure 45. Libraries Folder

DB1

EN

CU

R

PV

ENO

Q

CV

I0.0

3

Q4.0

MW1

"CTU”Q4.0

SWITCH 1

I0.0

COUNTDOWN

SWITCH 2

I0.1

RESET

I0.1

L1

Page 53: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

53

C. Double-click the Libraries folder to open the folder, as shown in fi gure 46.

Figure 46. Standard Libraries Folder

D. Double-click the Standard Library folder to open the folder as shown in fi gure 47.

Figure 47. Standard Libraries Folder Opened

Page 54: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

54

E. Double-click the System Function Blocks folder to open the folder as shown in fi gure 48.

Figure 48. System Function Blocks Folder Opened

F. Double-click the SFB1 CTD IEC_TC icon to place a copy of the instruc-tion on Network 1, as shown in fi gure 49.

Figure 49. System Function Block CTU Instruction

Page 55: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

55

G. Click on the red ??? and a text box will open.

H. Type DB1 in the box and press Enter twice.

A Data Block must be assigned with SFB counter instructions. For this counter, it will be assigned as DB1.

A dialog should appear asking if you wish to create a Data Block with the name DB1.

I. Click Yes on the dialog the create the Data Block DB1.

The CTD instruction should appear as shown in fi gure 50.

Figure 50. Data Block DB1 Created for CTD Instruction

J. Click in the text box next to the CD parameter to place a cursor in the box.

K. Type I0.0 for the address of the CD parameter.

This is the same as placing a N.O. Contact instruction with address I0.0 next to the CD parameter. You could place a N.O. Contact instruction here, but it is not necessary. The program will function the same either way.

L. Press Enter twice to accept the value and move the text box to the LOAD parameter.

M. Click the N.C. Contact button on the toolbar to place a N.C. Contact instruction next to the Load (LD) parameter.

N. Click the red ??? above the N.C. Contact instruction to open a text box.

O. Type I0.1 into the text box.

Page 56: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

56

P. Press Enter twice to accept the value and move the text box to the next parameter.

Your screen should appear as shown in fi gure 51.

Figure 51. N.C. Contact Instruction Added for Reset Parameter

Q. Type 3 into the text box next to the PV parameter.

This is the value that the counter must count to before activating its output.

R. Press Enter twice to accept the value and move the text box to the Q parameter.

S. Type Q4.0 for the address of the Q parameter.

When the CV equals 3, output address Q4.0 will turn true.

This is the same as placing an output coil next to the Q parameter with an address of Q4.0. You could place an output coil next to the parameter, but it is not necessary. The program will function the same either way.

T. Press Enter twice to accept the value and move the text box next to the CV parameter.

U. Type MW1 into the text box.

The CV or Count Value will be stored in Memory Word 1.

Page 57: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

57

V. Press Enter twice to accept the value.

The instruction should appear on your screen as shown in fi gure 52.

Figure 52. SFB CTU Instruction

9. Save OB1. 10. Perform a memory reset on the processor. 11. Download the SIMATIC 300 Station object to the PLC. 12. Use the PLC programming software to perform a Warm Restart and place

the PLC in RUN mode. 13. Go online with the processor and monitor the OB1 block. 14. Perform the following substeps to test the operation of the program.

A. Examine the PLC program on your computer monitor.

The CTD instruction is energized because there is no conditional logic attached to the EN input. The PV is three, and the CV is zero. Since the CV is zero, Q is energized, turning on lamp 1 through output Q4.0

B. Turn switch 2 off momentarily.

Doing this causes N.C. Contact instruction I0.1 to turn true or to a logic 1 enabling the LOAD parameter of the counter instruction. This loads the PV into the CV, causing the CV parameter to equal 3. Since the CV is greater than zero, the output parameter Q is de-energized and lamp 1 turns off.

C. Turn switch 1 on.

Doing this causes the N.O. Contact instruction I0.0 to turn true, energizing the CD input of the counter instruction. This causes the CV to decrease from 3 to 2.

Since the CV is still greater than zero, the Q output remains de-energized.

DB1

EN

CD

LOAD

PV

ENO

Q

CV

I0.0

3

Q4.0

MW1

"CTD”

I0.1

Page 58: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

58

D. Turn switch 1 on/off two more times.

Doing this causes N.O. Contact instruction I0.0 to turn true or to a logic 1 each time, enabling the CD input of the counter instruction. The CV value of the instruction decreases to zero. Since the CV is equal to zero, the Q parameter is energized, which energizes output coil Q4.0 causing lamp 1 to turn on.

E. Turn switch 2 off/on.

Doing this causes the N.C. Contact instruction I0.1 to turn true, applying a logic 1 to the LOAD parameter of the counter. This again loads the PV value into the CV, making the CV value 3. Since the CV value is greater than 0, the Q output is de-energized and lamp 1 turns off.

15. Repeat step 14 several times until you feel comfortable with the operation of the instruction.

16. Click the Monitor button to go offl ine from the processor. 17. Use PLC programming software to place the PLC into STOP mode. 18. Close the LAD/STL/FBD Editor. 19. Close the SIMATIC Manager. 20. Perform the following substeps to power down the PLC trainer.

A. Turn off the PC and monitor.

B. Turn off the PLC trainer.

Page 59: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

59

SKILL 4 DESIGN A PLC PROGRAM USING AN SFB CTD INSTRUCTION TO CONTROL THE NUMBER OF PRODUCTION CYCLES

Procedure Overview

In this procedure, you will design a PLC program that controls the number of production cycles of plastic injection molding machine. This program will require you to use a combination of event-driven sequencing, time-driven sequencing, and a CTD instruction. You will use the double-acting DCV and cylinder of the 87-MS1, 87-MS2, or 87-MS3 Mechatronics Station to do this. You may also use the reversing motor starter of the 87-MS6 to simulate the operation of a double-acting DCV.

1. Examine the following information. Scenario: You work on an engineering team for a company that produces

plastic injection molding machines. The company is working on a new machine, as shown in fi gure 53. This machine has three basic components to perform the steps of the injection-molding process: the injection unit, the clamp unit, and the ejector pins.

Plastics material is supplied to the machine’s hopper in a granular or pellet form. The plastic is heated until it melts. Then it is injected or forced into a mold cavity. The injection pressure is held for a period of time until the plastic part is solidifi ed in the mold. The pressure is then released, the mold opens, and the newly-formed plastic parts are ejected by the ejector pins from the machine.

Figure 53. Plastics Injection Molding Machine

Page 60: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

60

Your task is to write a PLC program to control the mold/clamp section of the machine. The general sequence, I/O diagram and a power diagram are as follows:

General Sequence• Pressing START begins the process cycle.• The mold closes (cylinder extends).• When the mold is closed (cylinder extended), LS4 is actuated. This causes plastic to be injected into the mold (green pilot light turns on and a timer starts timing).• After 5 seconds (timer times out), the plastic injection stops (pilot lamp off) and the mold is allowed to cool for a period of 10 seconds (another timer starts timing).• After 10 seconds, the mold opens (cylinder 2 retracts).• Pressing STOP at any time causes the machine to stop at the end of its cycle.• The machine should stop automatically after 10 cycles.

Figure 54. I/O Diagram

START

STOP STOP

START

MOLD CLOSED

I0.0

I0.1

I1.4

MOLD OPENED

I1.5

PILOTLIGHT

INJECTINGPLASTICGQ4.0

SOL 2A

SOL 2B

MOLDCLOSE

MOLDOPEN

Q4.6

Q4.7

LS3

LS4

Page 61: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

61

Figure 55. Power Diagram

2. Use the information from Step 1 to develop your PLC program. 3. Locate the 87-MSx Mechatronics station that you will be using for this

exercise. 4. Verify that this station is separated from all other stations. If it is not, perform the following substeps to separate it from the other

stations.

A. Verify that the station power cord has been disconnected from the wall outlet or any other station.

B. At the back of the station, unplug the adjoining station’s power cord from the underneath side of the work surface. Feed the cord through the hold in the adjoining panels.

C. Remove the adjoining station’s pneumatic hose from the quick connect on the station. Feed the hose through the hole in the adjoining panels.

D. In the right front of the station, on the top of the work surface is a 9-pin to 9-pin cable that connects the communications between the two stations. Disconnect this cable from the other station.

E. Loosen the connecting fasteners that hold the work surfaces together by turning the thumbscrews CCW.

Push the station away from the other station(s) to give yourself room to work.

5. Verify that the station contains a Portable PLC Mounting Console, if it does not, perform the following substeps install your Portable PLC Mounting Console in the Mechatronics Station.

A. Make sure that the PLC power cable is turned off.

B. Remove the PLC power cable from the Portable PLC Mounting Console.

C. Disconnect the 87-IOS from the Portable PLC Mounting Console

D. Remove the PC to PLC interface cable from the PLC.

CLAMPCYLINDER

SOL 2ACLOSE

SOL 2BOPEN

SOL 1A

LS3MOLD

OPENED

LS4MOLD

CLOSED

OPEN CLOSED

MOLD

EJECTORCYLINDER

EJECTORPINS

Page 62: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

62

E. Grasp the Portable Mounting Console’s handles and hang the Portable PLC Mounting Console onto the 87-MS Station’s receiving hooks.

F. Connect and fasten the Portable Mounting Console’s power cable to the Mechatronics station.

G. Feed the Portable Mounting Console’s DB connectors behind the operator panel and reconnect them to the station’s digital interface module. The cable marked I/O Port 1 should be connected to the left-most connector, cable I/O Port 2 should be connected to the middle connector, and cable I/O Port 3 should be connected to the right-most connector.

H. Make sure that the Interface cable is connected from the PC to the PLC.

I. Remove all stock material from the trainer’s feeder devices and store them in that station’s parts bin.

6. Plug the station’s power cable into a wall outlet. 7. Connect an air supply to the station’s air manifold quick connect. 8. Perform the following safety check before you begin working on the station.

Make sure that you can answer yes to each item before proceeding.

YES/NO SAFETY CHECKOUT

Remove all obstructions from the work area

Check for signs of damage to the equipment

Wear tight fi tting clothing, roll up long sleeves, remove ties, scarves, jewelry, etc.

Tie up long hair

Remove any robot teach pendants from the work area

Locate the emergency stop button

Ensure that safety glasses are worn by people in area

Ensure that all people are outside any work envelopes

Figure 56. Mechatronics Safety Check

9. Perform the following substeps to power up the station.

A. Place the Mode Selector switch in the Manual position.

B. Remove the lockout/tagout device from the electrical power source.

C. Remove the lockout/tagout device from the pneumatic power source.

D. Turn on the air to the station by shifting the lever on the lockout valve.

E. Set the station’s air supply regulator to 60 psi/414 kPa.

F. Turn the station’s Main Power switch to the On position.

G. Power up the PC and monitor.

H. Place the PLC’s Mode Selector switch into the RUN position.

Page 63: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

63

10. Start the SIMATIC Manager. 11. Create a Project named L5S4xxx where xxx represents your initials. 12. Create a SIMATIC 300 Station object for the trainer and confi gure its

hardware or upload the Station object by selecting Upload Station or Upload Station to PG... from the PLC menu.

13. Enter the PLC program that you developed in Step 2 into the OB1 fi le. Make sure to delete all of the networks fi rst if you uploaded the Station object. 14. Save your PLC project. 15. Perform a memory reset on the processor. 16. Download the SIMATIC 300 Station object to the PLC. 17. Perform a Warm Restart to place the PLC in Run Mode. 18. Go online with the processor and monitor the OB1 block. 19. Perform the following substeps to test the operation of your program.

A. Press START momentarily.

Cylinder 2 should begin to extend (mold closing).

After cylinder 2 extends (mold closed), the green pilot light should turn on to signal that the plastic is being injected.

After 5 seconds the green pilot light should turn off and the mold cools for 10 seconds.

After 10 seconds and the mold opens (cylinder retracts). The “machine” should repeat its cycle.

B. During one of the cycles, press STOP momentarily.

The cycle should continue until it reaches the end and then stops.

C. Press START momentarily.

The machine should start cycling again.

Verify that the machine stops after it has completed 10 cycles. 20. Click the Monitor button to go offl ine from the processor. 21. Use the PLC programming software to place the PLC into STOP Mode. 22. Close the LAD/STL/FBD Editor. 23. Close the SIMATIC Manager. 24. Perform the following substeps to power down the PLC trainer.

A. Turn off the PC and monitor.

B. Turn off the PLC trainer.

C. Perform a lockout/tagout on the system’s electrical power source (if applicable).

D. Perform a lockout/tagout on the system’s pneumatic power source (if applicable).

Page 64: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

64

SEGMENT 2 SELF REVIEW

1. The System Function Block (SFB) Count Down (CTD) instruction _________ its Count Value (CV) by one each time its Count Down input is energized.

2. The CTD instruction energizes its ______ ______ when the Count Value has decreased to zero.

3. The Count Value is initially loaded by energizing the LOAD input of the counter to load the ______ ______ into the Count Value (CV).

4. The CTD instruction’s ______ ______ parameter is the count input of the CTD instruction.

5. The CTD instruction’s ______ ______ is the number of times the CD parameter must go from false to true in order to energize the Output (Q) of the CTD instruction.

6. The CV decreases by 1 each time the CD parameter goes from false to true. The possible value range is ______ to ______.

7. The CTD instruction’s ______ ______ is a “user-accessible” block of PLC memory that stores the counter’s status data.

Page 65: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

65

SEGMENT 3COUNT UP AND DOWN INSTRUCTION

OBJECTIVE 5 DESCRIBE THE OPERATION OF AN SFB COUNT UP/DOWN INSTRUCTION

The Siemens System Function Block (SFB) Count Up/Down (CTUD) instruc-tion increases its Count Value by one each time the Count Up (CU) input is ener-gized and decreases its Count Value by one each time the Count Down (CD) input is energized.

The instructions Output Up (QU) parameter is energized when the Count Value (CV) is greater than or equal to the Preset Value. The instructions Output Down (QD) parameter is energized when the Count Value is less than or equal to zero.

Figure 57. SFB CTUD Instruction

The CTUD instruction is used in applications where a certain amount of product must be stored or staged for the next operation. This staging of product ensures a constant fl ow to the next process. To maintain a constant amount of product in the staging area, an Up/Down Counter counts up or down depending on whether product is entering or leaving the storage area.

Page 66: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

66

The components of the SFB CTUD instruction are shown in fi gure 58 and described as follows:

Figure 58. SFB CTUD Instruction

•ENABLE INPUT (EN) - The CTUD instruction’s Enable Input (EN) param-eter is used to enable the instruction’s operation. When the EN parameter is true the CTUD instruction is enabled.

•ENABLE OUTPUT (ENO) - The CTUD instruction’s Enable Output (ENO) parameter indicates when the instruction is enabled (EN is true). When the EN parameter is true the ENO output is energized.

•COUNT UP INPUT (CU) - The CTUD instruction’s Count Up Input (CU) parameter is the count up input of the CTUD instruction. A false-to-true change in the CU parameter causes the enabled CTUD instruction to increase its count value by 1.

•COUNT DOWN INPUT (CD) - The CTUD instruction’s Count Down Input (CD) parameter is the count down input of the CTUD instruction. A false-to-true change in the CD parameter causes the enabled CTUD instruction to decrease its count value by 1.

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD"

0

0

0

0

00

0

Q5.4

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 CD FALSE

I0.3 SWITCH 4 R FALSE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 QU FALSE

Q5.6 INDICATOR 3 QD FALSE

MW1 CV 0

PARTIAL DATA BLOCK (DB1) FOR CTU INSTRUCTION

Page 67: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

67

•LOAD - The CTUD instructions LOAD parameter loads the Preset Value (PV) into the Count Value (CV) when a positive pulse is applied to the LOAD input. The CU and CD inputs are locked out when the LOAD input is a logic 1.

•RESET - The CTUD instruction’s Reset parameter resets the CTUD instruc-tion’s Count Value (CV) to 0. When the Reset parameter is true, it changes the Count Value (CV) to the value 0 regardless of the value currently at the Count Value (CV).

•PRESET VALUE (PV) PV - The CTUD instruction’s Preset Value (PV) is the number of times the CU or CD parameter must go false to true in order to energize the Output Up or Down. (QU/QD).

•OUTPUT UP (QU) - The CTUD instruction’s Output Up (QU) is energized when the CU value is greater than or equal to PV value.

•OUTPUT DOWN (QD) - The CTUD instruction’s Output Down (QD) is energized when the CD value is less than or equal to 0.

•COUNT VALUE (CV) - The CTUD instruction’s Count Value (CV) is the current value of the CTUD instruction. The possible value range is -32,768 to 32,767.

•DATA BLOCK (DB) - The CTUD instruction’s Data Block (DB) is a “user accessible” block of PLC memory in which counter status data is stored. The Data Block stores the status of the counter’s: Enable Input (EN), Enable Output (ENO), Count Up Input (CU), Count Down Input (CD), Reset, Load, Preset Value (PV), Outputs Up or Down (QU/QD), and Count Value (CV). Each SFB CTUD instruction requires its own data block.

The table shown in the fi gures is a partial view of the Data block that is used with the SFB counters, and is used to illustrate the operation of the counter instruction.

Page 68: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

68

To understand how the CTUD instruction works, look at the program in fi gure 59. This program contains an SFB CTUD counter instruction and makes use of the instruction’s parameters EN, ENO, CU, CD, R, LOAD, PV, QU and QD. The program is shown with the counter instruction and its Data Block in its initial condition.

At this time, the CTUD instruction is disabled because the N.O. Contact (I0.0) instruction is false. The CTUD instruction’s CV (in Memory Word 1 or MW1) is initially 0. The CTUD instruction’s PV is initially 3. All input parameters are false and all outputs are de-energized at this time, as shown in the table in fi gure 59.

Figure 59. PLC Programming Using CTUD Instruction

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD" Q5.4I0.0

0

0

0

0

Q5.4

INDICATOR 1

Q5.5

INDICATOR 2

Q5.6

INDICATOR 3

SWITCH 1

I0.0

SWITCH 2

I0.1

SWITCH 3

I0.2

SWITCH 4

I0.3

SWITCH 5

I0.4

00

0

INPUTS OUTPUTS

ENABLE

COUNT UP

COUNTDOWN

RESET

LOAD

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 CD FALSE

I0.3 SWITCH 4 R FALSE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 QU FALSE

Q5.6 INDICATOR 3 QD FALSE

MW1 CV 0

Page 69: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

69

In fi gure 60, Switch 2 is turned on causing N.O. Contact instruction I0.1 (CU parameter) to turn true. N.O. Contact instruction I0.0 (EN parameter) is false. With the EN parameter false the CTUD instruction is disabled. A disabled CTUD instruction will cause the CV to stay 0. Unless the CTUD instruction is enabled, the Count Value will not increase or decrease.

Figure 60. CTUD Instruction De-energized and CU True

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD" Q5.4I0.0

01

0

Q5.4

INDICATOR 1

Q5.5

INDICATOR 2

Q5.6

INDICATOR 3

SWITCH 1

I0.0

SWITCH 2

I0.1

SWITCH 3

I0.2

SWITCH 4

I0.3

SWITCH 5

I0.4

0

0

INPUTS OUTPUTS

ENABLE

COUNT UP

COUNTDOWN

RESET

LOAD

0

0

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN FALSE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 CD FALSE

I0.3 SWITCH 4 R FALSE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO FALSE

Q5.5 INDICATOR 2 QU FALSE

Q5.6 INDICATOR 3 QD FALSE

v CV 0

Page 70: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

70

In fi gure 61, Switch 1 is turned on to enable the CTUD instruction. Switch 2 is turned on applying a positive input to the CU input. This causes the CV value to increase to 1. The enabled CTUD instruction counts only when the CU or CD parameter goes from false to true.

Figure 61. CTUD Instruction Energized and CU Parameter True

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD" Q5.4I0.0

01

0

Q5.4

INDICATOR 1

0 Q5.5

INDICATOR 2

Q5.6

INDICATOR 3

SWITCH 1

I0.0

SWITCH 2

I0.1

SWITCH 3

I0.2

SWITCH 4

I0.3

SWITCH 5

I0.4

0

0

INPUTS OUTPUTS

ENABLE

COUNT UP

COUNTDOWN

RESET

LOAD

1

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 CD FALSE

I0.3 SWITCH 4 R FALSE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 QU FALSE

Q5.6 INDICATOR 3 QD FALSE

MW1 CV 1

Page 71: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

71

In fi gure 62, Switch 2 has been turned off and on two more times causing the CV to be 3. The CV is now equal to the PV in the CTUD instruction causing output QU (Q5.5) to be energized. Turning Switch 2 on/off from this point on will increase the CV value, but will not affect the CTUD instruction’s status.

Figure 62. CV Value Equals PV Value

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD" Q5.4I0.0

11

0

Q5.4

INDICATOR 1

Q5.5

INDICATOR 2

Q5.6

INDICATOR 3

0

SWITCH 1

I0.0

SWITCH 2

I0.1

SWITCH 3

I0.2

SWITCH 4

I0.3

SWITCH 5

I0.4

0

0

INPUTS OUTPUTS

ENABLE

COUNT UP

COUNTDOWN

RESET

LOAD

3

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU TRUE

I0.2 SWITCH 3 CD FALSE

I0.3 SWITCH 4 R FALSE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 QU TRUE

Q5.6 INDICATOR 3 QD FALSE

MW1 CV 3

Page 72: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

72

In fi gure 63, Switch 2 has been turned off and Switch 3 is turned on causing the CV to decrease by 1. The CV is now 2. Notice that the output ENO (Q5.4) is still energized but output QU (Q5.5) is now de-energized. The output QU for the CTUD instruction is not energized because the CV does not equal the PV.

Figure 63. CV Value Decreases by Making CD Parameter True

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD" Q5.4I0.0

00

1

Q5.4

INDICATOR 1

Q5.5

INDICATOR 2

Q5.6

INDICATOR 3

0

SWITCH 1

I0.0

SWITCH 2

I0.1

SWITCH 3

I0.2

SWITCH 4

I0.3

SWITCH 5

I0.4

0

0

INPUTS OUTPUTS

ENABLE

COUNT UP

COUNTDOWN

RESET

LOAD

2

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 CD TRUE

I0.3 SWITCH 4 R FALSE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 QU FALSE

Q5.6 INDICATOR 3 QD FALSE

MW1 CV 2

Page 73: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

73

In fi gure 64, Switch 4 has been turned on. The CV is reset to 0. Notice that the output QU (Q5.5) is de-energized. Output QD (Q5.6) is energized because CV equals 0.

Figure 64. Reset of CTUD Instruction

DB2

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1

I0.2

3

I0.3

I0.4

Q5.5

Q5.6

MW1

"CTUD" Q5.4I0.0

00

0

Q5.4

INDICATOR 1

Q5.5

INDICATOR 2

Q5.6

INDICATOR 3

SWITCH 1

I0.0

SWITCH 2

I0.1

SWITCH 3

I0.2

SWITCH 4

I0.3

SWITCH 5

I0.4

1

0

INPUTS OUTPUTS

ENABLE

COUNT UP

COUNTDOWN

RESET

LOAD

1

0

ADDRESS SYMBOL PARAMETER STATE/VALUE

I0.0 SWITCH 1 EN TRUE

I0.1 SWITCH 2 CU FALSE

I0.2 SWITCH 3 CD FALSE

I0.3 SWITCH 4 R TRUE

I0.4 SWITCH 5 LOAD FALSE

PV 3

Q5.4 INDICATOR 1 ENO TRUE

Q5.5 INDICATOR 2 QU FALSE

Q5.6 INDICATOR 3 QD TRUE

MW1 CV 0

Page 74: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

74

SKILL 5 ENTER AND EDIT A PLC PROGRAM THAT USES AN SFB COUNT UP/DOWN INSTRUCTION

Procedure Overview

In this procedure, you will enter and run a PLC program that uses an SFB Count Up/Count Down instruction. This should familiarize you with how to enter the instruction as well as how the instruction operates. You will use your 87-IOS I/O Simulator Station in performing this skill.

1. Perform the following substeps to prepare the PLC for use.

A. Verify that the Portable Mounting Console and 87-IOS are connected.

B. Make sure that the PLC power cable is connected to the PLC and plugged into an outlet.

C. Verify that the PLC power cable’s toggle switch is in the off position.

D. Make sure that the interface cable is connected from the PC to the PLC.

E. Turn switch 2 of the 87-IOS on (up) all other switches should be in the off position.

2. Power up the PLC trainer.

WARNING

Most PLC applications require an organized startup and shutdown procedure to avoid personal injury and/or damage to the machinery. Be certain to follow these procedures when in the fi eld.

3. Start up the SIMATIC Manager. 4. Create a Project named L5S5xxx where xxx represents your initials. 5. Create a SIMATIC 300 Station object for the trainer and confi gure its

hardware or upload the Station object from the PLC. 6. Open Organizational Block OB1. Remember to delete the Networks if you uploaded the Station object.

Page 75: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

75

7. Examine the PLC ladder logic program shown in fi gure 65.

Figure 65. PLC Program Containing CTU Instruction

8. Enter the PLC program shown in fi gure 65. The CTUD instruction (SFB2) is in the System Function Blocks folder. 9. Save OB1 to disk. 10. Perform a memory reset on the processor. 11. Download the SIMATIC 300 Station object to the PLC. 12. Use the PLC programming software to perform a Warm Restart and place

the PLC in RUN mode. 13. Go online with the processor and monitor the OB1 block. 14. Perform the following substeps to test the operation of the program.

A. Examine the PLC program on your computer monitor.

In its initial condition, QD is energized because CV equals zero. QD causes output Q4.1 to be true which turns on Lamp 2.

B. Turn switch 4 on and off.

Doing this energizes the LOAD parameter of the instruction, causing the PV of 3 to be loaded in to the CV. Since CV is greater than zero, the QD output is de-energized, turning off lamp L2. Also QU is energized because CV is greater than zero, which energized output Q4.0 and turned on lamp 1.

C. Turn switch 1 on and off.

This increases the CV to 4. All other inputs and outputs remain the same.

D. Turn switch 3 on/off twice.

Doing this energizes the QD parameter, which causes the CV to count down.

The CV should now be 2, which is less than the PV. Since CV is less than PV, output QD remains de-energized and output QU has de-energized, turning off L1.

EN

CU

CD

R

LOAD

PV

ENO

QU

QD

CV

I0.1I0.2

I0.3

3

Q4.0

Q4.1

MW1

"CTUD"Q4.0

SWITCH 1

SWITCH 3

SWITCH 4

I0.0

I0.2

I0.3

I0.0

DB1

L1

Q4.1 L2

SWITCH 2

I0.1

LAMP 1

LAMP 2

Page 76: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

76

E. Turn switch 3 on/off two more times.

This causes the CV to be zero. Since the CV is zero, the QD parameter energizes and the QU parameter remains de-energized. L2 turns on.

15. Repeat step 14 several times until you feel comfortable with the operation of the instruction.

16. Click the Monitor button to go offl ine from the processor. 17. Use PLC programming software to place the PLC into STOP mode. 18. Close the LAD/STL/FBD Editor. 19. Close the SIMATIC Manager. 20. Perform the following substeps to power down the PLC trainer.

A. Turn off the PC and monitor.

B. Turn off the PLC trainer.

Page 77: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

77

SKILL 6 DESIGN A PLC PROGRAM THAT CONTROLS A CONVEYOR QUEUE STATION

Procedure Overview

In this procedure, you will design a PLC program that uses an Up/Down Counter instruction to control a conveyor queue station. You may use any Mechatronics station except the 87-MS5 to perform this skill.

1. Examine the following information: Scenario: You work as an electrical engineer for a highly automated

manufacturing company. An “experimental” robot workcell has been designed for the production line. This robot will load and unload parts to a CNC lathe.

The robot will get is parts from a queue station (waiting area for parts) that receives parts from the main conveyor. The problem is that the queue can only hold four parts, so it has been decided that a gate controlled by a PLC will be used to make sure no more than four parts can enter the queue at any one time.

Your job is to design a program that will operate the queue station. The general sequence, I/O diagram, and pictorial are as follows: General Sequence

• Pressing the Start pushbutton causes the queue station to begin operation. The cylinder extends to open the queue and allow parts to enter.• As each part enters the queue, it passes photoelectric sensor, PE1. This sensor causes the PLC to count the number of parts that enter the queue station.• When the parts count reaches four, the queue gate closes (cylinder retracts).• As each part leaves the workcell, it passes the photoelectric sensor 2, PE2. This sensor counts the parts that are leaving the queue station.• The queue can only hold four parts at any one time. Therefore, the queue gate is to be closed whenever there are four parts in the workcell. This is the net difference between the parts counted by PE1 and PE2.• The pneumatically operated queue gate opens (cylinder extends) any time there are fewer than four parts in the queue station.• The process continues until the Stop pushbutton is pressed. This causes the system and the counter instruction to reset.

Page 78: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

78

Figure 66. Pictorial for Conveyor Queue Station

Figure 67. PLC I/O Diagram

2. Use the information from Step 1 to develop your program.

CONVEYOR TRAVEL

CNC LATHE

PARTS

ROBOT

OFF RAMPPHOTOELECTRIC

SENSOR (PE2)

PHOTOELECTRICSENSOR (PE1)

PNEUMATICCYLINDER

QUEUE

GATE

SOL SV1

Q4.5I0.0

I0.1

I1.0

I1.0

STOP

(PE1)

(PE2)

STARTQUEUEGATEOPEN

RESETMAN

AUTO

X

X

Page 79: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

79

3. Locate the 87-MS Mechatronics station that you will be using for this exercise.

4. Verify that this station is separated from all other stations. If it is not, perform the following substeps to separate it from the other

stations.

A. Verify that the station power cord has been disconnected from the wall outlet or any other station.

B. At the back of the station, unplug the adjoining station’s power cord from the underneath side of the work surface. Feed the cord through the hold in the adjoining panels.

C. Remove the adjoining station’s pneumatic hose from the quick connect on the station. Feed the hose through the hole in the adjoining panels.

D. In the right front of the station, on the top of the work surface is a 9-pin to 9-pin cable that connects the communications between the two stations. Disconnect this cable from the other station.

E. Loosen the connecting fasteners that hold the work surfaces together by turning the thumbscrews CCW.

Push the station away from the other station(s) to give yourself room to work.

5. Verify that the station contains a Portable PLC Mounting Console, if it does not, perform the following substeps install your Portable PLC Mounting Console in the Mechatronics Station.

A. Make sure that the PLC power cable is turned off.

B. Remove the PLC power cable from the Portable PLC Mounting Console.

C. Disconnect the 87-IOS from the Portable PLC Mounting Console

D. Remove the PC to PLC interface cable from the PLC.

E. Grasp the Portable Mounting Console’s handles and hang the Portable PLC Mounting Console onto the 87-MS Station’s receiving hooks.

F. Connect and fasten the Portable Mounting Console’s power cable to the Mechatronics station.

G. Feed the Portable Mounting Console’s DB connectors behind the operator panel and reconnect them to the station’s digital interface module. The cable marked I/O Port 1 should be connected to the left-most connector, cable I/O Port 2 should be connected to the middle connector, and cable I/O Port 3 should be connected to the right-most connector.

H. Make sure that the Interface cable is connected from the PC to the PLC.

I. Remove all stock material from the trainer’s feeder devices and store them in that station’s parts bin.

6. Plug the station’s power cable into a wall outlet. 7. Connect an air supply to the station’s air manifold quick connect.

Page 80: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

80

8. Perform the following safety check before you begin working on the station. Make sure that you can answer yes to each item before proceeding.

YES/NO SAFETY CHECKOUT

Remove all obstructions from the work area

Check for signs of damage to the equipment

Wear tight fi tting clothing, roll up long sleeves, remove ties, scarves, jewelry, etc.

Tie up long hair

Remove any robot teach pendants from the work area

Locate the emergency stop button

Ensure that safety glasses are worn by people in area

Ensure that all people are outside any work envelopes

Figure 68. Mechatronics Safety Check

9. Perform the following substeps to power up the station.

A. Place the Mode Select switch in the Manual position.

B. Remove the lockout/tagout device from the electrical power source.

C. Remove the lockout/tagout device from the pneumatic power source.

D. Turn on the air to the station by shifting the lever on the lockout valve.

E. Set the station’s air supply regulator to 60 psi/414kPa.

F. Turn the station’s Main Power switch to the On position.

G. Power up the PC and monitor.

H. Place the PLC’s Mode Selector switch into the RUN position. 10. Start the SIMATIC Manager. 11. Create a Project named L5S6xxx where xxx represents your initials. 12. Create a SIMATIC 300 Station object for the trainer and confi gure its

hardware or upload the Station object from the PLC. 13. Open Organizational Block OB1. Remember to delete the Networks if you uploaded the Station object. 14. Enter the PLC program that you developed in step 2 into Organizational

Block OB1. 15. Save OB1. 16. Perform a memory reset on the processor. 17. Download the SIMATIC 300 Station object to the PLC. 18. Use the PLC programming software to perform a Warm Restart and place

the PLC in RUN mode. 19. Go online with the processor and monitor the OB1 block.

Page 81: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

81

20. Perform the following substeps to test the operation of the program.

A. Press and release the Start pushbutton.

B. Turn the Cycle Select switch to the left and back to center four times.

This simulates four parts entering the robot’s queue workcell.

The gate should close after the fourth part has entered the workcell.

C. Turn the Cycle Select switch to the right and back to center twice.

This simulates two parts leaving the robot’s workcell.

After turning the Cycle Select switch right the fi rst time, the gate should open.

D. Turn the Cycle Select switch to the left and back to center once.

This simulates another part entering the queue.

The gate should remain open.

E. Turn the Cycle Select switch to the left and back to center again.

The gate should close. 21. Click the Monitor button to go offl ine from the processor. 22. Use PLC programming software to place the PLC into STOP mode. 23. Close the LAD/STL/FBD Editor. 24. Close the SIMATIC Manager. 25. Perform the following substeps to power down the PLC trainer.

A. Turn off the PC and monitor.

B. Turn off the PLC trainer.

C. Perform a lockout/tagout on the system’s electrical power source (if applicable).

D. Perform a lockout/tagout on the system’s pneumatic power source (if applicable).

Page 82: PLC COUNTER INSTRUCTIONS - Edl€¦ · PLC counter instructions are ... Figure 1 shows the Counter folder in the LAD/STL/FBD ... are included in the STEP 7 software to make it easier

B25014-AA05UEN PLC COUNTER INSTRUCTIONSCopyright © 2012 Amatrol, Inc.

82

SEGMENT 3 SELF REVIEW

1. The Siemens System Function Block (SFB) Count Up/Down (CTUD) instruction increases its Count Value by one each time the ______ ______ input is energized and decreases its Count Value by one each time the ______ ______ input is energized.

2. The CTUD instruction’s ______ ______ parameter is energized when the Count Value (CV) is greater than or equal to the Preset Value.

3. The CTUD instruction’s ______ ______ parameter is energized when the Count Value is less than or equal to zero.

4. To maintain a constant amount of product in the staging area, an Up/Down Counter counts up or down depending on whether product is ______ or ______ the storage area.

5. A _________ change in the CU parameter causes the enabled CTUD instruction to increase its count value by 1.

6. The CTUD instructions LOAD parameter loads the ______ ______ into the Count Value (CV) when a positive pulse is applied to the LOAD input.

7. When the Reset parameter is true, it changes the Count Value (CV) to the value ______ regardless of the value currently at the Count Value (CV).

8. The CTUD instruction’s Count Value (CV) is the current value of the CTUD instruction. The possible value range is ______ to ______.