By Fritz Purkert
ISA Standards & Practices
PLC Technology has improved in the past few years mainly due to the improved speed and multiple core computer processors. This improved communication and allowed complex functions to be incorporated into the logic controllers. 15 years ago the processing of a PID loop took about 250 ms – now the speed is 250 ᶙs, with a response time of 1 ᶙs. The higher processing speed allows the use of more complicated algorithms. One thing has changed little – most programming is still sequential, which, at even high speed, means it is not real time.
One other change was introduced in the last few years – the logic controllers are able (and allowed) to process safety functions. While the processors have become quite reliable and the control elements are more rugged and able to take abuse (mechanical and electrical), programming has not become easier.
Logic controllers can be programmed in ladder logic, sequential functions charts, function block diagrams, and procedure function charts, and recently some PLC manufacturers starting to offer PC programming languages like: C, C++, and C #, Java and Visual Basic. Unlike in the business world computing (changes and transactions), a chemical process or manufacturing step cannot be rolled back and corrected for product already manufactured.
Control programming is not an art, it is an engineering discipline. As with any discipline it requires self-control and self-restraint. It is engineering, which is creatively applying understood and proven principles to generate workable solutions for new designs.
Good implementation requires good design, good coding and effective debugging skills. It requires the programmer to be comfortable with the programming language and its idiosyncrasies. Each hardware manufacturer has a slightly different approach to a function implementation. Changing PLC manufacturers may require a new learning experience for programmers and coders. To avoid confusion, management should try to enforce the use of the same names for computer variables when programs. Typically, when writing new or updated programs, the major mistake that occurs is misspelling variables names. Even the best programmers make mistakes. Record the errors – even the ones caught be the compiler or editor.
Allowing safety related functions being programmed with a PLC can make mistakes more severe or even dangerous. Keep the safety related functions separate from the control functions. If possible use a separate CPU for each function. This comes close to a parallel processing approach, but it adds a huge level of complexity. KISS is still the best approach to any programming task (keep it simple stupid).
Document your work, document any changes, document simple and complex errors. It will allow you to identify weak spots, recognize patterns, and make you more aware of possible mistakes. Learning from your mistakes will make you a better engineer and programmer.
Apply these good programming habits:
- Reuse previously proven code – document them
- Produce consistent unambiguous design
- Provide time to document and update designs
- Document code logic
- Break code into manageable pieces
- Provide version control of source code
- Ask for code review by peers (a must with safety section)
- Debug only small portions of code at one time
- Record errors and learn from them
- Become an expert by documenting your mistakes – it is progress.