I’m Jason Firth.
Happy New year to everyone!
I promised to talk more about virtual machines last time, and I’m finally following up on that.
First, some definitions.
A Virtual Machine is basically a machine (a computing machine with what we’re about to talk about) implemented in software.
A simple virtual machine may be very simple. Most programmers could bang a simple one out in a few minutes to do very simple operations, such as taking a file and doing operations with what’s contained in that file.
There are also much more complicated virtual machines. For example, the Java programming language is compiled into something called ‘bytecode’. This bytecode is not executable on your computer by itself. However; your computer has a virtual machine designed specifically for running Java bytecode loaded on it, called the Java JRE. That’s how Java programs run. One of the benefits of this is that you can write java code once to run on a virtual machine, and then as long as you have a working virtual machine, you should be able to run that program on any platform, no matter the processor, or the operating sytem.
A much more complicated version of a virtual machine is to have a PC create a virtual machine pretending to be another PC in software. This is sometimes called emulation. There’s a number of software packages that do this for us. VMWare is probably the most popular one. Windows Server 2008 and onwards has the ability to run virutal machines built in. Oracle has Virtual PC. Bochs is a popular open source program for virtualization.
Intel has included special hardware acceleration of virtual machines for server machines. It helps provide direct access to hardware and CPU resources without having a software layer in between.
There is a clear benefit to using virtual machines on servers. Basically, you can have one incredibly powerful computer that is acting like 100 different computers. You can also have the virtual machine running in parallel on different computers so if there’s a hardware failure, a different parallel system can immediately take over. In terms of resource utilization, virtual machines have useful benefits: not every virtual server will be using all resources at all times, so you can run multiple virtual servers, called “instances” on the same amount of hardware that might run one server if you had dedicated hardware for each server. Also, if you’re selling instances, you can assign more or less resources to that instance depending on the demand, allowing you to set your prices based on resourcing.
So, how can this possibly apply to PLCs?
Well, the idea is that instead of running PLC logic on a PLC processor, you could run the software in an instance in a data center.
There’s no reason why this can’t work. Most PLCs today run a proprietary operating system called VxWorks by a company called Wind River. This operating system is probably the most popular operating system you’ve never heard of. It’s used in spacecraft, in military and commercial aircraft, in communication hardware, and in large scale electrical infrastructure, to name a few. This operating system runs just fine in VMWare, according to some sources I found on the Internet. It’s extremely likely that a PLC controller can be made to run in a Virtual Machine on a server.
Of course, there’s reasons why it’s not a great idea. After all, a PLC controller is a purpose built piece of hardware. It is designed to handle dirty power, and extreme temperatures and humidity. It is designed to fail gracefully when it does fail. By contrast, consumer grade or even business grade servers are much less robust, are designed with much shorter running life in mind, and usually designed with more performance in mind than reliability.
There are PLCs that do make decisions from a PC. They’ve existed for decades. They’re called “Soft PLCs”. NASA uses a Soft PLC named “National Instruments LabView”. So there is a place for these, but as you can see it’s not a simple one size fits all answer.
Now for the trick I mentioned last time.
See, for all this talk of “Should PLCs use Virtual Machines”, there’s one simple fact it’s easy to forget: PLCs are Virtual Machines!
Inside a PLC, there is no giant rack of relays. The original purpose of a PLC was to take that giant cabinet filled with relays and replace it with a CPU running a program that emulates the function of that relay cabinet — the definition of a virtual machine.
Some PLCs have a special custom chip designed to run the virtual machine logic called an ASIC. This means that however we do it, a PLC does, and will almost always, run a virtual machine!
“Almost”?
Well, there’s one more spanner in the works. Not every PLC is a virtual machine.
How would this work? Well, if you had a microcontroller, and programmed a compiler designed to produce native code using ladder logic or FBD, then uploaded the complied code to the microcontroller, then you’d have a normal controller running native code, and not a virtual machine. On the other hand, every major PLC brand today doesn’t do that. They all use virtual machines.
Thanks for reading!