Tag based memory structures are what most new generation PLC/PAC's use. A tag is a friendly name for a memory location. This tag name also has a data type assigned.
In this section we will use the Allen Bradley ControlLogix PAC. Refer to the manufacturer manual for other PAC brands.
As stated earlier, tags are the same as variables used in languages such as C++, VB.NET or Java. Tag names should be assigned that are descriptive to the data being stored in them. Example of tag names could be:
There are several rules that must be followed when creating tag names.
When a tag is created it must be assigned a data type. The basic data types are 'basic' and 'structured'. The following tables outline the basic data types and the most commonly used structures.
|31 - 16||15 - 8||7 - 1||0|
|Bool||Not Used||Not Used||Not Used||0 or 1|
|Sint||Not used||Not used||-128 to 127|
|Int||Not Used||-32,768 to 32,767|
|Dint||-2,147,483,648 to 2,147,483,647|
-3.40282347E38 to -1.17549435E-38 (negative values)
1.17549435E-38 to 3.40282347E38 (positive values)
|Structure Data Type||Type of Stored Data|
|Timer||Control structure for timer instructions|
|counter||Control structure for counter instructions|
|Control||Control structure for array instructions|
|Message||Control structure for the message instructions|
|PID||Structure for the PID instructions|
Before continuing with tags, data types and structures, it is important to understand the structure of a ControlLogix project. ControlLogix projects consist of Tasks, Programs and routines. The following is a graphical representation of a ControlLogix project. Refer to this graphic during the following descriptions.
There are two types of tasks: continuous and periodic. Every project must have one continuous task and it can be the only continuous task in the project. A project can have upto 32-tasks. A task is associated with a progarm and has two functions:
As stated above there are two types of tasks, continuous and periodic.
Each task requires at least one program. A task can have up to 32-programs. Only one program can execute at-a-time.
Routines are where the executable code resides. Routines can be written in:
or a combination of all.
There are two types of routines:
When a program executes the main routine executes first. The main routine is used to call(execute) other routines in the program (subroutines).
For those who are familiar with the AB SLC500 or PLC5, the main routine is the same as LAD 2.
Any and all additional routines within a program are called subroutines. Subroutines are used to keep programs organized. They contain executable code, just like the main routine and can be written in any of the 4-languages listed above. Subroutines will only execute when they are called from the main routine or from another subroutine.
An example for the use of subroutines could be: An assembly area uses a rotary indexer that has 10-different assembly stations. There can be 10-subroutines with each subroutine containing the program code that controls one of the assembly stations. These subroutines are called from the main routine or from other subroutines. If the product being produced does not require the 10-assembly stations, the subroutine call to the assembly station(s) not required can be disabled and that/those stations will not be included in the process.
There are two types of tags:
The scope of a tag is where and when the data stored at the location in memory referenced by the tag is available. Some languages call scope, lifetime.
The data in a program scoped tag is only available when that program is executing. The tag and its data are not available to any other program. When the program stops executing and transfers control to another program the tags in the stopped program are no longer available.
Program level tags assist in keeping data organized and also assists in security by providing data hiding.
The following figure is a screen shot of the Rockwell Automation RSLogix 5000 project window that shows the tree structure of an RSLogix 5000 project.
There are two tag classifications:
All instructions are assigned a base tag. The base tag is a tag name that represents the process function and is assigned a data type appropriate for that function.
As an example: A mixing vessel on the north side of the plant might have a base tag name; North_Vessel_Mixer and if this tage is being used to turn on/off the mixer motor it would assigned the data type Bool (0 or 1).
An Alias For tag is another name for a base tag. I/O points are assigned to base tags using an Alias For to the I/O module point.
If the mixer motor controller is wired to an output module in slot 2, terminal 14, the I/O point would be assigned using an Alias For tag. Therefore, the base tag: North_Vessel_Mixer would be assigned an Alias For tag of: Local:2:O.Data.14
The form for a physical address in the AB ControlLogix processor is:
The location specifies the network location for the data.
The slot is the slot number the I/O module is plugged into. Slot are numbered with slot 0 being the first slot on the left side of the rack and continues counting up by 1 going to the right.
The Type specifies one for four types of data:
Member specifies the type of data that the module can store. Digital (discrete) I/O modules use a DATA member. Analog I/O modules use a Channel Member (CH#)
A submember is specific data related to a member. More on this later.
The bit number specifies a bit number for an internal instructions or a screw terminal for I/O modules.
Only two delimiters are used; Colons (:) and periods (dots)(.). If an address is a control-type tag, a (C) is placed at the end of the address to indicate that the tag is a controller scoped tag.
Example: if a base tah is assigned to a start push button on process 1, that is wired to the input module in slot 7, screw terminal 8, and if this input module is in the same rack as the controller, the base tag might be:
and then it would be assigned an Alias For of:
There is no submember for the Alias For.