Virtual Controllers
A Virtual Controller is a simulated PLC with its own tags, programs and scan. A project holds up to 4 controllers, such as a Filler and a Capper, and one controller can read a tag from another, the way two PLCs share data over a network.
What a project holds
Every project starts with one controller, named PLC1 at the address 192.168.1.10. Add up to 4 controllers. Each has its own program, tags and scan, and all of them run on one shared simulated clock, in project order. Data types and Logic Classes are shared by the whole project. The controller you have open is the one you edit; the others keep their state and keep scanning.
Add a controller
- In Project Explorer, find the Virtual Controllers folder and click +, or open View and choose Virtual Controllers, then click Add virtual controller.
- Type a Name: letters, digits and underscores, starting with a letter, and not already used. Type an IP address from 192.168.1.1 to 192.168.1.254. Both default to the next free ones, such as
PLC2. - Click Add. The new controller is blank, with the project's data types and Logic Classes.
- Click another controller in the folder to open it, or select its tile and click Open.
The Virtual Controllers tab
The tab shows This controller, a Virtual network with one front panel for each controller, and a Connections table. Each front panel has three lights: RUN, OK and NET. Select a tile to change its settings in the Inspector:
| Setting | What it does |
|---|---|
| Mode | Run or Program. A controller in Program mode does not run its program and keeps sending its last values. A faulted controller must be opened and reset. |
| Scan | How often this controller scans: 5, 10, 20, 50 or 100 ms. |
| Network cable | Unplug drops every connection to the controller. Delay makes its data arrive late, from 50 ms to 1000 ms. |
| IP address | The controller’s address on the virtual network. |
The toolbar Run and Stop act on the controller that is open. To run another controller from its tile, the project must be built. FORGE asks you to open that controller first if it is faulted or uses a Link.
Read a tag from another controller
- Open the controller that should receive the value, such as
Filler. - In the Connections table click Add connection, or select the sender’s tile and click Read a tag from.
- Choose the Controller and the Tag there. Name the Tag here, which defaults to the sender and tag together, such as
CapperReady. - Choose how often it updates: 10 ms to 1000 ms, 20 ms by default. Click Add.
An example: the Filler waits for the Capper
The Capper controller has a BOOL tag Ready. The Filler reads it as CapperReady. In the Filler’s program the received tag is an ordinary contact:
| Tag | Value |
|---|---|
| CapperReady | 1 |
| FillerStop | 0 |
| FillerRun | 1 |
In the tag table the Filler’s CapperReady is read-only: only the Capper’s program writes Ready. In the HMI Studio tag picker, the I/O mapping editor and in messages, a tag from another controller is written Capper:Ready once the project has two or more controllers.
How the data moves
- The direction is one way: the sender sends and the receiver reads. For a two-way exchange, add a second connection the other way round.
- The receiver’s copy must have exactly the same type, including the data type of a structure and the size of an array, as the sender’s tag.
- A sender shares up to 32 tags. A tag must be a controller-wide tag of type BOOL, SINT, INT, DINT, LINT, REAL, STRING, CHAR, a structure or an array of up to 64 elements. Timers and counters cannot be shared.
- FORGE samples the sender’s last committed scan, then delivers the value at the start of the receiver’s next scan, never in the middle of one. A cable delay adds to that.
- Each sender and receiver pair has one connection, which can carry many tags. A controller cannot read from itself.
Is the connection alive?
The receiving controller gets a status tag named Conn_ and the sender’s name, such as Conn_Capper, with these members:
| Member | Meaning |
|---|---|
| OK | On while data keeps arriving. |
| AgeMs | How long ago the last value arrived, in ms. |
| Lost | How many times the connection timed out since Run. |
A connection times out after 4 times its update time. The Connections table shows its state: OK, DELAYED, LOST, UNPLUGGED, or the name of the controller that is in Program mode. When it is lost the receiver keeps the last values, so check Conn_Capper.OK before you trust them.
Good to know
- A project file with two or more controllers keeps each controller’s name, address, program, tags and connections. A project with one controller is saved as it always was, and reopens as
PLC1. - On Free you can open and run a project that has several controllers, and edit and run the one that is open. Adding a controller, running another one from its tile, and connections need Pro.
- A fault stops only the controller that faulted. The others keep running.
- A controller holds its own scene. With two or more controllers, the Simulators menu offers Reopen for the scene it was using.