Setting Up Virtual Machines for Automation Testing
How to leverage Hyper-V and VMware to create isolated testing environments for PLC logic and HMI development.
Testing PLC (Programmable Logic Controller) code and HMI (Human Machine Interface) screens on live equipment is a recipe for disaster. That's why building a robust virtualized testing environment is a game-changer.
Why Virtualize?
- Safety: Mistakes in logic won't damage physical machinery or compromise worker safety.
- Snapshots: You can take a snapshot of the VM before installing a massive software update. If it breaks, roll back instantly in seconds.
- Portability: Export the VM image and share it with teammates to reproduce edge cases accurately across disparate field rigs.
My Preferred Stack
I primarily use Hyper-V for its deep integration with Windows Pro/Enterprise, which is standard across industrial engineering environments.
Steps to Provision a Dev VM
- Enable Hyper-V: Turn on the Hyper-V hypervisor role in Windows Features.
- Dedicated Virtual Switch: Create an External Virtual Switch to allow the VM to bridge directly with physical PLCs on the test bench network.
- Hardware Allocation: Provision a Generation 2 VM with at least 8GB of RAM, static memory allocation (avoid dynamic memory ballooning with industrial runtimes), and 4 vCPUs.
- Baseline Snapshots: Install the target automation suite, activate licenses, and immediately capture a golden master snapshot.
# Quick Hyper-V VM Creation Script
New-VM -Name "PLC-TestBench-Win11" -MemoryStartupBytes 8GB -Generation 2 -NewVHDPath "C:\VMs\PLC-TestBench.vhdx" -NewVHDSizeBytes 120GB -SwitchName "External-PLC-Switch"Virtualization transforms how we develop, test, and safely deploy mission-critical automation systems.
Related Article
If an RDP session disconnects when you connect a VPN inside the VM, see Fix: RDP Session Drops When Connecting a VPN Inside a VM for the split-tunneling fix.