IMDHMIControls LibraryShop main store

Troubleshooting

Connecting Factory I/O to a local CODESYS soft PLC over OPC UA

Industrial networks Published 8 min read

Short answer

Yes: OPC UA only carries tag values, so the ladder or structured text must run in the CODESYS runtime. Fix the connection in order: prove the engineering path through the Gateway to the runtime first, then the OPC UA endpoint at port 4840, then map each scene point to one variable. Keep Control I/O out of it, because Factory I/O runs one driver at a time.

On this page
  1. What OPC UA carries, and where the logic runs
  2. The five links the tag path needs
  3. Prove the Gateway path before touching Factory I/O
  4. Check the endpoint the driver actually uses
  5. Worked example: counting unproven links for the Sorting scene on one PC
  6. Map each scene point to exactly one variable
  7. One driver at a time: Control I/O or OPC UA
  8. Questions asked

Your reading is correct: OPC UA carries tag values and nothing else. The ladder or structured text for the Sorting scene has to execute in a controller, and with no physical PLC that controller is the CODESYS runtime, not the Gateway and not Factory I/O. Connections like yours fail because one of five separate links is down while the two you checked look fine. Fix them in path order: prove the engineering route through the Gateway to the runtime, then the OPC UA endpoint, then map each scene point to exactly one variable. Keep Control I/O out of the picture; it cannot share the driver slot with OPC UA, and the OPC UA driver is the one that shows industrial tags.

What OPC UA carries, and where the logic runs #

OPC UA, standardized as IEC 62541, is a communication protocol, and the client/server profile you are using does three things: read variables, write variables, and subscribe to them, with a subscription pushing a notification each time a value changes. Calling that publish/subscribe-like works as intuition, but the operative fact is simpler. None of it executes a rung or a line of structured text, so something has to run the Sorting scene logic, and on your machine that something is the CODESYS runtime. Control Win V3 is the soft PLC the Factory I/O tutorials build on: its OPC UA server is the server, and the Factory I/O OPC UA driver is the client that comes to it.

The roles can reverse, and the troubleshooting is completely different when they do; starting an OPC UA client connection from PLC code describes that other arrangement. Your demo keeps the PLC as the server and Factory I/O as the client.

Five components must each be alive before a single Factory I/O tag moves. Two are processes you can watch start; three are states you have to prove.

Link Job Proof it is up
CODESYS development environment Builds, downloads and monitors the application Project builds with no unresolved variables
Local CODESYS Gateway Carries engineering traffic to the runtime Shows in the communication path and finds the runtime
Soft PLC runtime (Control Win V3) Executes the ladder or structured text Application logs in and reports Run
OPC UA server in the runtime Exposes variables at an endpoint A client opens a session and browses them
Factory I/O OPC UA driver Reads, writes and subscribes to scene tags Driver items show good quality and move

The server in the fourth row is not a separate purchase to chase: per CODESYS documentation, OPC UA server capability is included in CODESYS-compatible soft PLCs, so that link is configuration work, not an install decision.

Prove the Gateway path before touching Factory I/O #

Even on one PC the engineering path crosses process boundaries and firewall rules, so prove CODESYS can reach its own runtime before you blame the driver.

  1. Open the device's communication settings and confirm the selected Gateway is the local one you started, not a leftover from another installed version.
  2. Scan for devices, and when several appear, pick the runtime by its displayed identity rather than the first entry.
  3. A red squiggly underline on the device in the project tree marks a version mismatch: right-click the device, choose "Update device", and select the version you have installed.
  4. If the Gateway itself will not start, look for two versions installed side by side. One reported case had a 3.5.18.5 Gateway auto-launching out of the system tray while the project needed the 3.5 one; stopping the wrong process and starting the matching Gateway restored the connection.
  5. Log in, download the application, command Run, and watch a timer or counter toggle in online mode.

When a step fails, read it this way:

  • Gateway missing from the communication path: the process is down or the wrong version is running, so start the matching one.
  • Scan finds no device: the runtime is stopped, bound to another interface, or blocked by the local firewall.
  • Login fails on a visible target: read the runtime's diagnostics, because you are probably logging into a different runtime than the one you configured.

This stage passes only when online monitoring shows the application running and a variable changing inside CODESYS.

Check the endpoint the driver actually uses #

The OPC UA session runs from Factory I/O straight to the endpoint; it does not detour through your open project or the Gateway. Control Win V3 serves OPC UA on port 4840, so on one machine the address is of the form opc.tcp://localhost:4840. Read the exact string from the active server configuration instead of typing from memory. If you later split the demo across two PCs, the same endpoint becomes opc.tcp://<PC-address>:4840, with the runtime PC's address in place of localhost and TCP port 4840 opened in that PC's firewall.

  • Confirm the server is bound to an interface the client can reach; a server bound to one interface refuses a client arriving on another address, even on the same PC.
  • Match the driver's security setting to a policy the endpoint advertises, and clear certificate trust on both sides if authentication is on.
  • Browse the server namespace from any OPC UA client and confirm every Sorting scene variable is exposed for external access, with a usable data type and write access on the commands.
  • Enter tag names exactly as browsed; a tag that connects but never changes is a mapping fault, not a comms fault.

Demos that must run for days meet different failures on the same stack; fixing CODESYS OPC DA memory growth stopping SCADA reads documents one of them on the older DA protocol.

Inputs:

  • Factory I/O with the OPC UA driver selected and the Sorting scene loaded, the setup you described.
  • The Gateway and the Control Win V3 runtime confirmed running on the same PC, your own check and the only two links proven so far.
  • OPC UA endpoint port 4840 on Control Win V3, from CODESYS documentation for the soft PLC.
  • Five links in the tag path, from the table above.

