PLC vs. Arduino for industrial control

Can a $20 micro-controller equal a PLC for a real-world industrial control application?

By Doug Reneker, circuit designer

The “maker” world of basement robot builders continues to grow, with companies developing hardware and software to support all sorts of interesting applications. A number of micro-controllers have emerged to perform a wide variety of functions at very low upfront hardware and software costs.

A large number of boards, including micro-controllers, field programmable gate arrays (FPGAs) and single-board computers, have emerged. Among these, Arduino and Raspberry Pi are two leading names (Figure 1). Both are open-source devices, with components available from a variety of suppliers, and both require a high level of programming skills and some imagination before they can be used for real-time industrial control applications.

Some industrial users might envision these platforms as a substitute for an entry-level PLC. After all, if an Arduino can control a robot for a STEM competition entry, why can’t it control an industrial robot, or a simple machine? If it’s possible to buy an Arduino for as little as $20, why spend hundreds on a PLC? An Arduino can do lots of things, but as I discovered, making it work in even a simple industrial application is easier said than done.

WEBINAR: PLC vs. Arduino - Register for the interactive demonstration on 9/20

Real-time industrial control with an Arduino

The Raspberry Pi is effectively a miniaturized Linux-based single-board PC, whereas an Arduino is more like a PLC. While either platform looked suitable, I settled on the Arduino for our project: closed-loop control of flow generated by a pump. A sensor measures flow and sends data to the Arduino, which adjusts a control valve actuator to maintain the setpoint. This is one of the most basic industrial analog automation functions and often uses a PID loop as the control algorithm.

The Arduino uses PI control capability—it doesn’t need derivative for this type of loop—to read the signal from the flowmeter and adjust the valve to reach and maintain the setpoint. The concept is simple enough, but, when working with real-world industrial equipment, it gets more complicated.

The Arduino is a bare-bones device, as befits its price, but it does have extensive capabilities if the right program can be written to match the application. It’s a totally blank slate for a programmer, with no native capabilities or function blocks ready to upload, so I had to create the PI algorithm from scratch.

It has both discrete and analog I/O; however, the selections are limited. Analog inputs are 0-5 V, and the analog outputs are pulse-width modulation (PWM). This is suitable for regulating the speed of a motor or for modulating a temperature control loop, but not so good for many other applications. Most industrial analog instruments and actuators are designed for 4-20 mA current loops, so this standard was used in the demonstration project, requiring quite a bit of design and engineering effort.

Dealing with current loops

The demonstration equipment uses standard off-the-shelf industrial components: A Rosemount 3051SFP Integral Orifice flowmeter and Fisher Easy-Drive control valve, both provided by Emerson Automation Solutions (Figure 2). These were not selected for any specific capabilities or characteristics beyond their physical size. They are both very common types of devices, making them very appropriate for this demonstration.

The first step is converting the 4-20 mA signal coming from the flowmeter to 0-5 V, or better, 1-5 V to retain the live zero. This is not an uncommon situation, and converters are available from multiple sources. However, in keeping with the DIY character of the experiment and to keep costs down, I created one from scratch (Figure 3). It was built on an Arduino prototype shield to mount on top of the main board. A simple 250-Ohm resistor converts the 4-20 mA signal to 1-5 V.

The more challenging task was converting PWM to 4-20 mA. The lack of commercial solutions suggests this isn’t a common conversion, so I had to build this converter from scratch (Figure 4). I decided to electrically isolate the 4-20 mA current loop output using a two-channel optoisolator to allow more flexibility in connecting with other current loop devices. This leaves the problem of powering the circuit, as it is isolated from the power supplies. This was solved by powering the circuit from the current loop itself, using a voltage-reference integrated circuit.

Arduino PWM outputs run at 500 Hz. A low-pass filter removes the 500 Hz signal and its harmonics, resulting in a dc signal proportional to the PWM duty cycle. A second-order Sallen-Key active filter was designed with a cutoff frequency of 7 Hz to provide sufficient attenuation of the 500 Hz component.

An operational amplifier (op-amp) is used to convert the low-pass filter output to current. Keep in mind that all the power supply currents—for the op-amps, voltage reference and optoisolator outputs—need to be less than 4 mA, as they must flow through the current loop. The resulting isolated output requires a maximum of 10 V from the 4-20 mA current loop for power, so it works quite well in a 24 V system. There was sufficient room to fit all the signal converting circuits on the same shield.

Basic infrastructure support

An Arduino has no power supply, nor does it have any type of human-machine interface (HMI), but it can use a small graphics display shield added to the stack, with a screen size of about 1.75 by 2.25 inches. Custom programming is required to provide useful information, unlike a PLC, which will typically have multiple HMI options requiring only simple screen configuration. Wire mounting is also rudimentary, so connecting the external devices takes some doing. Mounting the Arduino boards requires creativity since there is no enclosure, nor any handy options such as a DIN-rail mount.

For the demonstration project, I used a standard 24 Vdc power supply suitable for powering the flowmeter and control valve, but the voltage had to be stepped down with a simple linear regulator to 12 Vdc to power the Arduino (Figure 5).

