element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Project Videos
  • Challenges & Projects
  • element14 presents
  • Project Videos
  • More
  • Cancel
Project Videos
Documents Building a DIY PLC with PocketBeagle 2: Finding Out Why Industrial Controllers Cost So Much
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Project Videos to participate - click to join for free!
Related
Recommended
Engagement
  • Author Author: cstanton
  • Date Created: 19 Aug 2026 5:15 PM Date Created
  • Last Updated Last Updated: 20 Aug 2026 4:28 PM
  • Views 142 views
  • Likes 3 likes
  • Comments 6 comments

Building a DIY PLC with PocketBeagle 2: Finding Out Why Industrial Controllers Cost So Much

Can you really build your own industrial PLC, or are commercial controllers expensive for a reason? In this project, Clem sets out to answer that question by designing and building a PocketBeagle 2 based PLC from scratch, starting with a simple maker-friendly prototype before tackling the realities of industrial design, including electrical isolation, ESD protection, USB compliance, analogue signal integrity and realtime control. Along the way he explores the AM6254's Linux and PRU architecture, wrestles with device tree overlays, exposes the board's onboard 12-bit ADC, and finishes with a live colour-detection demo that combines analogue inputs, USB vision and network streaming. Most importantly, the project reveals where the real engineering effort in industrial hardware lives, and why a reliable PLC is far more than just a computer in a DIN rail enclosure

Watch Clem Pocket the Industrialisation

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Clem has always had a healthy suspicion of expensive industrial hardware. Looking at the price of programmable logic controllers (PLCs), his initial reaction was much the same as many makers staring at a catalogue of industrial equipment: surely there cannot be that much inside a PLC to justify the cost.

Rather than speculate, he decided to build one.

The result is a PocketBeagle 2 based PLC project that starts out as a straightforward maker build and gradually evolves into something much closer to a genuine industrial controller. Along the way, it becomes a lesson in electrical isolation, PCB layout, device tree configuration, realtime processing and the countless small decisions that separate a prototype from a product.

As Clem puts it:

"Sometimes they are actually just an Arduino in a fancy box and some relays... but there are also legacy systems with big brand names and high price tags and these are built for reliability."

His goal was not to reproduce an industrial PLC exactly, but to understand where all that engineering effort goes.

image

Starting with an Open PLC Platform

Commercial PLCs often come with proprietary software ecosystems, vendor lock-in and long-term support guarantees. Clem wanted to approach the problem from a different direction.

Instead of using a dedicated PLC platform, he based his design around the PocketBeagle 2, a compact Linux-capable development board built around Texas Instruments' AM6254 Sitara processor.

What attracted him was the combination of high-level Linux functionality and low-level deterministic control.

"I wanted it to have serious capabilities. It should have realtime Linux support and it also should have a deterministic way of controlling the inputs and outputs."

Unlike many maker boards, the PocketBeagle 2 includes two Programmable Realtime Units (PRUs), effectively dedicated microcontroller-class cores integrated into the processor.

These can operate independently from Linux and are designed specifically for tasks that require predictable timing.

"We have the Linux controls around USB devices, high-level stuff like AI models and communication with networks and other devices, and then the PRUs can control all the inputs and outputs."

The AM6254 architecture immediately begins to resemble the split architecture found in many industrial systems. Linux handles networking, storage and complex applications while dedicated realtime processors handle machine control.

Clem even points out that the second PRU could act as a watchdog, redundancy controller or cross-checking processor, similar to techniques found in safety-oriented industrial equipment.

image

Version One: The Maker Approach

The first PLC design intentionally follows the path many hobbyists would take.

A Hammond DIN rail enclosure serves as the mechanical foundation, while a relatively simple two-layer PCB carries the electronics. The board includes:

  • PocketBeagle 2 controller
  • Microchip USB2514 USB 2.0 hub controller
  • Four analogue input channels
  • Four relay outputs
  • ULN2003 Darlington relay driver
  • Dual USB host ports
  • DIN rail mounting format

The PCB itself was designed quickly.

"I eyeballed the position of all the connectors and I tried to put as many features in here as possible."

