Learn Logix Part 3.4. In this article, we learn about routines in a Studio 5000 Logix Designer project. Specifically, we learn what routines are, what routines are available to use in a Studio 5000 Logix Designer project, and how to create them.
Learn Logix is a series of articles designed to teach you everything you need to know to work with Rockwell Automation’s Studio 5000 Logix Designer and the Logix 5000 series of PLCs.
In the last part of the series, we learned about programs in a Studio 5000 Logix Designer project. Specifically, we learned what programs are and how to create them. In this part of the series, we’ll learn about the types of routines available in a Studio 5000 Logix Designer project and how to create them.
A routine is a project component where code is written and viewed. A routine can be written in any of the four programming languages that are supported by Studio 5000 Logix Designer. These programming languages are;
You can see what programming language a routine is written in by the unique icon attached to the routine in the Controller Organizer;
All routines in a Studio 5000 Logix Designer project are defined as the main routine, a fault routine, or a subroutine. The assignment of a routine as the main routine or a fault routine is done in the Configuration tab of the Program Properties dialog box.
If a routine is not assigned as the main routine or a fault routine, then it is automatically a subroutine.
Let’s look at the role of each type of routine within a program in more detail.
The main routine is the default routine scheduled in the program to be executed by the controller. Since the main routine is the default routine for the program, every program must have exactly one main routine.
You can identify the main routine in a program, by the symbol “1” attached to the routine’s icon.
It is common to only use the main routine to call other subroutines in the program using the Jump to Subroutine (JSR) instruction. The JSR instruction is used to call a specific subroutine in a program.
A subroutine is a segment of code that performs a specific task in a program. A program can have as many subroutines as the memory of the controller being used allows.
Subroutines are only executed when they are called by a JSR instruction. If a subroutine is not called from a routine being executed, then it is not scanned by the controller.
A fault routine is the routine that is executed when the controller finds a major recoverable fault while executing a program. Each program can only have one fault routine which is assigned when creating a new routine within the program.
To create a routine in a Studio 5000 Logix Designer project, right-click on the program where you want to add the routine and click Add > New Routine
The New Routine dialog opens.
Give the routine a name and optionally choose the assignment for the routine. Click OK to create the routine.
In this case, a main routine called P_Routine is created in the program, P_Program.
In this article, we learned about routines in a Studio 5000 Logix Designer project. Specifically, we learned about the types of routines that are available to use and how to create them.
In the next part of the series, we will learn about tags in a Studio 5000 Logix Designer project. If you haven’t already, be sure to subscribe to the mailing list below to be notified when the next part is available.
Update: You can find the next part of the Learn Logix series, Understanding Industrial Networks, here. In this article, we get an overview of industrial networks and learn about the main components that make up an industrial network.
A detailed look at how to work with the new CEM programming language available in TIA Portal and the advantages of this new high-level programming language.
C# From Scratch Part 1.1. In this part, we learn how to install .NET on your machine.