Writing code to implement the PI algorithm on the Arduino had to be done from scratch but was relatively simple. The current loop input is read, the difference between the setpoint and the input evaluated, the integral and proportional corrections are calculated, and the result is sent to the PWM current loop output.

To view operation, I wrote a program to use the small display to indicate both the process variable—read via the current loop input—and the control output as a function of time. This provides a direct view of the performance of the control system.

The Arduino provides several analog inputs, so three more analog inputs were connected to potentiometers to adjust the operating factors (Figure 6). One controls the setpoint of the controller, allowing the water flow to be controlled at the turn of a knob. The two others provide the proportional and integral gains for the control loop and are manipulated to balance stability and response time. None of them have any scale or engineering units to indicate the setting.

Ready to run

The flowmeter has a default local display (Figure 7) showing the flow rate in gallons/minute (GPM) and differential pressure (dP) in inches of water to provide external indication of loop functionality. The PI algorithm performed as expected, and the loop can be tuned by manipulating the potentiometers to adjust the two control factors. Flow control exhibited the normal characteristics, good and bad, of PI loops.

There is a flow bypass valve, which can be used to cause changes to the process, forcing the loop to adjust the valve to maintain the setpoint. I created a program so the display can show a working representation of the loop (Figure 8); however, with the display’s size, it requires some effort to read.

The PWM-to-current-loop converter is the main bandwidth limitation. The necessity to use a low cutoff frequency to adequately filter the PWM limits how fast the Arduino can respond to a change in conditions. The 100 ms (10 Hz) sampling interval works well, once the proportional and integral gains are adjusted. If the bypass valve is open, it robs roughly half of the input flow from the system, but the Arduino adjusts the control valve to achieve the desired flow within a few seconds. With steady water flow, the system is stable, without any indication the control valve is making adjustments.

Naturally, the Arduino has no concept of the engineering units it is dealing with, but then neither does a PLC. It is simply dealing with the current values, which is really all it has to do. Operators may want to see gallons or percent open, but it is not necessary for the controller.

Most industrial-grade equipment, like a PLC, is designed for use in potentially hostile environments where operation is critical and must be continuous. It can’t break down and quit simply because the plant gets a little too hot or cold. Most Arduinos are not built with this in mind. More industrial-grade units are emerging as are rated enclosures, but this consideration should be part of any analysis.

Real-time industrial control with a PLC

The second phase of the demonstration project used a basic low-end PLC, in this case a BRX (BX-DM1E-10ED23-D) from AutomationDirect. I came to this project with no prior experience with PLC programming or knowledge of ladder logic, making the comparison with Arduino objective, albeit more challenging than it would have been for an experienced PLC programmer.

The PLC has one analog output and one analog input, both configurable for 4-20 mA current loop operation, along with several discrete inputs and outputs. Programming access to the PLC is from an external Windows PC via Ethernet. The first step was downloading and installing the Do-more Designer software on a PC, a free download from www.automationdirect.com.

Once the software was installed, the PLC was connected to the PC with an Ethernet cable and powered up with 24 Vdc (Figure 9). A quick “ipconfig” command on the laptop revealed the Ethernet address of the laptop. A different IP address on the same subnet was programmed into the PLC via the Do-more Designer software.

The next step was learning a bit of ladder logic coding. Chapter 10 of the BRX PLC Hardware User Manual includes a step-by-step example of programming a simple timer using ladder logic. Working through this exercise provided a nice introduction to the software and to the basic programming structure of the PLC.

The analog input and output were configured for 4-20 mA current loop via the software. This was much easier than designing and building the current loop interfaces for the Arduino. After writing a couple rungs of ladder logic, a dc milliammeter verified the function of the output.

The PLC offers a sophisticated PID instruction, allowing the various loop parameters to be set for manual or automatic control of the loop. A very simple control loop was created by connecting the analog output back to the analog input, again using the milliammeter. Associating the PID instruction with the scaled analog input and output allowed the PLC to learn the PID function without handling several gallons of water. Active PI control was verified by “robbing” a bit of the output current with a resistor and watching the BRX PLC compensate.

Armed with this capability, it was time to integrate the PLC with our flow control loop. Connecting to the flow sensor was straightforward, with the 24-Vdc supply providing excitation for the flow sensor current loop. The control valve was even easier because the PLC current loop output provided the necessary excitation.

Firing up the system, it was a simple matter of using the Do-more Designer software to adjust the proportional and integral coefficients of the PID function to achieve stable flow through our system. Adjusting the flow was straightforward, with the setpoint adjusted via the Do-more Designer software.

The PID features of the Do-more Designer software provide self-scaling plots of both the process variable and the control variables, allowing clear, real-time monitoring of system performance.

Beyond the basic, core level of operation, the PLC offers a wide variety of the common support functions often needed in an industrial application such as limit detection, reporting and data recording. Compared to our Arduino demo, where each function must be written from scratch, this PLC allows the system designer to focus on the application and how it fits into a larger production system, instead of the details of controller hardware and software.

ALSO READ: New technology pushes machine smarts to the edge

Make or buy?

