How we used Linux

How we used Linux

Introduction

Industrial Automation is an industry that's always 10 years behind mainstream technologies. This is partly due to the large monopoly held by the three main players, Siemens, Allen Bradley & Wonderware. This has led to an unfortunate lack of innovation, especially in native industrial web applications, Which are almost nonexistent.

At Bubble Automation we saw this as an issue. Most clients who wanted remote monitoring capabilities of their sites were stuck using clunky add-ons. Add-ons requiring large license fees and maintenance costs, or insecure TeamViewer/VNC connections needing third party tools to be installed on the clients machines.

Our Aim

We wanted to build a modern secure native web application that required no browser or PC plugins. Need to provide live data and work on any device e.g mobile, tablet, netbook & desktop to prevent the need for unnecessary platform dependant apps. For security, the web server had to be on the customer's premise, small enough to be put in a control panel and robust enough to survive industrial conditions.

Choosing the Framework

NodeJS was the first framework we tested, it seemed promising but at the time wasn't the most stable or well-supported platform. The biggest issue was connecting to a database using their experimental database module.
After trial and error with various frameworks, opting for a pure Python solution seemed most convenient partly due to our in-house python experience, but most importantly its wide module support.

Selecting the Right Hardware

After a very brief experience using current industrial grade single board computers, it was immediately obvious they weren't suitable. Most use out-dated Intel Atoms in large noisy enclosures. This sent us on the path of today's competitive credit sized PC market, listed are a few we've tried:

  • Raspberry Pi 2 Model B
  • Raspberry Pi 1 Model B
  • ODROID-U3
  • Odroid C1
  • Odroid XU4

Each board was extensively tested running our Python framework with unrealistic loads. The board that stood out was the ODROID XU4 which was clearly superior all round as shown in the benchmarks below. This board had far better CPU and network performance, but most importantly much higher I/O speeds and bandwidth which was critical for our MySQL database.

dhrystone

dhrystone-rp2-c1-xu4


Results are an index relative to a SPARCstation 20-61 (rated at 10.0)
Source

whetstone

whetstone-rp2-c1-xu4


Results are an index relative to a SPARCstation 20-61 (rated at 10.0)
Source

hdparm

hdparm-rp2-c1-xu4


Results are in megabytes per second.
Source

dd

dd-rp2-c1-xu4


Results are in megabytes per second.
Source

Architecture & Software Design

The basic starting point was to create a daemon that could read Modbus registers over TCP/IP from the field as shown in figure 1. This later grew to a context sensitive event based system that could translate field events into Alarms, Live Trending, Historical graphs, Event logs, & notification emails.

pymodbus-diagram-1


Figure 1.

Providing this information to the client proved to be a difficult task; displaying Real Time information on a web page in pure HTML5 requiring no plugins has never been easy. Using techniques such as long polling would only lead to crashing the browser as there was just far too much information that needed to be fed into the browser at relatively high speed, at around 1-second scan intervals.

Our solutions came back to the reason NodeJS was such a good candidate for Real Time data solutions, that was Web Sockets. This provides full-duplex communication over a TCP connection. Thankfully we came across a powerful PHP Library that provided this functionality.
For this reason, we could build all server side components in PHP using Twitter Bootstrap to provide a simple interface with responsive design at its forefront.

A LEMP stack (Linux, Nginx, MySQL, & PHP) is used to provide a robust base with speed, stability, & reliability for our PHP, HTML, & Javascript front-end. The main reasons for using Nginx over Apache is its better utilization of multicore processors assigning a worker per core, and its better security track record over Apache.

pymodbus-trends-tablet


Front-end on tablet

Security

Due to the nature of our industry, building our application secure by design was critical. A lot of time was spend creating a secure login not vulnerable to SQL Injection, Session Hijacking, Cross Site Scripting, & Brute Force Attacks. To top this off we created a hardened minimal Linux image to use on our servers this is kept up to date with all of the current security patches.
We work strictly on a non-control basis meaning in the unlikely event our software is compromised, there is no way the intruder could damage your site. Our software only monitors the state of the field and does not affect the control process.

Conclusion

Thanks to the high availability of small inexpensive single board computers and the large progression in Open Source software development, Bubble Automation has managed to bring innovation to an industrial market which is usually slow to take on modern ideologies.
Our choice of using an Open Source foundation has eliminated expensive licensing fees and running costs for us and our clients giving our software a competitive edge.