All posts
technical4 min read

Connecting Your Browser Simulation to Real PLCs with OPC UA

OPC UA enables browser-based simulations to communicate with real PLC hardware. Learn how the WebSocket bridge approach works, how to set up a connection, and what security considerations matter.

Sim Assist Team

What Is OPC UA?

OPC UA (Open Platform Communications Unified Architecture) is an industrial communication standard designed for secure, reliable data exchange between devices, controllers, and software systems. Unlike its predecessor OPC Classic, which was tied to Windows COM/DCOM, OPC UA is platform-independent and runs on everything from embedded controllers to cloud servers.

OPC UA provides a rich information model. Devices expose their data as a structured address space of nodes, where each node can represent a variable, a method, an object, or an event. Clients browse this address space, read and write values, subscribe to changes, and call methods. The protocol handles serialization, security, and session management.

For industrial simulation, OPC UA is the natural bridge between a virtual environment and real control hardware.

The Challenge: Browsers Cannot Speak OPC UA Directly

OPC UA uses binary TCP connections by default. Web browsers are sandboxed environments that cannot open arbitrary TCP sockets. This means a browser-based simulation cannot connect to an OPC UA server directly.

The solution is a WebSocket bridge: a lightweight server-side component that translates between WebSocket messages from the browser and OPC UA binary protocol on the network side. The bridge maintains the OPC UA session, handles subscriptions, and forwards data in both directions.

How the Sim Assist OPC UA Bridge Works

The Sim Assist architecture uses a three-tier approach:

1. Browser Client

The simulation running in your browser communicates with the bridge using WebSocket messages. These messages carry structured commands like "read node X," "write value Y to node Z," or "subscribe to changes on nodes A, B, C."

2. Bridge Server

The bridge server runs as a lightweight process, either on your local machine or on a network-accessible server. It accepts incoming WebSocket connections from the browser and maintains outbound OPC UA client connections to one or more PLC servers. The bridge translates between the two protocols in real time, with latency typically under 10 milliseconds.

3. PLC / OPC UA Server

The target PLC runs an OPC UA server (most modern PLCs from Siemens, Beckhoff, Rockwell, and others include one). The server exposes the PLC's variables, I/O points, and diagnostic information as OPC UA nodes.

Setting Up a Connection

Getting connected involves a few straightforward steps:

  1. Start the bridge: Download and run the Sim Assist bridge application on a machine that has network access to the target PLC. The bridge exposes a local WebSocket endpoint.
  2. Configure the endpoint: In the Sim Assist editor, open the OPC UA connection panel and enter the bridge's WebSocket URL (e.g., ws://localhost:4840/bridge).
  3. Browse the server: Once connected, the editor displays the PLC's OPC UA address space as a tree. You can browse nodes, inspect data types, and see current values.
  4. Map variables: Drag nodes from the address space tree onto your simulation's I/O mapping table. This binds a simulation variable (e.g., a sensor output) to a real PLC variable (e.g., an input register).
  5. Run the simulation: Start the simulation. Sensor values from the virtual plant flow to the PLC via the bridge, and the PLC's control outputs flow back to drive actuators in the simulation.

Security Considerations

Connecting a browser simulation to production equipment introduces security concerns that must be addressed:

Authentication

The bridge supports OPC UA security policies including Basic256Sha256 encryption and certificate-based authentication. You should configure the bridge to require valid certificates for both the client (bridge) and server (PLC) sides of the connection. Anonymous connections should be disabled in production environments.

Network Isolation

The bridge should run on the same network segment as the PLC, or be accessible through a VPN. Never expose OPC UA endpoints or the bridge's WebSocket port directly to the public internet. Use firewall rules to restrict access to known IP addresses.

Read-Only Mode

For testing and demonstration scenarios, you can configure the bridge in read-only mode. In this configuration, the simulation can read PLC values but cannot write to them. This is useful when connecting to a running production system for monitoring or training purposes.

Session Management

The bridge enforces session timeouts and connection limits. If the browser disconnects unexpectedly (e.g., a closed tab), the bridge closes the OPC UA session and releases resources. This prevents orphaned sessions from accumulating on the PLC.

Practical Use Cases

Virtual Commissioning

Build a digital twin of a machine or production line in Sim Assist, then connect it to the real PLC. Run the actual control program against the virtual plant to verify logic, timing, and sequences before the physical machine is assembled.

Hardware-in-the-Loop Testing

Use the simulation as a test bench for PLC programs during development. Inject faults, simulate sensor failures, and verify that safety logic responds correctly, all without risking physical equipment.

Operator Training

Connect a training simulation to a real HMI panel. Operators can practice procedures, respond to alarms, and learn the system's behavior in a safe, controlled environment.

Remote Diagnostics

When a machine is already in production, connect a read-only simulation to monitor the PLC's state in real time. Overlay the simulation's 3D view with live data to quickly understand what the machine is doing and diagnose issues remotely.

Getting Started

The Sim Assist OPC UA bridge is available for Windows and Linux. Installation takes under five minutes. Once running, the bridge appears as a connection option in the Sim Assist editor. Start with a simple read-only connection to a test PLC, verify that data flows correctly, and then expand to bidirectional communication as your confidence grows.