Part B. OPC UA
OPC UA carries names, not addresses, so nothing is mapped. Each part's tag is the PLC's own name for the variable,
and the simulator finds it on the server. Stop the simulation before you rewire.
B1. Wire the parts to the PLC's names
The simulator matches a tag against the end of each variable's path on the server, so PLC_PRG.Eye finds
a variable at .../PLC_PRG/Eye whatever folders the server puts above it, and the same idea works for
MAIN.Eye or any other program name. Case does not matter; a name that fits two variables is refused with both listed.
B2. Point the simulator at the server
In Simulation > PLC Controllers…:
- Runs on: An external PLC.
- Under it, how the PLC connects: OPC UA, tags by name (the PLC runs an OPC UA server).
- Server: the PLC's endpoint,
opc.tcp://127.0.0.1:4840 on the same computer by default.
The connection is unsecured, with security policy None and an anonymous login, so the PLC's server has to allow both.
Use it on a test bench, not a plant network.
On Play the simulator reads the server's whole tree under Objects to find each tag. If the server holds far more
than the program, as a controller that also runs a CNC or drives does, put where the program's variables are in
Browse from: a path from Objects like DeviceSet.PLC.Programs, or a NodeId,
several separated by commas. Tags keep the names they have; only less of the tree is read.
B3. The PLC program
PROGRAM PLC_PRG
VAR
Eye : BOOL;
Run : BOOL;
END_VAR
Run := NOT Eye;
END_PROGRAM
Eye is a plain variable, not an input at %IX, because most PLCs refuse a client's write to a real
input, which their I/O system overwrites every scan.
On the PLC
- Put the program above into the PLC, as in part A or in a project of its own.
- Publish
Eye and Run on the PLC's OPC UA server, readable and writable. Every PLC has its own way to choose which variables its server exports; its documentation says how.
- Download the program and start it.
B4. Port 4840 may not be the PLC
4840 is OPC UA's standard port, and some OPC software installs the OPC Foundation's
discovery server there. It is a directory of the computer's OPC UA servers, with no tags. If that is
what answers, the simulator says so on Play instead of reporting every tag missing:
Could not connect: opc.tcp://127.0.0.1:4840 is an OPC UA discovery server, not a PLC, followed by
the servers it knows of, if any. A PLC's server that does not register with it will not be among them.
Move the PLC's server to its own port, such as 4841, in the PLC's own configuration (its documentation says
where), and restart it. Then use opc.tcp://127.0.0.1:4841 as the Server.
B5. Press Play
The status line says Reading and writing the PLC's tags at opc.tcp://127.0.0.1:4840 (or the port
you moved the server to), the dialog lists each tag against the variable it found, and the PLC stops the box at
the sensor.
A stopped program can still look alive. An OPC UA server belongs to the runtime, not the program, and keeps
answering with the last values when the application stops. Only a lost connection, or a server that goes
silent, makes the simulator hold the PLC's outputs off.