Humble Arduino As PLC

On the surface, a programmable logic controller (PLC) might seem like nothing more than a generic microcontroller, perhaps outfitted to operate in industrial settings with things like high temperatures or harsh vibrations. While this is true to some extent, PLCs also have an international standard for their architecture and programming languages. This standard is maintained by the International Electrotechnical Commission, making it so that any device built under these specifications will be recognizable to control engineers and maintenance personnel worldwide. And, if you use this standard when working with certain Arduinos, this common platform can become a standard-compliant PLC as well.

The IDE itself supports programming ladder diagrams, functional block diagrams, and other programming systems covered under the IEC 61131-3 standard. Not only that, it allows the combination of these types of PLC programming with Arduino sketches. The system offers many of the perks of PLC programming alongside the familiar Arduino platform, and supports a number of protocols as well including CANOpen, Modbus RTU, and Modbus TCP. It can also be used for monitoring a PLC system, essentially adding IoT capabilities to existing systems, enabling continuous monitoring, debugging, and program updates.

While not every Arduino is a great platform to build a PLC around, there are a few available for those looking for a system a little less proprietary and a little more user-friendly than typical PLC systems tend to be. There’s a reason that PLCs are built around an international standard and generally have certain hardware in mind to run it, though, and this comparison of a Raspberry Pi with an off-the-shelf PLC goes into detail about why certain components aren’t good choices for PLCs.

