Book Image

Instant PLC Programming with RSLogix 5000

Book Image

Instant PLC Programming with RSLogix 5000

Overview of this book

RSLogix5000 is a user friendly IEC61131-3-compliant interface for programming the current generation of Rockwell Automation PLCs, which includes Ladder Diagrams (LD), Graphical Function Block Diagrams (FBD), Graphical Structured Text (ST), and Sequential Function Charts (SFC). Instant PLC Programming with RSLogix 5000 captures the core elements of PLC programming with RSLogix 5000 with a minimal investment of time. We will avoid getting into control theory and focus on condensing the information specific to RSLogix 5000. We have selected the key areas of RSLogix and provide a step-by-step approach to teaching them. This book start by follows the steps involved in creating a new RSLogix 5000 project and configuring racks, slots, and channels. Next, we will create routines using the various languages available in RSLogix 5000, troubleshooting and resolving issues we encounter along the way. Finally, we will dive into the advanced features, such as online changes, code generation, task management, and user-defined structures. You will also learn object-oriented PLC programming techniques using advanced features like user-defined types (UDTs) that improve the maintainability, uniformity, and readability of our routines. We also highlight the strengths and limitations of online changes and demonstrate techniques to maximize flexibility. You will learn everything you need to get up and running with RSLogix 5000 as well as best practices used by industry experts.
Table of Contents (7 chapters)

Understanding tags (Simple)


RSLogix 5000 Named Associations (text-based memory locations also known as variables) are used in our PLC application to represent process values and equipment. In this recipe, we will introduce text-based name associations used in RSLogix 5000. We will demonstrate the configuration of tag types Base and Alias. We will work through a step-by-step guide to creating and associating tags with inputs, outputs, and memory.

Getting ready

To complete this exercise, you need to have completed the previous recipes.

How to do it...

  1. First, we will create a tag using the New Tag window. You can open the new tag window by right-clicking on the Controller Tags folder of the Controller Organizer (to display the Controller Organizer, press Alt + 0) and selecting New Tag (or by pressing Ctrl + W).

  2. The New Tag window allows us to configure several parameters for our tag. The first tag we will create will be a base tag that will be used internally in the program and is not directly associated to a card in the controller. The first base tag will be the set point for the flow control valve FC1001, so we will give it a text-based named association of FC1001_SP.

  3. Along with the name, setting a description is a recommended best practice. We will set the description to FLOW CONTROL 1001 SET POINT. Refer to the upcoming screenshot.

  4. Next, we will set the Type dropdown to Base.

  5. We will set the Data Type of our base tag to REAL.

    Note

    The REAL data type in RSLogix 5000 is a 32-bit (4 byte) value based on the IEEE 754 single-precision format. Using a floating decimal point, it is capable of representing a wide, dynamic range of values at the cost of precision. Data types are a critical component of PLC programming with the RSLogix 5000 platform. There are dozens of data types available in RSLogix 5000—too many to list in this short book. Rockwell has published a terrific document, Logix 5000 Controllers I/O and Tag Data, detailing the available data types and their usages available at http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm004_-en-p.pdf.

  6. We will set the value of Scope to FirstController.

  7. Setting the scope to Controller level will allow us to use this tag in all the tasks and programs in the project (Global scope).

  8. The External Access field is set to Read/Write so that our operator will be able to set the value from the HMI.

  9. The Style dropdown allows us to modify the way the value is displayed and the choices vary depending on the data type that is being used. The following screenshot shows all of these settings:

  10. Finally, we will click on OK to finish adding our variable tag to the project.

  11. Now, we will double-click on the Controller Tags leaf of the Controller Organizer and view our newly added tag in the Controller Scope pane of our project.

    Note

    The Tag Properties window can be viewed by selecting the tag, then right-clicking on it and selecting Tag Properties (or pressing Alt + Enter).

  12. Next, we will repeat the same process for an Alias tag that will be directly associated with the analog output of the flow control valve. This time, we will use the Controller Tags pane to enter our new tag into the Tags table. At the bottom of the Controller Tags pane, there is a tab labeled Edit Tags and, if we click on that tab, we can type a tag into the bottom row of the table as if we were adding it to a spreadsheet.

  13. In the Name column, set the value to FC1001_PV.

  14. In the Alias for column, select the data outputted from the analog input card. We added Local:1:I.Ch0Data as shown in the following screenshot:

  15. Finally, set the description to FLOW CONTROL VALVE 1001 PROCESS VALUE.

    Note

    Using aliases for inputs is a bad practice due to the asynchronous nature of the way the ControlLogix processor requests data. The ControlLogix CPU has multiple cores capable of executing multiple tasks simultaneously; your analog input values can change part way through the scan of your logic. Values changing part way through a routine can cause results that are difficult to predict and put a program in a state that it is not intended to be in. Experienced programmers copy the value of the input to an internal tag at the beginning of the routine or at the beginning of the continuous task. Using COP instructions to move digital input values to internal tags is also a bad practice because it is more difficult to force the values. Forcing values that are mapped contact-to-coil is much easier to do and read. In summary, digital inputs should be mapped coil-to-contact to internal tags and analog inputs should be mapped to internal tags using MOV instructions.

    Note

    Outputs use aliases because there are no issues with asynchronous data transfers and it is easy to force an alias.

How it works...

We have added two new tags to our project as follows:

  • A base type tag that is not directly connected to an input or output card and allows us to specify any data type we wish to use

  • An alias type tag that is connected to an input or output card value and whose data type is specified by the card configuration

RSLogix 5000 uses text-based named associations that can be referenced by name throughout the project. In RSLogix, tags can also be referenced by external sources, such as HMIs, SCADA, and DCS systems rather than the numeric addresses of legacy PLC applications.

There's more...

Text-based named associations is an important concept in RSLogix 5000. This recipe describes a few more important aspects of it.

Deleting tags

Tags can also be deleted from the Edit Tags tab of the Controller Tags pane. You can delete a tag by right-clicking on the box to the left of the name and selecting the Delete menu option (or by pressing the Delete key after selecting a tag).

Understanding tag scope

The Scope field of the New Tag form represents the area where the tag is visible within the controller. When you specify the scope as the controller itself (FirstController in our example), the tag is accessible globally, meaning it can be accessed from all tasks and programs. Later, we will create programs and define tags that have a scope for a particular program and cannot be accessed outside that specific program.

Data Types in RSLogix 5000

There is a wide range of data types available, which can be seen from the Data Type dropdown of the New Tag form. Base types, arrays, function block types, motion control types, and so on can be added to a controller at any Scope level.

Produced and Consumed tags

You may have noticed that there were two other options in the Type field of the New Tag form: Produced and Consumed. These tags allow values to be shared between two separate PLCs on a network. They are limited to a handful of data types. The project that contains the Produced tag must have the remote-networked PLC mapped in I/O Configuration of the project. More information on produced and consumed tags can be found in the Rockwell publication Logix5000 Controllers Produced and Consumed Tags available at http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm011_-en-p.pdf.