Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Creating Routines

Important User Information


This documentation, whether, illustrative, printed, “online” or electronic (hereinafter “Documentation”) is intended for use only as
a learning aid when using Rockwell Automation approved demonstration hardware, software and firmware. The Documentation
should only be used as a learning tool by qualified professionals.

The variety of uses for the hardware, software and firmware (hereinafter “Products”) described in this Documentation, mandates
that those responsible for the application and use of those Products must satisfy themselves that all necessary steps have been
taken to ensure that each application and actual use meets all performance and safety requirements, including any applicable
laws, regulations, codes and standards in addition to any applicable technical documents.

In no event will Rockwell Automation, Inc., or any of its affiliate or subsidiary companies (hereinafter “Rockwell Automation”) be
responsible or liable for any indirect or consequential damages resulting from the use or application of the Products described in
this Documentation. Rockwell Automation does not assume responsibility or liability for damages of any kind based on the
alleged use of, or reliance on, this Documentation.

No patent liability is assumed by Rockwell Automation with respect to use of information, circuits, equipment, or software
described in the Documentation.

Except as specifically agreed in writing as part of a maintenance or support contract, equipment users are responsible for:
• properly using, calibrating, operating, monitoring and maintaining all Products consistent with all Rockwell Automation
or third-party provided instructions, warnings, recommendations and documentation;
• ensuring that only properly trained personnel use, operate and maintain the Products at all times;
• staying informed of all Product updates and alerts and implementing all updates and fixes; and
• all other factors affecting the Products that are outside of the direct control of Rockwell Automation.

Reproduction of the contents of the Documentation, in whole or in part, without written permission of Rockwell Automation is
prohibited.

Throughout this manual we use the following notes to make you aware of safety considerations:

Identifies information about practices or circumstances


that can cause an explosion in a hazardous environment,
which may lead to personal injury or death, property damage, or economic loss.

Identifies information that is critical for successful application and understanding of the product.

Identifies information about practices or circumstances that can lead to personal injury or death, property
damage, or economic loss. Attentions help you:
• identify a hazard
• avoid a hazard
• recognize the consequence

Labels may be located on or inside the drive to alert people that dangerous voltage may be present.

Labels may be located on or inside the drive to alert people that surfaces may be dangerous temperatures.
Level 1: Logix - On Demand Creating Routines

Before You Begin

About this Lab


We will frequently want to organize our logic into multiple routines. We may do this for the
purpose of legibility, but we may also want to control if and when certain logic runs.
Furthermore, if we wish to program our logic in multiple languages, then we will require a
separate routine for each language that we wish to use. In this lab you will:
 Create routines
This lab takes approximately 10 minutes to complete.

Hardware
To complete this lab, you will require the following hardware:
 PC-based programming workstation with access to the RAcbi learning environment

Software
To complete this lab, you will require the following software:
 Studio 5000 Logix Designer® version 32

Files
To complete this lab, you will require the following files:
 Machine_1_Lab16.ACD

Setup
To complete this lab, you will need to perform the following setup procedure:
1. Log on to your instance of the RAcbi learning environment.

© Rockwell Automation, Inc. All rights reserved. 1


Creating Routines Level 1: Logix - On Demand

Create Routines
We currently have logic for the control of a conveyor in the main routine of a program that will
control a packaging line. We know that we will require a similar routine for the second line
conveyor. Furthermore, we would like to include a routine that monitors and reports status.
Thus, we need to create several subroutines and a main routine from wherein we will call the
subroutines. In this section of the lab, you will create routines to meet these requirements.

1. If you have completed all labs up to this point in the Level 1: Logix - On Demand course,
then you may continue using your Machine_1.ACD file from previous labs:
a. Open the Studio 5000® environment.
b. Under Recent Projects, select your Machine_1 project:

1.b.

2. If you have NOT completed all labs up to this point in the Level 1: Logix - On Demand
course (e.g., you are just doing this individual lab as a refresher), then open the starting
file for this lab:

a. Use the shortcut on the desktop of your instance of the RAcbi learning
environment to open the LabFiles.
b. Open the Machine_1_Lab16.ACD file.

We currently have all of our Conveyor 1 control logic programmed into the main routine of the
program. So, let’s begin by renaming this routine to reflect its function, and then we can remove
it from the program’s main routine assignment.

2 © Rockwell Automation, Inc. All rights reserved.


Level 1: Logix - On Demand Creating Routines

3. Within the MainProgram of the MainTask, right-click the MainRoutine and select
Properties:

4. Change the Name to ‘Conveyor_01’ and click the OK button:

© Rockwell Automation, Inc. All rights reserved. 3


Creating Routines Level 1: Logix - On Demand

5. Right-click the MainProgram and select Properties:

6. Go to the Configuration tab, set the Main assignment to <none>, and click the OK
button:

4 © Rockwell Automation, Inc. All rights reserved.


Level 1: Logix - On Demand Creating Routines

Now that we have changed our conveyor control routine into a subroutine, let’s create a
new program main routine.

7. Right-click the MainProgram, expand Add, and select New Routine… :

© Rockwell Automation, Inc. All rights reserved. 5


Creating Routines Level 1: Logix - On Demand

8. Name the routine ‘Dispatch’ and then verify that is in the Ladder Diagram language, it is
scheduled within the MainProgram, and it has the Main Assignment before clicking the
OK button:

Let’s add another routine to contain our status logic.

9. Right-click on the MainProgram, expand Add, and select New Routine… :

6 © Rockwell Automation, Inc. All rights reserved.


Level 1: Logix - On Demand Creating Routines

10. Name the routine ‘Status’ and then verify that is in the Ladder Diagram language and it
is scheduled within the MainProgram before clicking the OK button:

Since our conveyor control logic is now within a subroutine, and our new Status routine
is also a subroutine, we need to direct the processor to scan them from within the main
routine. Otherwise, they will not run.

11. Open the Dispatch routine.


12. Select rung 0, type ‘JSR’, and press Enter on your keyboard:

© Rockwell Automation, Inc. All rights reserved. 7


Creating Routines Level 1: Logix - On Demand

13. In the dropdown for the Jump to Subroutine (JSR) instruction, select the Conveyor_01
routine:

14. Right-click rung 0, select Copy, and then right-click rung 0 again and select Paste:

15. In the dropdown for the JSR on rung 1, select the Status routine:

8 © Rockwell Automation, Inc. All rights reserved.


Level 1: Logix - On Demand Creating Routines

Because these rungs are unconditional, the processor will scan the Conveyor_01 routine
and then the Status routine every time it comes around to scanning these rungs of code.
16. Close the Dispatch routine.

17. Click the Save icon to save your project.

© Rockwell Automation, Inc. All rights reserved. 9

You might also like