Routines in a Studio 5000 Logix Designer Project

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. You can find that part here or if you’re new to the series, you can find all of the previous parts here.

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;

  • Ladder Logic
  • Function Block Diagram
  • Sequential Function Chart
  • Structured Text

You can see what programming language a routine is written in by the unique icon attached to the routine in the Controller Organizer;

A routine can be written in any of the four programming languages

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.

Main Routine

Studio 5000 Logix Designer | Main Routine

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.

Subroutine

Studio 5000 Logix Designer | Subroutine

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.

Fault Routine

Studio 5000 Logix Designer | Fault Routine

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.

Creating Routines

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

Add a new routine to a program

The New Routine dialog opens.

Give the routine a name and optionally choose the assignment for the routine. Click OK to create the routine.

Give the routine a name and click OK

In this case, a main routine called P_Routine is created in the program, P_Program.

Conclusion

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.

Latest articles