Rather than spending days optimising every mechanical detail, the focus was on getting something functional into the enclosure as quickly as possible.

One feature Clem was especially keen to exploit was the PocketBeagle 2's integrated twelve-bit ADC. Unlike a typical Raspberry Pi, analogue inputs can be connected directly to the processor without requiring additional converter hardware.

The analogue channels are exposed through simple screw terminals, providing an easy way to interact with sensors and control inputs. The USB subsystem was another area where the project deliberately pushed the platform. By integrating the USB2514 hub controller, the PLC gains multiple USB ports for cameras, storage devices and peripherals.

On paper, it looked remarkably capable. Unfortunately, industrial design concerns do not appear on a schematic until something goes wrong.

image

When "Works" Isn't Good Enough

The first design functions. For many projects, that would be a success.

For a PLC, however, functionality is only the starting point.

Clem soon began identifying weaknesses that would become serious problems in an industrial environment.

The first issue was electrical safety.

"There is no real isolation in the original design. In case something goes wrong there could potentially be 230 volts everywhere in the system."

The relay outputs are capable of switching mains-voltage loads, yet the control electronics existed dangerously close to circuitry carrying higher voltages.

Industrial equipment depends heavily on segregation between control electronics and power electronics. Without that separation, failures can have consequences far beyond a damaged PCB.

The USB implementation also lacked many of the protections expected in a commercial design.

The original version provided only the minimum necessary circuitry to make the USB hub operate.

There was:

  • No ESD protection
  • No overcurrent protection
  • No controlled fault response
  • No dedicated USB power monitoring

These omissions are common in maker projects because they are often invisible during normal operation. Industrial equipment, by contrast, must survive repeated abuse from the outside world.

Analogue routing presented another problem.

"I've routed my analogue ports right next to the relays. That will not work very good because they will couple into it."

Relay switching generates electrical noise. Placing sensitive ADC signals next to relay circuits creates opportunities for incorrect readings, instability and potentially damage.

These are exactly the sort of layout considerations that are easy to overlook when the first goal is simply getting a board manufactured.

image

Building a More Professional Controller

The second board revision demonstrates how quickly extra engineering effort accumulates.

Clem moved to a four-layer PCB, improved component selection, reworked the enclosure integration and fundamentally redesigned the relay section.

More importantly, he stopped trying to maximise feature count and instead prioritised reliability.

"I preferred having good layout instead of more features on there because that is what the professional world considers the most important bit. Safe and reliable operation."

The revised USB implementation became significantly more sophisticated.

Dedicated current-limiting circuitry and fault detection were added to protect both connected peripherals and the PLC itself.

"These have current control chips specifically ordered and they have to detect if something goes wrong so your device that you plug into these USB ports can't destroy the overall thing."

This redesign required additional board area, forcing the reduction from four easily accessible USB ports down to two.

That trade-off between capability and robustness appears repeatedly throughout industrial design.

image

Isolation the Right Way

The most dramatic change involved the relay outputs. The revised PCB treats the relay circuitry and logic circuitry almost as completely separate systems. A dedicated isolation boundary divides the board into two sections. The only intentional signal path crossing that boundary is an optocoupler.

"An optocoupler is a way of galvanic isolation meaning there is no actual direct connection between these two halves. It is just and only a connection by light."

The relay control signals pass through an optocoupler before driving the ULN2003 relay driver.

This ensures that electrical disturbances from the relay side cannot directly propagate into the processor circuitry.

Even power supplies were separated.

Two isolated DIN rail power supplies were used: one dedicated to logic electronics and another for relay operation.

"We're truly isolated."

The resulting architecture begins to resemble industrial control hardware far more closely than the original all-in-one design.

image

The Device Tree Learning Curve

One of the most educational aspects of the project came from the software side.

Developers accustomed to Arduino or Raspberry Pi ecosystems often expect GPIO pins to work immediately.

The PocketBeagle 2 takes a more embedded Linux approach.

GPIO functionality must first be defined through device tree overlays.

"The apparently simple job of making a GPIO output starts involving device trees, pin multiplexing and the details of the underlying SoC."