So, which is better, the Arduino or the PLC? If only bare hardware cost for the controller and I/O are considered, the Arduino wins. But when all the ancillary components necessary to make the Arduino useful in this relatively simple application are added, the hardware cost gap will narrow or disappear. The time necessary to assemble and program the Arduino is also considerable. When this time is calculated at anything near normal engineering man-hour rates, the PLC is the clear winner in terms of overall cost.

Regarding performance, the Arduino and the PLC both did the job.

Although our project only looked at controlling a simple flow loop, most industrial applications will require a variety of other discrete and analog control functions. With a PLC, many of these are built in, but none are with an Arduino.

Someone experienced in C language programming might find the Arduino a quick study, but even the most basic industrial functions will have to be written from scratch. Someone who has never programmed either type of controller will have some work to do with either platform.

However, the number of online and other tutorials available for PLCs certainly weigh in their favor as they are aimed specifically at industrial users, with many function libraries available for downloading to perform common operations. For example, the PLC has loop-tuning software available, which would be very complex to write for the Arduino.

Equipment durability certainly weighs in favor of the PLC until more industrialized Arduino and Raspberry PI devices emerge. At the same time, most PLCs are part of product families, offering scalability and breadth of native capabilities, making it much easier to expand. PLCs with add-on I/O modules, HMIs and other ancillary equipment designed for mounting inside control cabinets will be far easier to work with and more time-efficient than Arduino or Raspberry PI platforms.

For someone learning the basics of code writing and concepts of control, the Arduino and its ilk provide interesting teaching tools. Having to write control algorithms from scratch causes a user to consider the intricacies of how automation is performed. The availability of devices with this level of sophistication at such low costs is quite remarkable and is a boon to those with more time than money.

But for an actual industrial application where production and revenue are at stake, a PLC with equivalent or better capabilities can be had for a few hundred dollars, and it will come with extensive online training videos and other information, and with function block libraries designed specifically for industrial applications.

Show Comments
Hide Comments

Join the discussion

We welcome your thoughtful comments.
All comments will display your user name.

Want to participate in the discussion?

Register for free

Log in for complete access.

Comments

  • Fun article! One note though - there are a lot of libraries written for Arduino, including an excellent one for PID loops: osPID. Very easy to use, and it has an auto tune feature available if you want to use one. Otherwise, www.controlguru.com is an excellent source for information on how to tune PID loops based on measurement of your process.

    Reply

  • Really cool article, Doug. We tinker with Raspberry Pi and microcontrollers here in the office, and I've been wondering about the feasibility of using an Arduino for industrial/control use. I assumed the necessary steps needed to make them 'industrialized' would be time and cost prohibitive, and your article really put it all together. Thanks!

    Reply

  • This is great. My teenage son and I want to recreate your work here but with the PLC option ;) I see you have the Easy Drive Control valve to maintain the programmed flow rate and you have the Rosemont SPF for flow measurement. What pump are you using to initiate the actual water flow? The Rosemont SPF is very expensive. Can you please recommend a specific cheaper alternative? Specifically, what software should we obtain to program the PLC for automating the two devices? Any specific part numbers and details would be greatly appreciated. Thank you! Tom

    Reply

  • Thanks for the comparison Doug. You mention several times that the PLC was simpler and given the application I completely agree. PLC manufacturers have decades of industry specific experience behind them, including those darn control engineers that only know ladder. Being in the mid-west, the hardware experience also narrows to our friends in Wisconsin. Playing devil's advocate, the same type of article could be written regarding home automation, except the hardware roles reversed. I could see replies to that article go something like this "but I just wanted to write a few lines of Python or Lua to send my sensor values to my processing stack" or "wait this big box runs on 24V and does not have wifi built in". But of course, home automation lacks safety concerns and tight loop control because we're not actuating a machine that could crash and cause personal injury or thousands of dollars in downtime and repairs. Where we have found the perfect place for Arduino, RPi, ESP8266/32 is non-critical applications. Being in IT, I try to invite myself to process improvement events at our company and educate the team members on ways we can automate some of their non-critical tasks. To me, making users aware of alternatives, rather than reaching for that Automation Direct catalog, has been priceless.

    Reply

  • I agree with your article. The main problem for Arduino is the reliability for use in the industry, which has an aggressive enviroment (powder, high temperature, vibration, etc), and the components doesn't support this for long time as PLC supports.

    Reply

  • This was a great article but it unfairly compares two different platforms to fill a specific application. Arduino and Raspberry Pi are development platforms and suited for creating and proving concepts not finished solutions. If you are an industrial customer building your own infrastructure then go PLC which will have the range of rugged components with which you can customize complete solutions to satisfy a great majority of your needs. If you are the kind of industrial customer who is implementing highly intelligent control systems but will not create or customize anything then you will have the best option using solutions that were third-party-developed on open source software and hardware. If you do the later, expenses will be mostly in services than tangible goods which is more economical for a business than having in-house expertise to support those systems. In the end the solutions in these articles really serve two different roles. The Arduino solution fails short term but the solution can scale at a greater savings than the PLC.

    Reply

RSS feed for comments on this page | RSS feed for all comments