Rule: a scene tag moves only when all five links are up. Subtract the links already proven from the total; what remains is the fault list, tested in path order and stopping at the first failure.

Arithmetic:

  • Links in the path: 5
  • Links already proven: 2
  • Links still unproven: 5 - 2 = 3, namely the application downloaded and in Run, the endpoint reachable, and the driver session established

One test covers two of the three: point a general-purpose OPC UA client such as UaExpert at opc.tcp://localhost:4840 and browse.

Result and decision:

  • The browse fails: the fault is at or before the server. No setting inside Factory I/O will fix it, so stop, resolve the server, its interface binding or the local firewall, then repeat the browse.
  • The browse opens and lists your scene variables: the endpoint and the published variables both pass in one move, and every remaining fault lives in the driver, meaning its address, security policy or tag names.

That is the cutoff: a failed browse means the fix is never in Factory I/O; a passed browse means the rest of the session is spent inside the driver.

Map each scene point to exactly one variable #

Map by direction, not by name resemblance. A Factory I/O sensor is an input to the PLC application; a conveyor or actuator command is an output from the application into the scene. Reverse that and you get tags that connect cleanly and control nothing.

  • List every Sorting scene point with its scene direction, PLC direction, data type and the browsed variable name.
  • Assign each point to exactly one server variable.
  • Operate one sensor at a time and watch its one variable in online mode.
  • Command one actuator at a time from the logic and watch its one scene device.
  • Leave sequence faults alone until every point-to-point test passes, because a mapping bug and a logic bug look identical from the scene.

The mapping check passes when each sensor moves exactly one variable and each command moves exactly one device.

One driver at a time: Control I/O or OPC UA #

Factory I/O supports one driver at a time, and Control I/O and the OPC UA driver are two different choices for that one slot. Control I/O is included in the Starter and Ultimate editions and is the easier start, but while it holds the driver role Factory I/O will not speak OPC UA, and Control I/O does not publish your tags to an OPC UA server as a side effect.

So commit: for a demo whose point is industrial tags, CODESYS runs the logic and the OPC UA driver carries the values, real ladder or structured text in a runtime with real client/server traffic over a real endpoint. Choose Control I/O only when simple scene control matters more than the tag story, and accept that OPC UA leaves the demo entirely.

If a future demo only needs one PC playing plant and controller, simulating a Modbus TCP SCADA link on one PC is the same pattern over a different protocol.

One caution before this demo meets real hardware: a soft PLC proves the tag path, not a machine, so the physical controller gets its own I/O checkout and a proved stop function before anything powers up.

Questions asked

Does the CODESYS Gateway have to stay running for Factory I/O to read tags?

No. The Gateway carries the engineering path, meaning download, login and online monitoring, while the OPC UA driver opens its session straight to the runtime's endpoint. Once the application is in Run you can close the development environment and the Gateway, and tag traffic continues. Reopen them only to edit or monitor the logic.

Can Control I/O run the scene and still put tags on an OPC UA server?

Not in Factory I/O. It runs one driver at a time, and Control I/O and the OPC UA driver are separate choices for that slot, so selecting Control I/O means no OPC UA driver, and Control I/O does not publish to an OPC UA server as a side effect. You can drive a scene manually from the Factory I/O UI with no driver at all, but that demonstrates no tag traffic. For tags, use CODESYS with the OPC UA driver.

Can CODESYS and Factory I/O run on two PCs?

Yes. Leave the Control Win V3 runtime on one machine and point the driver at that machine's endpoint, same port 4840 with the PC's address in place of localhost, after opening the port in that PC's firewall. Prove it the same way: browse the endpoint with a general-purpose OPC UA client on the Factory I/O PC first, then configure the driver.

The driver connects but items show bad quality - where is the fault?

In the session or the mapping, not in your logic. Bad quality on every item points at the session: endpoint address, security policy, certificate trust. Bad quality on one item points at that variable: it is not exposed for external access, or the tag name does not match the browsed name. The runtime keeps executing the program throughout, so the scene logic is not the suspect.

Do we need a physical PLC for a demo that travels?

No. Control Win V3 on the same laptop as Factory I/O executes the logic, and OPC UA carries the tags between the two processes: one machine, no controller hardware, no field wiring. That is the standard arrangement for showing tag usage to a non-controls audience. Add a physical PLC only when the demo must show real I/O or network hardware.

Keep reading

  • Troubleshooting

    Fix robot Profinet output writes over OPC UA

    Set the Profinet Internal Device Input Size and Output Size to 64 bytes each, under Controller tab, Configuration, I/O System, Profinet Internal Device, and robot output writes reach the PLC array. The failing direction, not the OPC UA status number, identifies the cause: a Bad-class write with the other direction working means the output byte image is missing.

    Industrial networks

  • Troubleshooting

    Troubleshooting a PLC-5 ControlNet connection path from a driver

    The route for a driver to a PLC-5 over ControlNet ends at the processor, not at the network: 1,2,2,4 becomes 1,2,2,4,1,0 once the processor slot is confirmed. Test the terminal route and the short route separately with the build recorded, and treat a working RSLinx read as proof of reachability, not proof the driver accepts the same string.

    Industrial networks

  • Troubleshooting

    Connecting STARTER to a PROFIBUS drive through an S7-300

    Being online with the S7-300 does not put STARTER online with the drive. Confirm the drives are on PROFIBUS, make the drive's station address match the one the project expects, select the routed path through the S7-300 in STARTER, and save the new parameters to EEPROM with P0971 = 1.

    Industrial networks