IMDHMIControls LibraryShop main store

How-to

Connecting a CODESYS HMI on Windows to an S7-1500 PLC

SCADA and data logging Published 7 min read

Short answer

Yes, it works. Use OPC UA with the S7-1500 as server and the CODESYS HMI as client when the PC only supervises; use a CODESYS Control Win runtime with target visualization over a PROFINET controller/device link when the PC must also run logic. The PROFINET path adds one single-device license on top of the runtime; the OPC UA path adds none.

On this page
  1. Choose the architecture before buying anything
  2. Path A: OPC UA with the S7-1500 as server
  3. Path B: Control Win with target visualization over PROFINET
  4. Counting licenses for one Control Win PC supervising one S7-1500 over PROFINET
  5. Map the data and keep write authority in the PLC
  6. Diagnose from the bottom of the stack up
  7. Questions asked

Yes, a CODESYS HMI on a Windows PC can supervise and command a Siemens S7-1500, and there are exactly two architectures worth building. Path A is OPC UA: the S7-1500 serves, the CODESYS side connects as the client, and every screen tag is a published node. Path B is a CODESYS Control Win runtime on the PC hosting the target visualization, tied to the S7-1500 by a PROFINET controller/device relationship. Take A when the PC only displays values and writes setpoints; take B when the PC must also execute CODESYS logic. This article walks both: the choice, the configuration steps, the license count, and the diagnostics ladder for the day the screen goes stale.

Choose the architecture before buying anything #

Both stations sit on one network with a standard Ethernet cable, but the cable alone exchanges nothing: each side must hold the complementary protocol role and an agreed data model. Over OPC UA, one endpoint is the server that publishes addressable nodes and the other is the client that subscribes and writes; settling which direction works for OPC UA server and client fixes certificates, addressing and who may browse. Over PROFINET, one station is the controller and the other is a device, exchanging cyclic I/O areas defined in both engineering tools.

Path A: OPC UA Path B: Control Win with PROFINET
S7-1500 role OPC UA server, enabled in TIA Portal PROFINET device, or controller if the PC is the device
PC role OPC UA client behind the CODESYS visualization CODESYS Control Win runtime with target visualization, as PROFINET controller
Data model Nodes browsed by namespace; commands as writable nodes Cyclic I/O areas mapped field by field at both ends
Choose when The PC supervises: indications, setpoints, alarms The PC must also run IEC logic or exchange cyclic I/O
Documented license load The Control Win runtime The runtime plus CODESYS PROFINET Controller SL on the PC

Commit like this: a supervisory station takes Path A; a station with its own interlocks, sequence or local control takes Path B. Either station is a Windows computer at the machine, and when it is specified new, an industrial panel PC hosting the visualization is the form that fits the cabinet door.

Path A: OPC UA with the S7-1500 as server #

  1. Enable the OPC UA server on the S7-1500 and generate its server interface in TIA Portal. The exact dialogs and settings are in connecting an S7-1500 to SCADA over OPC UA from TIA Portal.
  2. Publish the data. Give each data block or variable server access so it appears as a node in the server namespace; command variables get writable nodes, indications stay read-only.
  3. Point the CODESYS project's OPC UA client at the endpoint URL the CPU lists, and create the data source the visualization tags will resolve against.
  4. Exchange trust. The server must accept the client's certificate before any session completes; trusting an OPC UA client certificate on the PLC is the same handshake, and an untrusted certificate is the classic reason a reachable endpoint never opens a session.
  5. Browse and map. Map each node to a visualization variable with a matching type, Boolean, integer, float or string, and confirm the command nodes report writable access for the connected user.
  6. Prove it. Session established, every tag good quality, and a test write that reaches the PLC and is acted on only through PLC logic.

Path B: Control Win with target visualization over PROFINET #

  1. Install and license CODESYS Control Win on the PC; the count below shows what that stack contains.
  2. Add the PROFINET role. With the PC as controller, CODESYS PROFINET Controller SL covers it: a single-device license activated on the device that runs the runtime.
  3. Configure the complementary role on the S7-1500 in TIA Portal: device under the PC as controller, or controller over the PC as device. Firmware gates this on the Siemens side; the documented case is the S7-1200, which needs firmware above 4.0 for a CODESYS PROFINET link, so confirm the S7-1500 supports its role on the firmware it actually runs.
  4. Define the cyclic I/O areas at both ends of the link; the mapping rules are below.
  5. Build the target visualization against application variables, not against S7 tags: the screens read the CODESYS application, and the application reaches the S7-1500 through the mapped I/O. Running a PLC-hosted visualization on a remote panel PC follows the same serving model when the display sits away from the cabinet. Extra displays later are a visualization-side job; two ways to add a second panel to a CODESYS HMI PLC both leave the PLC link untouched.
  6. Commission: the controller accepts the configured device name, the application runs, cyclic data moves, and every screen value that mirrors the S7-1500 changes with the process.

Counting licenses for one Control Win PC supervising one S7-1500 over PROFINET #

Inputs:

  • The PC: 1 Windows machine that must execute logic as well as host screens, so Path B.
  • The PLC: 1 S7-1500, configured as the PROFINET device in TIA Portal.
  • Fieldbus roles in the IEC application: 1, a PROFINET controller.
  • Documented allowance: CODESYS Control Basic L is designed for applications with up to two CANopen, Modbus or J1939 fieldbus applications.
  • Documented add-on: CODESYS PROFINET Controller SL is a single-device license, activated on the device that runs the CODESYS runtime.
  • Runtime: CODESYS Control Win SL, offered as application-based licensing since v3.5.19.0 or as a single-device license.

