Poor-Man’s Control System

Jayson DeLancey
4 min readMar 19, 2018

--

In the Industrial Internet of Things (IIoT), systems thinking is important. Systems manage flows of goods, chemicals, energy, and manufacturing processes that run the world. Unless you’ve spent some time in this Operations Technology (OT) world, you may not understand the purpose and mechanics behind control systems.

From the recent book from Ryane Bohm, Industrial IIoT for Developers, a control system is described as an arrangement of physical components that is designed to regulate the equipment to which it’s attached. This can fall into a couple of categories. The first, open-loop controls are those that operate the same way regardless of conditions. An example given is that of a washing machine running for a set amount of time, regardless of whether it cleans the clothes or not. In the case of closed-loop controls we apply sensors and the control can take action based on sensor feedback, much like a thermostat does by sensing the temperature of the room and turning on/off the furnace or air conditioning unit.

The space gets more sophisticated as you begin experimenting with Programmable Logic Controllers (PLC), Supervisory Control and Data Aquisition (SCADA), Distributed Control Systems (DCS), and Data Historians that are commonly part of the system of an industrial process. The equipment involved tends to be expensive and mission critical so when rolling out new software and applications it is not always feasible to access these systems in a test environment where you can control the parameters and validate your app.

For this reason, I experimented recently with what could be considered a poor man’s control system. I’ve hacked together a control system for my Steam Engine Digital Twin using a Belkin WeMo Insight Smart Plug. This is not what we typically mean by control system nor appropriate for an industrial environment, but for under $50 it provides an accessible means to experiment and build up a POC.

Ping

Getting things setup is not without a few obstacles which I’m not going to cover at length here. You need to setup the WeMo Mobile App to communicate with your switch and update the software.

I began using a Python API provided in a BSD licensed open-source project called ouimeaux to communicate with the switch. You can install by simply running pip install ouimeaux and pip install ouimeaux[server]. While many industrial control systems may use something like modbus or OPC-UA, the Belkin devices use basic UPnP which make the devices discoverable by a server listening on the network.

Getting started, I create an environment and call start() and discover() which will create a UPnP server listening for messages to discover the devices communicating over the network. The list_switches() call should include the WeMo I configured in the app.

import ouimeaux.environment# Setup UPnP server and listen for devices
env = ouimeaux.environment.Environment()
env.start()
env.discover()
# Make sure we found the switch
if 'SteamControl' not in env.devices:
print(env.list_switches())
raise ValueError("Unable to discover control system.")
# Now we have access to our control
control = env.get_switch('SteamControl')

The Wemo switch is named SteamControl because I’m adding it to a project I’ve talked about at GlueCon and other venues. I have a Wilesco D20 Steam Engine that I refer to as my steam-powered data generator.

Source: How a steam engine works

The D20 unit is electric powered so I’m interested in learning about how much elecricity is needed to maintain pressure in the boiler and keep the machine running. I also want to respond to a situation where the pressure gets too high in the boiler to be able to shut-down power and let the system cool off or at the very least alert me to intervene and blow the whistle to stabilize the system.

Basic Insight

I have some basic control functions now over my light switch. I can find out what the current energy draw is, I can get an aggregate for the day or how long it has been enabled, and I can toggle it on or off.

# We have access to some metadata around electricity usage
print("current_power = " + str(control.current_power))
print("today_kwh = " + str(control.today_kwh))
print("today_on_time = " + str(control.today_on_time))

Mac Address, SSID, Serial Number, etc. are also useful features of the asset model for this particular device.

It is pretty easy and straightforward to send this data to Predix Time Series and Predix Asset by using the Predix Python SDK. You can find documentation on that library from the PredixPy Github.

Big Picture

The Control System is a closed-loop for providing a See-Think-Do response with milli-second level accuracy reliably in safety critical applications. The opportunity is to extract the sensor data from these Control Systems and aggregate it in the cloud where responsiveness is no longer a requirement. We can take advantage of distributed computing to apply machine learning / deep learning algorithms to help better understand and learn from the equipment for the types of insights we can use to optimize the control system and other operations in industrial environments. More about how I’m using this steam engine as an experiment in data analysis in another post.

Hope this little demonstration helps you think about the problem space, continue to learn about control systems, and maybe give the Predix Python SDK a try on your next project.

--

--

Jayson DeLancey

Manage Developer Relations @Dolby; Maker at Robot Garden; Previously HERE, GE, Rackspace, DreamWorks Animation, MathWorks, Carnegie Mellon