Because the AM6254 allows pins to serve multiple functions, Linux must be explicitly told how they are being used.

Clem candidly describes the experience:

"Device tree overlays are very intimidating and complicated and I don't even halfway know what I actually did there."

Once configured correctly, however, the flexibility becomes apparent. Linux gains direct access to GPIO, ADC resources and other processor features while still allowing PRU-based realtime control.

That flexibility is one of the PocketBeagle 2's greatest strengths, but it comes with a significantly steeper learning curve than many maker platforms.

image

Working with the Onboard ADC

The analogue subsystem proved much more straightforward.

Clem exposed four ADC channels and demonstrated how Linux can read them directly through the Industrial I/O framework.

The Python implementation is refreshingly simple.

ADC_PATH = "/sys/bus/iio/devices/iio:device0"
VREF = 1.8
ADC_MAX = 4095

return (raw / ADC_MAX) * VREF

Raw readings are collected from Linux system files and converted into voltages using the 12-bit ADC range. The implementation continuously reads all four channels and reports both raw counts and calculated voltages.

This direct ADC access became a key part of the final demonstration.

image

A Useful Failure

Unfortunately, not everything worked perfectly.

One of the relay isolation circuits exposed a design mistake.

The optocouplers were treated like standard logic devices rather than LED-driven isolation components.

Current-limiting resistors had been omitted.

"With a 3.3 volt logic level I should have used a 330 ohm resistor."

The result was that the optocoupler LEDs never switched fully off once activated.

"Once the LED activates for the first time it sits there drawing current at about two volts and never deactivates again."

The relays therefore refused to operate correctly during the final demonstration.

Rather than hide the mistake, Clem used it to illustrate a reality of professional hardware development: unfamiliar parts frequently behave differently from assumptions made during schematic capture.

Testing, redesign and verification are fundamental parts of the engineering process.

image

Live Colour Detection Demo

For the final demonstration, the PLC uses its analogue inputs, USB subsystem, Linux environment and networking stack simultaneously.

A USB webcam streams video into OpenCV while two analogue channels control detection parameters.

One analogue input selects the target hue while another sets the intensity threshold.

The software converts ADC values into colour detection parameters in realtime.

application_hue = int(
    (raw / ADC_MAX) * 255
)

opencv_hue = int(
    (application_hue / 255) * 179
)

A value of 150 corresponds approximately to blue, allowing trim potentiometers wired to the PLC to tune colour detection while the system is operating.

The software analyses webcam imagery, performs HSV filtering, calculates contour sizes and overlays detection results on the live image.

Results are then streamed over the network using a built-in web server.

During testing, Clem adjusted the analogue inputs live while watching colour detection track the blue colour of his shirt.

"We can set the hue and the saturation with these analogue potentiometers on the fly and observe the stream over the network."

The demonstration neatly combines nearly every subsystem available on the PLC.

image

So Why Are PLCs So Expensive?

By the end of the project, Clem's original question had evolved considerably. The first board genuinely supports the argument that many PLCs appear to be little more than a processor, some I/O and a box.

The second board reveals the hidden engineering. Isolation barriers. ESD protection. Current limiting. Optocouplers. Power integrity. Analogue layout. Device tree configuration. Mechanical integration. Realtime processing. Redundancy. Testing. Verification.

None of these individually seem particularly dramatic. Together they account for a substantial amount of engineering effort.

"Now that we know how incredibly difficult it is to make a real PLC, a system that has redundancy, safety, watchdogs and all these constructive features to make the relays safe and all the connections and inputs reliable, I think we can appreciate that sometimes they just have to cost more."

That does not mean every industrial PLC automatically represents good value. It does demonstrate that the real complexity often lies in the details that nobody notices until they are missing. Clem set out to build a PLC to understand where the money goes. What he discovered is that making something look like a PLC is relatively easy.

Building something that begins to behave like a professional industrial controller is a completely different challenge.

Supporting Files and Links

- PocketBeagle 2 Documentation

- Device Tree Tutorial by Grippy98

-  Episode 728 Resources - Building a DIY PLC with PocketBeagle 2: Finding Out Why Industrial Controllers Cost So Much  

Bill of Materials