Rule in words: a fieldbus role is covered only when its protocol appears in the runtime license's documented fieldbus list. Count the application's fieldbus roles, subtract the covered ones, and buy one single-device license per uncovered role, activated on the device running the runtime. Count the runtime license itself once.

Arithmetic:

  • Fieldbus roles used: 1 (PROFINET controller).
  • Covered roles: the Basic L list is CANopen, Modbus and J1939; PROFINET appears in it 0 times, so covered = 0 of 1.
  • Uncovered roles: 1 − 0 = 1.
  • Add-on licenses: 1 × CODESYS PROFINET Controller SL, on the PC.
  • Total on the PC: 1 Control Win SL runtime + 1 PROFINET Controller SL = 2.
  • Total on the S7-1500: 0.

Decision: the PROFINET architecture for this station is two CODESYS licenses on the PC. The threshold is one. The moment a design gives the PC one or more PROFINET roles, one PROFINET Controller SL goes on that runtime device; the number of roles or I/O bytes does not change it, and a second PC running its own controller role needs its own. Zero PROFINET roles, as in Path A, leaves the Control Win runtime as the only CODESYS license on the PC.

Map the data and keep write authority in the PLC #

Define every exchanged value by owner, direction, type and write authority. The owner is whichever controller computes the authoritative value; indications are read-only, and an operator command originates at the HMI, then is validated by S7 logic before it touches the process. That division is how an HMI and a PLC divide the work in a control system, and it does not change between OPC UA and PROFINET; only the transport does. One safety rule: no HMI write may command a machine action directly, and any function that protects people stays in the safety controller, never on this PC path.

On OPC UA, the mapping is per node: browse the namespace, match the type, and verify the access level on command nodes. On PROFINET, the byte layout is the contract: identical direction, length and field ordering at both ends, padding declared, multi-byte types on agreed boundaries. Two stations that exchange running data with wrong values have a layout mismatch, not a network fault.

Diagnose from the bottom of the stack up #

  1. Link and addressing: both interfaces up, unique addresses on the same subnet or a working route.
  2. Endpoint: the OPC UA client reaches the endpoint URL, or the PROFINET controller sees the configured device name.
  3. Session: the OPC UA session establishes with the accepted user and certificate, or PROFINET cyclic data flows in both directions.
  4. Quality: every subscribed tag reports good, current values.

Failures cluster by layer: 1 to 2 are addressing, cabling or firewall; 3 is role, configuration or trust; 4 is publication, permissions or type mapping. Work upward: a host that pings but will not open a session has already cleared the network.

Questions asked

Does the S7-1500 need a CODESYS license too?

No. CODESYS single-device licenses activate on the device that runs the CODESYS runtime, which here is the Windows PC. The S7-1500 side needs no CODESYS purchase at all: it needs its OPC UA server enabled or its PROFINET role configured in TIA Portal, which is the Siemens engineering tooling that CPU already uses.

Which side should be the OPC UA server?

The S7-1500, because it owns the process data. The CODESYS HMI connects as the client, subscribes to published nodes and writes the command nodes. Reversing the roles only fits when other systems should read values the PC itself produces, for example a PC-hosted calculation, which a supervisory HMI is not.

Can the same PC run the HMI and CODESYS logic?

Yes, and that is exactly the Control Win path. One runtime on the PC executes the IEC application and serves the target visualization, so the screens address local application variables while PROFINET or OPC UA moves process data between that application and the S7-1500. Keep the fast control in the S7-1500 and supervision on the PC.

The session is connected but tags show bad quality. Cable or configuration?

Configuration. Node publication, user permissions, a changed namespace, or a type mismatch in the HMI mapping, in that order of likelihood. An established session has already cleared the network, the endpoint and the certificates, so keep working at the application layer instead of re-patching cables.

Would Modbus TCP be simpler between the two?

It works, but it is not simpler to live with. Modbus TCP moves register arrays with no browsing, no quality flags and no security model, so every tag is a hand-maintained address. It also draws on the documented CODESYS Control Basic L allowance of up to two CANopen, Modbus or J1939 fieldbus applications, while the OPC UA path touches no fieldbus license at all.

Keep reading

  • How-to

    Connect an S7-1500 to SCADA over OPC UA from TIA Portal

    The S7-1500 has a built-in OPC UA server from firmware V2.0, deactivated by default. Enable it in the CPU device properties in TIA Portal, select the installed server license, copy the endpoint URL, and download. Paste the opc.tcp address into any OPC UA SCADA client, trust the certificates on both sides, then browse the PLC variables and map them to SCADA tags.

    SCADA and data logging

  • Troubleshooting

    Getting Citect SCADA talking to a Mitsubishi iQ-R PLC

    Fix the transport before anything else: the Citect MELSECQ port on TCP_BOARD must match the iQ-R's SLMP connection module exactly — protocol, port number and IP address. If tags above device 65,535 fail, that is the MELSEC Q protocol's 16-bit address ceiling, and no setting fixes it; move to Mitsubishi's OPC MX UA server with a Citect OPC client driver.

    SCADA and data logging

  • How-to

    Starting an OPC UA client connection from PLC code

    As of OPC UA Client app version 1.16.0, a configured connection stays Disconnected until something requests a start. PLC code does that job: run cyclically, read the client state, and issue the start request only when the state is Disconnected and no request is pending, gated so it fires once per attempt. Import the PLCOpenXML example into ctrlX PLC Engineering and give the PLC sole ownership of automatic starts.

    SCADA and data logging