February 11, 2005 |
Highlights | Sponsored by ABB |
A step-by-step guide illustrating how IEC61131-3 programming can be used in PLCs to execute specific functions and re-used to create different routines for existing or future projects. |
Object-Based Programming in PLCs
Object-based programming has become a common aspect of today’s office automation software products. Anyone who has added a customization to a spreadsheet or a user interface to a database is familiar with the benefits of these re-usable, self-contained modules. The world of programmable logic controllers (PLCs), however, had been slow to react to user demand until the release of the IEC61131-3 programming standard and subsequent products. The IEC61131-3 standard attempts to bring order to the chaotic world of PLC program development by implementing a better definition of program and data table structure. By adopting these standards into the definition of data table tag structures, a re-usable piece of logic can be developed which is not unlike objects that we use in Visual Basic, Access, or Excel. In its simplest form, an object is a piece of logic that executes one or more functions based on data contained within it. In addition, this object/data pair can be reused easily throughout the same program or in different programs. To show how this is done, Rockwell Automation’s ControlLogix will be used to depict how object-based programming is performed on PLCs. Defining an object To illustrate how such an object can be implemented in an actual ControlLogix program, let’s use an example of conveyor control. The object requirements are as follows:
User-defined types Master UDT: Conveyor Sub-UDTs When defining sub-UDTs and elements within UDTs, descriptive names should be used. This will be beneficial for program documenting since only the master UDT will require a descriptor. The element names will serve to further describe themselves. Declaring the UDT Object logic definition It is very important to ensure that all logic in the object subroutine only reference elements of the object data structure. This will allow re-use of the object code in its entirety. Real I/O can be mapped into object elements from another subroutine located under an “Inputs” program and real outputs can be activated from object elements programmed in another subroutine located under an “Outputs” program. This I/O mapping accomplishes the following:
Typical input and output mappings are shown here (input is top graphic). Once the I/O has been mapped, the object logic follows. The following example shows a simplified run command using object elements only. Summary
The speed of deployment comes because only one search-and-replace needs to be done per subroutine if I/O alias tags are used to define device I/O. All device functionality required for current and future needs can be built into the object model. This allows re-use within existing and future projects. Testing and commissioning accuracy can be another derived benefit from using this model. By building simulation logic and data structure into each object, the entire testing and simulating process becomes a function of the object. This also adds to object portability because the object can be completely tested without a physical connection to the I/O sub-system. Mike Voll is controls manager, manufacturing/industrial, Stantec Consulting Ltd. |