Product Name Manufacturer Quantity Buy Kit
Optocoupler, Darlington Output, 4 Channel, DIP, 16 Pins, 50 mA, 5.3 kV, 500 % ISOCOM 1 Buy Now
USB Connector, USB Type A, USB 2.0, Receptacle, 4 Ways, Through Hole Mount, Vertical multicomp 2 Buy Now
Wire-To-Board Terminal Block, 5.08 mm, 3 Ways, 30 AWG, 12 AWG, 3.31 mm², Screw würth 9 Buy Now
Plastic Enclosure, DIN Rail, Polycarbonate, 90 mm, 105 mm, 58 mm, IP20 Hammond 1 Buy Now
Pin Header, Board-to-Board, 2.54 mm, 2 Rows, 40 Contacts, Surface Mount Multicomp pro 2 Buy Now
Development Kit, PocketBeagle 2, AM6254, ARM Cortex-A53 / Cortex-M4F beagleboard 1 Buy Now
Flash Memory Card, MicroSDHC Card, 16 GB, Class 10, UHS-I U1, A1 integral 1 Buy Now
DARLINGTON TRANSISTOR ARRAY, SOIC-16 onsemi 1 Buy Now
General Purpose Relay, ORWH Series, Power, Non Latching, SPDT, 5 VDC, 10 A TE 4 Buy Now
AC/DC DIN Rail Power Supply (PSU), ITE, 1 Output, 15 W, 5 VDC, 3 A meanwell 1 Buy Now
AC/DC DIN Rail Power Supply (PSU), ITE, Industrial & Household, 1 Output, 15 W, 5 VDC, 3 A multicomp pro 1 Buy Now
USB Interface, USB Hub Controller, USB 2.0, 3 V, 3.6 V, QFN, 36 Pins microchip 1 Buy Now
ETHERNET ADAPTER, USB3.0 GIGABIT WHI 1 Buy Now
DIN Mounting Rail, DIN Mounting Rail, Racks & Cabinets, 1 m, 7.5 mm, 35 mm, Steel 1 Buy Now
TVS Diode, WE-TVS, Unidirectional, 5 V, 6.8 V, SOT-23, 6 Pins würth 4 Buy Now
 MIC2025 Microchip 2 MIC2025

Additional Parts

Product Name Manufacturer Quantity
Crystal and caps for the usb2514→ 24MHz
usb current control ICs + mosfets

  • plc
  • kicad pcb design
  • pocketbeagle 2
  • embedded linux
  • am6254
  • e14presents_mayermakes
  • analogue inputs
  • optocoupler
  • USB2514
  • industrial automation
  • diy plc
  • industrial control systems
  • programmable logic controller
  • ti sitara
  • friday_release
  • galvanic isolation
  • realtime linux
  • Share
  • History
  • More
  • Cancel
Actions
  • Share
  • More
  • Cancel
  • Sign in to reply
  • mayermakes
    mayermakes 45 minutes ago in reply to beacon_dave

    another way to do it. but it would require to power the board via AC and recitfy in each half, with step downs etc. the overall size is very constrained and that would put switching signals close to data lines which I would not want to do for singla integrity reasons. with the availability of capable DIN PSUS I did not see an advantage in that.
    you could wire the same supply to both halves but that would be unintended use and going against the (imagined) manual.. Allowing to independently power the halves also is great for implementation of safety cuttoffs (safety switches that cut power to actuator) without damaging the Logic controller or corrupting  its memory.

    there are for sure even more ways to do it all with their advantages and disadvantages

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes 55 minutes ago in reply to DAB

    thank you!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave 20 hours ago

    Would in not be safer to use a small internal transformer to provide galvanic isolation of power between the two halves of the board ? 

    With separate external power supplies, I can see someone wiring the same power supply to both halves.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB 23 hours ago

    Great episode Clem.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • cstanton
    cstanton 1 day ago

    Hey  SensoredHacker0 and  Em0ke , I'm interested to hear what you think of this as you both have familiarity with PLCs.  

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes 1 day ago

    this did cost me a nerve but it also led me down an embedded linux path I want to explore more!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube