Industries
October 26, 2023

PLC support: Giving access to industrial control systems

Pete Garafano
Consulting Engineer

The world of industrial controls is dominated by large, vertically integrated corporations, expensive hardware, and esoteric programming languages. This creates a large barrier to entry by requiring sizable capital expenditures and specialized software engineers to program these systems. As part of Viam's goal of democratizing access to smart machines, we have added support for the Revolution Pi line of PLCs from KUNBUS to the Viam platform.

The Revolution Pi takes a Raspberry Pi Computer Module and fits it into a DIN-rail mountable form factor. The module runs Linux, allowing you to run a wide array of widely available software, including Viam. When combined with the specially designed I/O modules available from KUNBUS, interacting with the world has never been easier. Instead of having to add relays or logic level shifters to interact with 24v signals, the I/O modules do this for you. They also provide strong guarantees around power on/off states of the I/O points as well as electrical isolation for the compute module. 

Adding Viam to your Revolution Pi opens up a world of possibilities for your industrial control project. Not only are you adding the world of Viam to your PLC project, you are adding access to a wide variety of industrial control components to the world of Viam. Now you are free to include things like video, ML Models, and internet data sources in your industrial control project. Oh, and you can program the whole thing in your favorite language, whether that is C++, Python, Go, or any number of other languages Viam supports.

How to use a PLC with Viam

Now that we know what the Revolution Pi is, and have an idea of what it can do, let's use it with Viam, as shown in the simple steps outlined below:

  1. Follow the Quick Start from KUNBUS to ensure you're running the latest software
  2. Configure the connected I/O Modules using the built in PiCtory interface on the Revolution Pi
  3. Install the viam-server
  4. Add the viam-revolution-pi module to your robot

Testing the Viam PLC setup 

Now let's test the setup. Open the Control Tab for the Revolution Pi on app.viam.com and expand the revpi Board card. From here you can get current pin states, or even toggle them on/off. Let's check the status of O_1:

Now turn it on by selecting "high," and clicking "Set Pin State."

You can check the pin state with a multimeter to confirm. Congratulations, you have just used Viam to interact with industrial control hardware!

How Viam PLC support works: The code 

You might say, "Well that's cool and all, but I'm not going to control my system from this basic UI, it's way too complicated." Well, you would have a point, so let's take a look at how this works from code, specifically using the example of Python.

First, let's head back over to app.viam.com and click the "Code sample" tab to install the viam-sdk in your Python environment. Next, copy the provided sample code, and be sure to click "Include secret" to make sure the viam-sdk can connect to the machine. I went ahead and made some modifications to the sample code to get what I have below:

First, we get a connection to the robot, and then we get a reference to the board named "revpi." From there, we can get a reference to the pin. Once we have this pin, we can begin to interact with it. This is in contrast to traditional PLCs, which typically handle I/O by directly interacting with memory addresses. However, this really isn't all that different; you can think of this as simply asking the system for the right memory address, instead of accessing hard coded values. 

So, what does our output look like?

As you can see, we started with the pin off, then we turned it on, and then turned it off again. Our output confirms this.
This is all well and good, but you might remind me that I said you can use multiple languages. Yes, that’s true, I did. So let's take a look at doing this with Go.

As you can see, the Go code is very similar to the Python code. It follows the same process, uses similar method names with some language specific parameters, and provides very similar output to our Python script:

How Viam compute offloading changes the game for ICS 

Perhaps you are now thinking to yourself: This is nice! I can hire regular software engineers to program my industrial control systems.

However, I've left one bit of interesting information out from my demos. None of my scripts have been running on my Revolution Pi. They have all been running on my desktop, controlling the I/O of the Revolution Pi, remotely, from a different state. 

This is part of the beauty of Viam. You can choose to run everything from a central location, or directly on the Revolution Pi itself. 

Why might you want to run your program on something other than the board with the I/O attached? Compute resources can be a big reason. If you need more compute power to run things like ML Models or OpenCV models, you can offload all the processing and commands to a more powerful machine, and not have to worry about trying to message commands to your I/O boards, you can do it straight from the code running the heavy processing

If this sounds interesting to you, I would highly encourage you to take a deeper look at Viam in 3 Minutes and Viam Security and Compliance.

twitter iconfacebook iconlinkedin iconreddit icon

Find us at our next event

Apr 15, 2025
Apr 15, 2025
,
03:00-04:00 PM EST

LIVESTREAM: Build a self-checkout with computer vision

Virtual
Build a real-time people detector using computer vision and a piezo buzzer with Adrienne and Nick from Viam's DevRel team in this hands-on livestream.
Watch live!
Apr 17, 2025
Apr 17, 2025
,
06:30 - 09:30 PM EST

NY Hardware April 2025 MeetUp

In Person
1900 Broadway Floor 6 New York, NY
Join us at the Viam office for the next NY Hardware Meetup! Viam Product Manager, Esha Maharishi, will be doing a live demo, and there will be plenty of time to connect with fellow hardware enthusiasts. Whether you're deep in the industry or just curious, come by for great conversations, hands-on tech, and free food and drinks!
Sign Up
Apr 22, 2025
Apr 22, 2025
,
06:00-8:30PM EST

Flutter NYC + iOSoho MeetUp

In Person
New York, NY
Flutter NYC and iOSoho are teaming up for a special co-hosted Meetup at Viam! Join us for an evening of mobile talks, networking, food, drinks, and exciting door prizes—including FlutterConUSA ticket raffles and exclusive swag.
Register Now
May 6, 2025
May 6, 2025
,
07:00-09:00 PM EST

Elastic New York Meetup

In Person
New York, NY
Monitor and automate the physical world with Elastic and Viam. Join us for a demonstration of gathering data from a fleet of sensors, visualizing it with Kibana, and creating alerting rules that trigger in real life.
Secure your spot
May 5, 2025
May 7, 2025
,

Shift Miami

In Person
Perez Art Museum 1103 Biscayne Blvd, Miami, FL
Interested in robotics, but don't know where to start? Meet Viam in Miami, where Adrienne Tacke will discuss how to get up and running, even if you're "just" a software developer.
Join Us
Jun 12, 2025
Jun 16, 2025
,

JS Nation

In Person
Amsterdam
WebRTC is most often associated with building video and text chat into browsers but this peer-to-peer technology can also be used to monitor and control machines from anywhere in the world! Join Nick Hehr to learn about industrial arms, DIY rovers, and dashboards of data in real time.
Register Now