33 thoughts on “Humble Arduino As PLC

  1. As a industrial controls engineer that has worked globally, keep the arduino in hobby zone where it belongs. There are machines running with 20, or 30 year old control systems that are PLC controlled. Not an ideal situation for support , but us old guys know them and can deal with them as they were designed for the industrial environment. My little six axis robot arm with arduino is great fun, but much harder to program and troubleshoot than any PLC based system.

    Just because you can, doesn’t mean you should

    1. One thing that trips people coming from Arduino/PC background with PLCs is that it’s a slightly different paradigm, because the original idea of a PLC is to emulate a ladder logic system that typically has synchronous inputs and outputs and a “cycle time” you should maintain. Twiddling the IO at random times gives you unpredictable behavior and an Arduino is doing things in the background which can mess up your timing or the order of your logic – though usually it’s not that critical. Still, you don’t do busy-waits, you don’t do locked conditions etc. Everything should run steadily and the logic of the circuit is evaluated all before the outputs are set.

      One of my questions when first introduced was “What if your program doesn’t complete within the cycle”, and the instructor answered “You allocate more CPU to it, so it does.” I didn’t get it, and kept insisting “But what if I have a loop that takes longer…”, and he just kept saying “You put more CPU on it.” How do you do that? What he meant was, you just don’t do something that takes longer than the cycle because that’s not how it’s supposed to work. You split it up over multiple cycles.

      With that in mind, an Arduino is perfectly usable as a PLC – it’s just not going to be very fast or down to the microsecond.

      1. >> an Arduino is doing things in the background which can mess up your timing or the order of your logic

        A base Arduino does not do a whole lot of things in the background. There’s a timer triggering an interrupt to give the millis() count, but not much more than that. Everything else is under the programmer’s control.

        >> it’s just not going to be very fast or down to the microsecond.

        That would depend on what you mean by “Arduino”. If you’re talking an UNO, sure – it’s not all that fast (for modern standards), running at 16 MHz. However, “Arduino” can also mean a Portenta H7 running at 480 MHz on one M7 core and 240 MHz on a second M4 core, and you can stretch the term to also include a Teensy 4 at 600 MHz. With no underlying OS to deal with, consistent timing to the microsecond level with either of those is easy – I’ve seen people get timing down to +/- .5 ns with a Teensy, which pretty much comes down to the slew rate on the output transistors.

        Someone else mentioned the Arduino Opta, which has the same dual-core microcontroller as the Portenta, and is sufficiently rugged for an industrial environment.

    2. With the growing number of available “professional” arduino compatible modules, I guess that what we may see in the field will be a slow creep – first it’ll be small-scale low budget startup kinds of applications, but then as some platforms will hopefully prove themselves reliable enough, economic incentives will lead to adoption of Arduino in more serious settings.

      1. There are “ruggedized” Arduinos available, and some models that are packaged in a typical rail mounting shell with isolated IO, and yet others that are real PLCs running Arduino compatible software.

    3. If you look at it the other way around, allowing people with little experience in programming to automate their projects with something as intuitive and reliable as ladder logic can only be a good thing. I don’t think the idea is to bring the Arduino to industrial automation. The idea is to bring the benefits of industrial automation to everyone else.

    4. Don’t be such a grinch. There are plenty of applications for non-name brand PLC tasks. It is exactly the same as using any custom HW/SW to do a task if it fits the task. Using PLC languages and idea is no different than using any programming language/system in that if it works, it works.

      There’s already hundreds, if not thousands, of brands of PLCs and other industrial control tech, that you will never know all of them anyway. If you are faced with one, then you either learn it, or give the job to someone else. This only makes it easier in that it isn’t C or C++ or Python you need to learn first.

      There are also hardened arduino compatible boards available for multiple sources.

  2. The ones I opened up have all been FPGAs at their core. The old Russians at work would laugh at me when I’d get the controllers doing math for one reason or another on this old bottle capping machine we were updating “Now you…..you… watch for smoke..heh..heh…” which probably says more about Soviet industrial controllers than anything.

    1. Open PLC is based on Beremiz, i do not know if Arduino PLC IDE uses it too or some other commercial environment or their own.

      For “simpler” stuff and limited to ladder language, there is also LdMicro, but there hasn’t been a release 2 years.

  3. A PLC is more than just a device that can run a program written in the IEC 61131-3 standard. First of all the hardware needs to be very reliable(safety, security) and certified. And second it needs to support a variety of protocols/standards, some of which are closed standards. This also needs to be reliable and certified. And third the tools need to be reliable and certified. I cringe that the website says these “PLCs” are suited for aviation.
    I don’t like the fact that current PLCs are closed and proprietary and would prefer if they make things more open. But you pay for an ecosystem that provides you with support of a wide range of applications and reliability.

    1. Hardware/software does not need to be certified non-safety applications. The only reason procotols/fieldbus systems need to be certified is because the organizations in control of them require that. Pretty much the only reason you could get in trouble with them is if you use the name, which is for sure trademarked, and because of possible patents. But like Modbus is pretty much lost to the free market.

      And the client might require certifications too, but if not. It’s on you if the device breaks, you take the chance, if you sell it to someone.

      I do not know which environment Arduino PLC IDE uses as a base, but you can buy and customize complete environments, for example Codesys, ISaGRAF and GEB Automation IDE. Beremiz is an open source environment which has been used for an IDE for few commercial products and Open PLC.

      Safety applications is another ball game. But for example for non-PLC type of deal, Microchip has safety certified chips and environment for some of their products.

      As for aviation, i don’t know any drone that uses safety critical hardware/software. They use microcontrollers just like billions of other devices with 0 duplications or memory checks.

      There are plenty of tasks you can do with these smaller “custom” PLCs that do not require bigger name brand PLCs, even for industrial applications. It’s exactly the same thing as using anything custom built with any kind of hardware/software. The mega corporations to not have full control of everything yet.

  4. It always depends on what one wants to achieve. For some simple garden watering, bbq smoker or garage door controls, an Arduino is a perfect, cheap and easy to use platform. And turning it into a PLC is as easy as turning it into a weather station or light string controller.

    NANO based PLC:
    http://www.universal-solder.ca/26442

    MEGA2560 based PLC:
    http://www.universal-solder.ca/26995

    Whoever claims only a Siemens or Allen Bradley is a true PLC did not understand the definition of “programmable logic controller”

  5. “To program with IEC 61131-3, you will need to unlock the hardware with a lifetime license key, available on our Store.”

    Umm… so one needs to fork over 16€ for every controller? Fine by me for commercial stuff as you can simply add that to your bill if the costumer wants that, but not very hacker friendly i would say.

  6. For the fans of the STM32, you may want to have a look at the X-Nucleo-PLC01A1 board (https://www.st.com/en/ecosystems/x-nucleo-plc01a1.html) and the firmware available with it, STEVAL-PLC001V1 (https://www.st.com/en/evaluation-tools/steval-plc001v1.html). Previous comments have raised the appropriate need for robust I/O. In this case, the board has galvanically isolated the PLC control unit. The micro itself is the STM32F746ZGT7 which is an industrial temperature grade, Cortex M7 core running at 216MHz. There are 12 inputs and an additional 12 outputs available for your design. Best of luck.

  7. I purchased an air dryer for an ozone water treatment and the microcontroller/relay a little after two years. I replaced it with an Arduino nano and a solid-state relay in the same cabinet and is still working after five years. I believe it could turn on pumps, heat, conveyors… As far as I know there is no common GUI to control it, not that it couldn’t be done, It is not my cup of tea.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.