A blend of traditional and high-level language programming may best serve industrial applications
For more answers to this question, click here.
A Control Design reader writes: We have some new younger engineers on staff who are fluent in some of the newer programming languages, but our customers want machines with more traditional programming languages like ladder logic. Are we wrong to hang onto International Electrotechnical Commission (IEC) 61131-3 languages? Upper management is slow to evolve with changing technology or letting the younger generation lead the way. Where are languages like Python and C++ most useful in industrial settings? Can Python run fast enough for real-time control? Where is the ability of C++ to create data logs most useful?
Answers
IEC languages shine for real-time control
I don’t see anything wrong with using—I don’t like the phrase “hanging onto”—IEC 61131-related languages as part of an overall Swiss Army Knife-style-toolkit approach to offering a solution to complex automation systems. Ladder, function-block-diagram and sequential-function-chart programming tools offer a meaningful graphical interface for troubleshooting for many technicians who come from a more electrical/technician background and not a programming background. And programmers/developers should always keep in mind who will be diagnosing problems that occur in the field.
The problem is using these tools to program very complex automation processes, such as databasing and network communications, where a more textual language like structured text or a high-level language (HLL) would be more useful. For these situations, being able to blend the various IEC and HLL programming tools allows for the creation of truly powerful solutions (Figure 1). There are a growing number of software platforms that allow this blending of programming methods and hardware to run these solutions, so it is good to have a discussion on the pros and cons of various HLLs.
The questioner asks specifically about Python and C++. These are good languages to discuss as they, along with C# and Node-Red, have been making a significant impact on automation. There are a couple of significant advantages to using these languages—talent pool and online support resources. There are a large number of programmers versed in these languages, and universities graduate far more programmers with these skills than they do IEC programmers.
Both languages have a large online support community with extensive open-source libraries and code snippets in Github that have been tested and proven by the masses and are available for download and used to provide shortcuts to development. One programmer that I know mentioned needing to create a simple HTTP server, and doing it in IEC was extremely tedious, whereas he was able to download some open-source C++ code and have it working in just a few hours.
When considering if Python has the speed to run a real-time application, the question that needs to be asked is: “How fast does the application need to run?” The real issue with Python’s speed is its garbage collector—the means by which it manages memory so that the programmer doesn’t have to, like in the days of Fortran and C. The garbage collector makes for a more compact program, but the memory needs to be looked after, and this can slow down processing. The garbage collector can be strategically disabled during the running of critical code so the processing speed can be played with.
So while Python can be used for real-time control, the experienced programmers I have talked to do prefer C++ for real-time control. These programmers also acknowledge that real-time control is an area where IEC languages still shine. Where platforms allow it, they will use Python for data handling and networking and IEC for real-time. There are also platforms that allow HLL code to be encapsulated inside IEC code to leverage the power of both languages.
The ability of C++ to create data logs helps with the convergence of IT and OT by being able to utilize the more standard IT data pipelines rather than using the more proprietary pipelines that have developed for OT databasing methods. There are libraries that speed up the implementation of data logs and allow more flexibility in crafting the wording and content of these logs. Also, the growth of services like Datadog and Elastic, which can chart, monitor and analyze your data, are creating a demand for the type of datalogging that can be done with C++.
Ted Thayer, principal product specialist for control systems / Phoenix Contact
Modern languages can provide better built-in security
Change is a risk, so it is understandable why end users and their management teams can be slow to adopt evolving technologies. In many cases, if current practices are working, then there is little perceived incentive to change and accept risk.
But by modernizing, and using more contemporary programming languages, industrial companies will drastically increase the pool of potential employees. There is little educational emphasis on IEC 61131-3 languages, so the availability of pre-trained candidates is growing very slowly or perhaps dwindling, making it harder to find good people. On the other hand, the educational system is producing graduates with training in more modern languages like C++.
From a cybersecurity perspective, modern languages provide a better degree of built-in security capabilities. C++ data logs are one example, which users can fit into their environment to provide better security. There is no portion of an industrial network exempt from cybersecurity considerations, because if malicious actors get a foothold anywhere, then they can inflict damage.
Steve Rawlins, Sr., CISSP, lead product cybersecurity officer, controls and software business / Emerson Discrete Automation
For more answers to this question, click here.