Encapsulated data in automation programming

Using an element of object oriented programming can keep data organized and simplify writing code.

01/08/2013


One problem we face when developing an automation solution is managing and organizing the vast amounts data that are needed. This applies to numerous scenarios, whether it is developing a tracking system, controlling conveyors, or discrete machine control. Not only is the organization of the data important to the control system directly, graphics development is equally concerned.

When presented with the challenge of developing a new automation solution, one of the first, and easiest traps to fall into is jumping into code development too quickly. This usually happens right after the I/O list is roughed in. The general mentality is that the code has to be finished ASAP to allow the graphics folks to get working on the screens and animation, but let’s think about an alternative approach.

Modern control processors offer significant improvement over the typical PLCs of the past. These improvements are, in part, the result of advances in computer theory, specifically object oriented programming (OOP). One of the concepts in OOP is called encapsulation. This idea stresses putting all of the characteristics of something together into one container or object. The idea being, if you want to know about a something, you only have to go to one place to find it. Conversely, all somethings have the same characteristics available. (This is grossly over-simplified, but it gets the point across).

Today’s control processors provide the ability of achieving encapsulated and highly organized data through the use of user defined data-types (UDT). Most manufacturers not only provide UDTs for developers, but employ the concept liberally themselves; for an example, look at the definition of a timer or counter type. These data types are made up of a collection of even more basic data types – Booleans, integers, etc.

The process begins, for me, with a spreadsheet layout that I've refined over time, some basic symbology, and the rough I/O list. Diagram 1 is an example of the basic symbols that I use for the data. The symbols are broken down into two basic areas: HMI and Proc(ess). The HMI symbols will be of great importance to the graphics developer, while the Proc symbols detail how the data moves through the program.

Diagram 1: Basic symbology

Diagram 1: Basic symbology

At this point, the challenge is to develop UDT definitions that will contain all of the necessary data elements for all like things. As an example, let’s consider a conveyor line and the motors that it uses. There are numerous characteristics of each motor: is it enabled, are the interlocks met, has the motor faulted, is it in Auto mode, and so on. Diagram 2 is a sample of a part of an individual motor definition that was developed.

Diagram 2: Sample motor UDT
Diagram 2: Sample motor UDT

The name, type, and description columns refer to the individual characteristic and what it means. The right-hand (un-named) column helps to clarify the meaning of the actual value. Of big help to the HMI folks is what the actual point means to them – the data can be read, written, either, don't touch, etc. The Proc field indicates where it’s from, how its flows and where / how it’s generated. There are no real requirements here, just information that adds clarity to the material in total.

Not only can the UDT contain basic data types, but it can be made up of other UDTs, as evidenced in diagram 3.

Diagram 3: Contained UDT’s as elements
Diagram 3: Contained UDT’s as elements

The upper portion is still part of the motor definition and it contains further UDTs of additional encapsulated data.

After mapping out all of the requirements of the system or process, we have generated several things:

• A significant amount of documented data in the controller
• Documentation to pass along to the graphics developer, and
• A reasonably well thought-out approach on how to write the actual code!

Once all of the UDTs have been input and controller tags created, development is well on its way. Obviously, writing the code is not trivial, but writing routines that deal with all or part of the data is further simplified by allowing those routines to work with the entire block of data; ALL of it, not just a few variables. Continuing on from this point, routines need to ensure that:

• Data is moved into registers (example: field inputs)
• Functional control is executed (example: interlocks are developed), and
• Data is moved out of registers (example: field outputs)

In general, when following this methodology, the code itself is more modular in nature and therefore much easier to maintain. It also lends itself to more thoroughly documented code, which is always a plus.

This is one approach to programming and it is not necessarily the only way to solve the problem. However, I believe that it is one more option that can be added to an automation developer’s bag of tricks.

This post was written by Jeff Monforton. Jeff is a senior engineer at MAVERICK Technologies, a leading system integrator providing industrial automation, operational support, and control systems engineering services in the manufacturing and process industries. MAVERICK delivers expertise and consulting in a wide variety of areas including industrial automation controls, distributed control systems, manufacturing execution systems, operational strategy, and business process optimization. The company provides a full range of automation and controls services – ranging from PID controller tuning and HMI programming to serving as a main automation contractor. Additionally MAVERICK offers industrial and technical staffing services, placing on-site automation, instrumentation and controls engineers.



No comments
The Top Plant program honors outstanding manufacturing facilities in North America. View the 2013 Top Plant.
The Product of the Year program recognizes products newly released in the manufacturing industries.
The Engineering Leaders Under 40 program identifies and gives recognition to young engineers who...
The true cost of lubrication: Three keys to consider when evaluating oils; Plant Engineering Lubrication Guide; 11 ways to protect bearing assets; Is lubrication part of your KPIs?
Contract maintenance: 5 ways to keep things humming while keeping an eye on costs; Pneumatic systems; Energy monitoring; The sixth 'S' is safety
Transport your data: Supply chain information critical to operational excellence; High-voltage faults; Portable cooling; Safety automation isn't automatic
Case Study Database

Case Study Database

Get more exposure for your case study by uploading it to the Plant Engineering case study database, where end-users can identify relevant solutions and explore what the experts are doing to effectively implement a variety of technology and productivity related projects.

These case studies provide examples of how knowledgeable solution providers have used technology, processes and people to create effective and successful implementations in real-world situations. Case studies can be completed by filling out a simple online form where you can outline the project title, abstract, and full story in 1500 words or less; upload photos, videos and a logo.

Click here to visit the Case Study Database and upload your case study.

Maintaining low data center PUE; Using eco mode in UPS systems; Commissioning electrical and power systems; Exploring dc power distribution alternatives
Synchronizing industrial Ethernet networks; Selecting protocol conversion gateways; Integrating HMIs with PLCs and PACs
Why manufacturers need to see energy in a different light: Current approaches to energy management yield quick savings, but leave plant managers searching for ways of improving on those early gains.

Annual Salary Survey

Participate in the 2013 Salary Survey

In a year when manufacturing continued to lead the economic rebound, it makes sense that plant manager bonuses rebounded. Plant Engineering’s annual Salary Survey shows both wages and bonuses rose in 2012 after a retreat the year before.

Average salary across all job titles for plant floor management rose 3.5% to $95,446, and bonus compensation jumped to $15,162, a 4.2% increase from the 2010 level and double the 2011 total, which showed a sharp drop in bonus.

2012 Salary Survey Analysis

2012 Salary Survey Results

Maintenance and reliability tips and best practices from the maintenance and reliability coaches at Allied Reliability Group.
The One Voice for Manufacturing blog reports on federal public policy issues impacting the manufacturing sector. One Voice is a joint effort by the National Tooling and Machining...
The Society for Maintenance and Reliability Professionals an organization devoted...
Join this ongoing discussion of machine guarding topics, including solutions assessments, regulatory compliance, gap analysis...
IMS Research, recently acquired by IHS Inc., is a leading independent supplier of market research and consultancy to the global electronics industry.
Maintenance is not optional in manufacturing. It’s a profit center, driving productivity and uptime while reducing overall repair costs.
The Lachance on CMMS blog is about current maintenance topics. Blogger Paul Lachance is president and chief technology officer for Smartware Group.