Industrial networks: PROFIBUS, PROFINET, switching and OPC UA

← Robot list · The basics

How the PLCs, drives, robots and supervision of a plant talk to each other: the automation pyramid, PROFIBUS DP and PA, Ethernet and IP for automation people, how a switch works and what VLANs are for, PROFINET with its device names, update time and watchdog, rings and MRP, industrial cabling, OPC UA and MQTT up to the cloud, EtherNet/IP, EtherCAT and Modbus TCP, cybersecurity and diagnostics. Five live labs: poll a PROFIBUS segment, teach a switch, pull a PROFINET cable, cut a ring and subscribe to OPC UA data.

How to use this course

Each lesson gives the idea in one sentence, then the real settings (addresses, ports, times, file types) of Siemens, Rockwell, Beckhoff and the others, a worked example from a plant, and a lab or a table to keep. Prerequisites: the industrial automation course (PLC, I/O, cycle) and, for the bits and frames, the communication course (UART, RS-485, Modbus RTU).

1

Why a factory needs several networks

20 min
You will learn

the automation pyramid and what travels at each level, cyclic and acyclic data, determinism and jitter, fieldbuses against industrial Ethernet, the main families (PROFIBUS, PROFINET, EtherNet/IP, EtherCAT, Modbus, OPC UA, MQTT) and who is behind each, and the difference between IT and OT.

In one sentence

Near the machine, small amounts of data must arrive every few milliseconds without fail; higher up, large amounts of data can arrive a bit later: each level has the network that fits its needs.

1.1 Cyclic and acyclic data

Cyclic data (or I/O data, process data) is sent again and again at a fixed rate: the 2 bytes of a speed set-point, the 16 inputs of a remote module. If it arrives late, the machine misbehaves. Acyclic data is sent on request: reading the serial number of a drive, writing a parameter, a diagnostic alarm. A good industrial network carries both on the same cable, with priority to the cyclic data.

Determinism means the time of delivery is bounded and known. Jitter is the variation of that time from one cycle to the next. An office network is fast on average but not deterministic: a big file download can delay a frame by tens of milliseconds. A motion axis synchronised with another one needs a jitter under a microsecond.

1.2 The families you will meet

NetworkMediumOrganisationWhere
PROFIBUS DP / PARS-485 / MBPPI (PROFIBUS & PROFINET International)installed base, Siemens world, process plants
PROFINETEthernetPISiemens and most European machines
EtherNet/IPEthernetODVARockwell (Allen-Bradley), Omron, North America
EtherCATEthernetETG (Beckhoff)fast motion, robots, packaging
Modbus RTU / TCPRS-485 / Ethernetopen (Modbus Organization)meters, drives, simple devices, every brand
IO-Link3-wire point to pointIO-Link Communitysmart sensors under a master
OPC UAEthernet (TCP)OPC FoundationPLC to SCADA, MES, cloud, between brands
MQTTEthernet (TCP)OASISIoT, data to the cloud

IT (information technology) is the network of offices: confidentiality first, frequent updates, a PC can be rebooted. OT (operational technology) is the network of machines: availability and safety first, equipment that runs 15 years, a PLC that cannot be rebooted during production. Most problems in modern plants come from where IT and OT meet: that is the subject of lessons 7 and 8.

Worked example

A bottling line: 40 remote I/O stations and 12 drives on PROFINET with a 4 ms update time (level 1), 3 HMIs that read 2000 variables every 500 ms (level 2), an MES that collects counters and quality every minute through OPC UA (level 3), and an ERP that receives the production order once per batch (level 4). Same plant, four time scales, from milliseconds to hours.

The essentials
  • Five levels: field, control, supervision, MES, ERP; the lower, the faster and the more deterministic.
  • Cyclic data at a fixed rate, acyclic data on request; both share the cable.
  • Determinism = bounded delivery time; jitter = its variation.
  • IT protects data, OT protects availability and safety.

Key terms

  • automation pyramid
  • fieldbus
  • industrial Ethernet
  • cyclic, acyclic data
  • determinism, jitter
  • SCADA, MES, ERP
  • IT, OT

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

At which level of the pyramid does a SCADA work?

  1. Level 2, supervision
  2. Level 0, field
  3. Level 4, ERP
  4. Level 1, PLC

Solution

Rule used 0 field, 1 control, 2 supervision, 3 MES, 4 ERP lesson 1 — figure

Answer A

Level 1 · Beginner2

Reading the serial number of a drive once is…

  1. acyclic data
  2. cyclic data
  3. a broadcast
  4. a deterministic frame

Solution

Rule used acyclic = on request lesson 1 — 1.1

Answer A

Level 2 · Intermediate3

A frame arrives after 2.0, 2.1, 1.9, 2.4 and 2.0 ms. What is the jitter (max − min), in ms?

Solution

Rule used jitter = variation of the delay lesson 1 — 1.1

  1. 2.4 − 1.9 = 0.5 ms.

Answer 0.5 ms

Check yourself
  1. What is the difference between cyclic and acyclic data?

    Cyclic: sent again and again at a fixed rate (I/O); acyclic: sent on request (parameters, diagnostics).

  2. Why is an office network not enough for a motion axis?

    It is not deterministic: the delay and jitter are not bounded.

  3. Which network does Rockwell (Allen-Bradley) use for I/O?

    EtherNet/IP.

2

PROFIBUS DP and PA: the classic fieldbus

30 min
You will learn

how PROFIBUS DP works (RS-485, master-slave polling, token between masters), addresses, speeds and cable lengths, the violet cable and its terminations, the GSD file, DP-V0/V1/V2, PROFIBUS PA for process instruments, and the usual faults.

In one sentence

PROFIBUS DP is an RS-485 bus on which a master asks each slave in turn for its inputs and gives it its outputs; the speed falls when the cable gets longer.

2.1 Masters, slaves and addresses

The DP master (class 1: the PLC) owns the bus. It sends each slave a request telegram with its outputs and the slave answers at once with its inputs: polling. When there are several masters, they pass a token: only the holder may talk. Each station has an address from 0 to 125 (126 is the default of a new device, 127 is broadcast), set by rotary switches or by software. Two stations with the same address make the whole segment fail.

SpeedMax length of a segment
9.6 – 93.75 kbit/s1200 m
187.5 kbit/s1000 m
500 kbit/s400 m
1.5 Mbit/s200 m
3 – 12 Mbit/s100 m

A segment holds at most 32 stations; repeaters add segments (up to 126 stations). The cable is the violet shielded twisted pair, wires A green and B red. At both physical ends of each segment, the switch of the 9-pin connector is set to ON: it connects the terminating resistors (220 Ω between A and B, 390 Ω pull-up and pull-down), fed by the device. A termination switched on in the middle cuts the bus after it; a missing one gives reflections and random errors.

2.2 GSD files and DP versions

  • GSD file: a text file from the manufacturer that describes the device (modules, I/O sizes, speeds, parameters). You import it in TIA Portal, Studio 5000 or CX-Configurator before configuring the slave.
  • DP-V0: cyclic data and diagnostics. DP-V1: plus acyclic read/write of parameters and alarms. DP-V2: plus clock synchronisation and slave-to-slave traffic, for drives.
  • PROFIBUS PA (process automation): same protocol, but a different physical layer, MBP at 31.25 kbit/s, that carries power and data on two wires and can be intrinsically safe for explosive zones (ATEX). A DP/PA coupler links the two.
Worked example

10 slaves with 8 bytes in each direction. One exchange is a request and a response of about 9 + 8 = 17 bytes each, 11 bits per byte (start, 8 data, parity, stop): 2 × 17 × 11 = 374 bits, plus about 120 bits of reaction and idle times ≈ 494 bits. At 1.5 Mbit/s: 0.33 ms per slave, 3.3 ms for the 10. At 500 kbit/s: 9.9 ms. If the cable is 300 m, 1.5 Mbit/s is not allowed (200 m): choose 500 kbit/s, or add a repeater.

In the field

The three classic PROFIBUS faults: a termination wrong (count the ON switches: exactly two per segment), a shield badly connected (it must be clamped wide on both ends and the equipotential bonding must be good), and a duplicate address after replacing a device. A bus tester (Siemens BT200, PROFItrace) measures the resistance between A and B (110 Ω with both terminations, power off) and shows the quality of each station.

The essentials
  • DP master polls each slave: outputs in the request, inputs in the response.
  • Addresses 0–125, 32 stations per segment, 12 Mbit/s at 100 m down to 93.75 kbit/s at 1200 m.
  • Violet cable, A green, B red, termination ON at both ends only.
  • GSD file to configure; PA = same protocol at 31.25 kbit/s, powered, intrinsically safe.

Key terms

  • DP master, DP slave
  • polling, token
  • station address
  • segment, repeater
  • terminating resistor
  • GSD file
  • DP-V0, V1, V2
  • PROFIBUS PA, MBP, intrinsic safety

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

Maximum length of a PROFIBUS DP segment at 500 kbit/s, in m?

Solution

Rule used table of speeds and lengths lesson 2 — 2.1

Answer 400 m

Level 2 · Intermediate2

Power off, both terminations ON: what resistance do you measure between A and B, in Ω?

Solution

Rule used two 220 Ω in parallel lesson 2 — field box

  1. 220 × 220 / (220 + 220) = 110 Ω.
  2. 220 Ω: one termination missing; 73 Ω: one too many.

Answer 110 Ω

Level 3 · Professional3

20 slaves, 500 bits per exchange, 1.5 Mbit/s. Bus cycle time, in ms?

Solution

Rule used cycle = slaves × bits / speed lesson 2 — worked example

  1. 20 × 500 = 10 000 bits.
  2. 10 000 / 1 500 000 = 6.67 ms.

Answer ≈ 6.7 ms

Check yourself
  1. What is the maximum length of a segment at 1.5 Mbit/s?

    200 m.

  2. How many terminations are ON in a correct segment?

    Two, one at each physical end.

  3. What is the GSD file for?

    It describes the slave (modules, I/O, parameters) for the configuration software.

3

Ethernet and IP for automation people

30 min
You will learn

the Ethernet frame and the MAC address, IPv4 addresses, subnet masks and gateways, why a PLC and a PC must be in the same subnet, TCP and UDP and the ports of industrial protocols, and how to set up the address of a PLC and test the link with ping.

In one sentence

Ethernet carries frames from one MAC address to another on the same network; IP gives each device an address and a subnet, and TCP or UDP deliver the data to the right program through a port number.

3.1 The frame and the MAC address

A MAC address (48 bits, written 00:1B:1B:A1:00:01) is burnt into each network port by the manufacturer; the first 3 bytes identify the brand (00:1B:1B is Siemens). The EtherType says what is inside: 0x0800 for IPv4, 0x0806 for ARP, 0x8892 for PROFINET real-time, 0x88A4 for EtherCAT. PROFINET and EtherCAT cyclic data therefore do not use IP at all: it is faster, and it is why a PC with Wireshark sees them but cannot "ping" them.

3.2 IP addresses and subnets

An IPv4 address is 4 bytes: 192.168.0.10. The subnet mask (255.255.255.0, or /24) says which part is the network and which part is the device: here 192.168.0 is the network, 10 the device. Two devices talk directly only if they are in the same subnet; otherwise the frame goes to the gateway (a router). Addresses 0 (network) and 255 (broadcast) of a /24 are reserved: 254 devices per /24.

PLCPCMaskResult
192.168.0.1192.168.0.50255.255.255.0same subnet: OK
192.168.0.1192.168.1.50255.255.255.0different subnets: no connection without a router
192.168.0.1192.168.1.50255.255.0.0same subnet (/16): OK
192.168.0.1192.168.0.1255.255.255.0same address twice: conflict, random failures

When a device wants to send to an IP address in its subnet, it first asks "who has 192.168.0.50?" with an ARP broadcast; the owner answers with its MAC. That is why broadcasts exist on every network, and why too many devices in one subnet create a lot of broadcast traffic.

3.3 TCP, UDP and ports

TCP opens a connection, numbers the bytes, acknowledges and resends what is lost: reliable but with delays. UDP just sends: fast, no resend, good for cyclic data that will be sent again anyway. The port picks the program inside the device.

ProtocolTransport and port
Modbus TCPTCP 502
OPC UATCP 4840
EtherNet/IP explicit / implicit (I/O)TCP 44818 / UDP 2222
S7 communication (ISO-on-TCP)TCP 102
MQTT / MQTT over TLSTCP 1883 / 8883
HTTP / HTTPS (web server of the PLC)TCP 80 / 443
PROFINET RT, EtherCATno IP: directly in the Ethernet frame
Worked example

A technician cannot go online with an S7-1200 at 192.168.0.1 /24. His laptop has 10.20.30.5 /24 from the office network. Fix: give the laptop a fixed address in the same subnet, for example 192.168.0.200 /24, no gateway needed. Test: ping 192.168.0.1 answers, then TIA Portal finds the PLC. Check first that .200 is not already used by another device of the machine.

The essentials
  • MAC address: burnt in, 48 bits, used inside one network; EtherType says what the frame carries.
  • IP + mask: same subnet to talk directly, otherwise through a gateway; never two identical addresses.
  • TCP reliable, UDP fast; the port picks the service (502 Modbus, 4840 OPC UA, 44818 and 2222 EtherNet/IP).
  • PROFINET RT and EtherCAT cyclic data skip IP for speed.

Key terms

  • MAC address
  • EtherType
  • IPv4 address, subnet mask
  • gateway, router
  • ARP, broadcast
  • TCP, UDP, port
  • ping

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

Which address can a PC use to talk to a PLC at 192.168.0.1 /24 without a router?

  1. 192.168.0.50
  2. 192.168.1.50
  3. 192.168.0.1
  4. 10.0.0.50

Solution

Rule used same network part (/24 = first 3 bytes), different device part lesson 3 — 3.2

  1. 192.168.0.1 is taken by the PLC itself.

Answer A

Level 2 · Intermediate2

How many device addresses in a /24 subnet?

Solution

Rule used 256 − network − broadcast lesson 3 — 3.2

Answer 254

Level 2 · Intermediate3

A SCADA reads a meter with Modbus TCP. Which port must the firewall open?

Solution

Rule used ports of industrial protocols lesson 3 — 3.3

Answer TCP 502

Check yourself
  1. PLC 192.168.10.5 /24 and HMI 192.168.11.5 /24: can they talk directly?

    No: different subnets (192.168.10 and 192.168.11).

  2. Which port does OPC UA use by default?

    TCP 4840.

  3. Why can you not ping PROFINET cyclic data?

    They travel directly in Ethernet frames (EtherType 0x8892), without IP.

4

Switching: how a switch moves frames, and VLANs

30 min
You will learn

how a switch learns MAC addresses and forwards frames, flooding of unknown and broadcast frames, full duplex and why there are no more collisions, store-and-forward and cut-through, priorities (802.1p), VLANs (802.1Q), managed and unmanaged switches, port mirroring, IGMP snooping and LLDP.

In one sentence

A switch reads the source MAC of each frame to learn which device is behind which port, and then sends each frame only to the port of its destination; what it does not know, it floods.

4.1 The MAC address table

  1. A frame arrives on port 3 from MAC A: the switch writes "A → port 3" in its table (it forgets entries not seen for 300 s).
  2. It looks for the destination MAC B. If B is in the table, the frame goes out of that port only.
  3. If B is unknown, or if it is a broadcast (FF:FF:FF:FF:FF:FF) or a multicast, the frame is copied to all the other ports: flooding.

Each port is a separate link in full duplex: send and receive at the same time, no collisions, unlike the old hubs. A store-and-forward switch receives the whole frame, checks its FCS and then forwards it (delay ≈ 6.7 µs per hop for a minimal frame at 100 Mbit/s, about 120 µs for a 1500-byte frame); a cut-through switch starts forwarding as soon as it has read the destination, which PROFINET IRT and EtherCAT devices use to keep the delay per hop small.

delay through a line of n switches ≈ n × (frame time + switch latency)

4.2 Priorities and VLANs

A VLAN (IEEE 802.1Q) cuts one physical switch into several logical networks: a frame of VLAN 10 never goes out of a port of VLAN 20, broadcasts included. The 4-byte tag carries the VLAN number (1–4094) and a priority of 0 to 7 (802.1p): PROFINET RT frames use priority 6, so a switch with queues sends them before a file transfer. A port that carries several VLANs to another switch is a trunk; a port for one device is an access port.

4.3 Managed switches in a plant

FunctionWhy it matters on a machine
VLAN, QoSseparate the machine from the office, give priority to I/O traffic
IGMP snoopingsend multicast only where it is wanted: essential with EtherNet/IP, whose I/O can be multicast
LLDPeach device tells its neighbour who it is: PROFINET uses it to check the topology and to give a name to a replaced device automatically
Port mirroringcopy the traffic of a port to a laptop with Wireshark, for diagnostics
SNMP, web, diagnosticssee port errors, cable length, link down alarms in the HMI or SCADA
MRP, RSTPring redundancy (lesson 6)

Industrial switches (Siemens SCALANCE, Hirschmann, Phoenix Contact, Moxa, Rockwell Stratix) add a 24 V DC supply (often redundant), DIN-rail mounting, −40 to 70 °C, an alarm contact and certified PROFINET or EtherNet/IP functions. An office switch in a cabinet works on the bench and fails in summer, or floods the I/O network with multicast.

The essentials
  • A switch learns source MACs and forwards to one port; unknown destinations and broadcasts are flooded.
  • Full duplex: no collisions; store-and-forward checks the frame, cut-through is faster.
  • VLANs separate networks on one switch; priority 6 for PROFINET RT.
  • In a plant: managed industrial switches with IGMP snooping, LLDP, port mirroring and diagnostics.

Key terms

  • switch, hub
  • MAC address table, ageing
  • flooding, broadcast, multicast
  • full duplex
  • store-and-forward, cut-through
  • VLAN, trunk, access port
  • QoS, 802.1p priority
  • IGMP snooping, LLDP, port mirroring

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

A switch has just been powered on and receives a frame for the drive. What does it do?

  1. It floods it to all other ports and learns the sender
  2. It drops it
  3. It sends it back
  4. It waits for the drive to speak

Solution

Rule used unknown destination → flooding; source → learning lesson 4 — 4.1

Answer A

Level 2 · Intermediate2

Time on the wire of a 1518-byte frame (+ 20 bytes preamble and gap) at 100 Mbit/s, in µs?

Solution

Rule used time = bits / bit rate lesson 4 — 4.1

  1. 1538 × 8 = 12 304 bits.
  2. 12 304 / 100 000 000 = 123 µs: a store-and-forward switch adds that much per hop.

Answer ≈ 123 µs

Level 2 · Intermediate3

What does a VLAN do to broadcasts?

  1. It keeps them inside the VLAN
  2. It blocks all of them
  3. It sends them to every VLAN
  4. It turns them into unicast

Solution

Rule used a VLAN is a separate logical network lesson 4 — 4.2

Answer A

Check yourself
  1. What does a switch do with a frame whose destination it does not know?

    It floods it: copies it to every port except the one it came from (in the same VLAN).

  2. How does a switch learn where a device is?

    From the source MAC address of the frames that device sends.

  3. Why is IGMP snooping needed with EtherNet/IP?

    Multicast I/O would otherwise be flooded to every port and overload the devices.

5

PROFINET: I/O over Ethernet

35 min
You will learn

the roles (IO controller, IO device, IO supervisor), the GSDML file, device names and DCP, how the controller gives the IP addresses, the update time and the watchdog, RT and IRT and the conformance classes, alarms and diagnostics, replacing a device, PROFIsafe, and how to compute the load of a PROFINET network.

In one sentence

In PROFINET each device is known by its name; at start-up the controller finds it by that name, gives it its IP address and parameters, then both exchange their I/O every update time and watch each other with a watchdog.

5.1 Roles, names and start-up

  • IO controller: the PLC (S7-1500, S7-1200, but also Beckhoff, Phoenix, Omron NX with PROFINET). IO device: remote I/O (ET 200SP), drive (SINAMICS G120), valve terminal, robot, camera. IO supervisor: the engineering PC or HMI for diagnostics.
  • The GSDML file (XML) describes the device, like the GSD of PROFIBUS. Import it, drag the device into the network view, connect it to the controller.
  • Each device has a device name ("conveyor-1"), stored in the device. The controller searches the name with the DCP protocol, then assigns the IP address of the project. A new device out of its box has no name: you give it one once ("Assign device name"), or the controller does it through the topology (LLDP neighbours).

5.2 Update time and watchdog

The update time (0.25 to 512 ms in RT, often 1 to 8 ms) is how often the controller and the device send each other their cyclic frames, each in its own direction. Each frame carries, besides the data, status bytes (IOPS, IOCS) that say whether the values are good. If a device receives no valid frame during the watchdog time, it sets its outputs to their substitute value (usually 0: motors stop) and the controller reports the failure (BF LED, OB86 on Siemens). By default the watchdog is 3 update times.

watchdog time = update time × accepted cycles without I/O data   (4 ms × 3 = 12 ms)

ClassWhat it addsTypical use
RT (CC-A)cyclic real-time frames with priority 6, any standard switchremote I/O, drives in speed mode, 1–10 ms
CC-BLLDP topology, SNMP diagnostics, mandatory for process and most machinesautomatic device replacement, network diagnostics
IRT (CC-C)reserved time slots planned in advance, special switches in the devices, jitter < 1 µssynchronised motion axes, 0.25–1 ms

Alarms travel acyclically: a module signals a wire break, a short circuit, a missing supply, and the PLC calls a diagnostic interrupt (OB82). PROFIsafe sends safety data (an emergency stop, a light curtain, a safe torque off) in the same frames as the standard data, with its own counter, checksum and watchdog: the network is a "black channel", the safety does not depend on it. A failsafe CPU (S7-1500F) and F-modules are needed.

Worked example

A line with 64 devices, update time 2 ms. Each device sends one frame each way per cycle, minimal size 84 bytes on the wire (lesson 3). In one direction, on the port of the controller: 64 × 84 × 8 = 43 008 bits every 2 ms = 21.5 Mbit/s, that is 21.5 % of a 100 Mbit/s full-duplex link: acceptable. The rule of thumb is to keep cyclic traffic under about 50 % of each link: with frames bigger than the minimum or an update time of 1 ms, you get close. Solutions: 4 ms for slow devices, several controller ports, or a 1 Gbit/s backbone.

The essentials
  • Controller, device, supervisor; GSDML to configure; the device is found by its name (DCP), the controller gives the IP.
  • Update time 1–8 ms typical; watchdog = update × factor (3 by default): outputs go to substitute values.
  • RT for I/O, CC-B for topology and diagnostics, IRT for synchronised motion.
  • PROFIsafe: safety data in the same frames, network as a black channel.

Key terms

  • IO controller, IO device, IO supervisor
  • GSDML file
  • device name, DCP
  • update time, watchdog time
  • RT, IRT, conformance class
  • substitute value
  • diagnostic alarm
  • PROFIsafe, black channel

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

Update time 2 ms, watchdog factor 3: watchdog time, in ms?

Solution

Rule used watchdog = update × factor lesson 5 — 5.2

Answer 6 ms

Level 2 · Intermediate2

A replaced ET 200SP does not start. LEDs: BF on. What is the most likely cause?

  1. The new device has no device name (or a wrong one)
  2. The PLC program has a bug
  3. The switch is too fast
  4. PROFIsafe is missing

Solution

Rule used the controller finds devices by name (DCP) lesson 5 — 5.1

  1. Assign the name, or use automatic replacement with LLDP topology (CC-B).

Answer A

Level 3 · Professional3

100 devices, update time 1 ms, 84-byte frames: load in one direction on a 100 Mbit/s port, in %?

Solution

Rule used load = devices × bits per frame / update time / bit rate lesson 5 — worked example

  1. 100 × 84 × 8 = 67 200 bits per ms = 67.2 Mbit/s.
  2. 67.2 % > 50 %: too high, use 2 ms or a gigabit backbone.

Answer 67.2 %

Check yourself
  1. How does the controller find a PROFINET device at start-up?

    By its device name, with DCP; then it assigns its IP address.

  2. Update time 8 ms, factor 3: after how long does a device go to its safe state when the cable is cut?

    24 ms.

  3. Why can PROFIsafe use a standard network?

    Its own counter, checksum and watchdog detect every network fault: the network is a black channel.

6

Topologies, redundancy and cabling

25 min
You will learn

line, star, tree and ring topologies and the switches built into devices, ring redundancy with MRP and RSTP and their recovery times, why the watchdog must be longer than the recovery time, media redundancy without interruption, and industrial cabling: cable categories, M12 D- and X-coded connectors, shielding, lengths and fibre.

In one sentence

Most industrial devices have a 2-port switch inside, so they can be chained in a line; closing the line into a ring and letting MRP block one port gives a network that survives one broken cable.

TopologyForAgainst
Linefew cables, follows the machineone broken cable or one device off loses everything after it; delay adds up
Stareach device independent, easy to diagnosemany cables and switch ports
Treestar of lines: one branch per machine sectionthe central switch is a single point of failure
Ringsurvives one broken linkneeds MRP, DLR or RSTP; a short interruption at the break

6.1 Ring redundancy

Ethernet forbids loops: a broadcast would turn forever. In MRP (Media Redundancy Protocol, IEC 62439-2, used by PROFINET) one device is the ring manager (MRM): it keeps one of its two ring ports blocked and sends test frames around the ring. If the test frames stop coming back, a link is broken: the manager opens its port and tells the switches to forget their MAC tables. Guaranteed recovery time: 200 ms for up to 50 devices (profiles of 500, 30 and 10 ms also exist). RSTP (IEEE 802.1w) does the same for any mesh, but its recovery is less predictable. DLR (Device Level Ring) is the EtherNet/IP equivalent, about 3 ms for 50 devices.

During the recovery, frames are lost. If the PROFINET watchdog of the devices is shorter than the recovery time, they all fail even though the ring did its job. Rule: watchdog > ring recovery time, for example update 4 ms × factor 60 = 240 ms > 200 ms (TIA Portal proposes it when MRP is on). Where no interruption is allowed (synchronised axes), MRPD sends every frame both ways around the ring: zero switchover time, IRT only.

6.2 Industrial cabling

  • Copper: 100 m maximum between two ports. PROFINET cable is green, 4 wires (100 Mbit/s), shielded, type A (fixed), B (flexible) or C (trailing chain). Gigabit needs 8 wires, Cat 6.
  • Connectors: RJ45 in the cabinet (industrial versions with a metal housing), M12 D-coded (4 pins, 100 Mbit/s) on the machine, M12 X-coded (8 pins) for 1–10 Gbit/s. A field-assembled connector with insulation displacement is quick, but must be tested.
  • Shield and earth: shield connected at both ends, a good equipotential bonding between cabinets (otherwise a current flows in the shield), data cables at least 20 cm away from motor cables, crossing them at right angles.
  • Fibre: between buildings, over 100 m, or across strong electrical noise and different earth potentials: multimode up to about 2–3 km, single-mode tens of km.
In the field

Most "network problems" on a machine are cables: a connector badly crimped, a cable crushed in a cable chain, a shield not clamped. A managed switch or the PLC diagnostics show the counters of CRC errors per port; a cable tester certifies a link. Look at those before suspecting the program.

The essentials
  • Devices with 2 ports allow lines; a ring with MRP survives one cut in ≤ 200 ms.
  • The PROFINET watchdog must be longer than the ring recovery time.
  • DLR for EtherNet/IP, RSTP for meshes, MRPD for zero switchover.
  • 100 m of copper, M12 D-coded on the machine, shield at both ends, fibre between buildings.

Key terms

  • line, star, tree, ring
  • MRP, ring manager (MRM)
  • recovery time
  • RSTP, DLR, MRPD
  • M12 D-coded, X-coded
  • shield, equipotential bonding
  • multimode, single-mode fibre

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

In a PROFINET ring, which device keeps a port blocked?

  1. The MRP ring manager
  2. Every device
  3. The last device of the line
  4. None

Solution

Rule used the MRM blocks one ring port to avoid a loop lesson 6 — 6.1

Answer A

Level 2 · Intermediate2

MRP recovery 200 ms, update time 8 ms. Smallest whole watchdog factor that does not trip?

Solution

Rule used update × factor > 200 ms lesson 6 — 6.1

  1. 200 / 8 = 25; 25 × 8 = 200 is not strictly more.
  2. 26 × 8 = 208 ms > 200 ms.

Answer 26

Level 2 · Intermediate3

Which connector for 100 Mbit/s Ethernet on a machine (IP67)?

  1. M12 D-coded
  2. M12 A-coded
  3. RJ11
  4. Sub-D 9

Solution

Rule used D-coded: 4 pins, 100 Mbit/s; X-coded: 8 pins, gigabit; A-coded: sensors lesson 6 — 6.2

Answer A

Check yourself
  1. Why does the ring manager keep one port blocked?

    To avoid a loop, in which broadcasts would circulate forever.

  2. MRP recovery is 200 ms, update time 4 ms. What watchdog factor at least?

    More than 50 (for example 60: 240 ms).

  3. What is the maximum length of a copper Ethernet link?

    100 m between two ports.

7

OPC UA and MQTT: data for supervision and the cloud

35 min
You will learn

why OPC UA exists, client and server, the address space (nodes, NodeIds, objects, variables, methods), the services Browse, Read, Write, Call, subscriptions with sampling interval, publishing interval and deadband, security (certificates, Sign and SignAndEncrypt, users), companion specifications, PubSub, and MQTT with its broker, topics and QoS.

In one sentence

OPC UA lets any client, from any brand, discover what a machine contains and read, write or subscribe to its data securely; MQTT pushes messages through a broker to whoever subscribed to a topic.

7.1 Client, server and address space

The old OPC (now "Classic", 1996) ran only on Windows (DCOM) and was hard to secure. OPC UA (Unified Architecture, IEC 62541) is platform-independent: the server can live in the PLC itself (S7-1500, S7-1200 since firmware 4.4, Omron NX, Beckhoff TwinCAT, Codesys, B&R), in an edge PC or in a SCADA. The client (SCADA, MES, a Python script) connects to opc.tcp://192.168.0.10:4840.

Everything in the server is a node with a NodeId (ns=3;s="Tank_T101"."Level": namespace 3, string identifier), a class (Object, Variable, Method…), attributes (value, data type, timestamp, status code) and references to other nodes. The client does not need a list of addresses: it browses the tree, as in a file explorer. Each value comes with a status (Good, Uncertain, Bad) and a source timestamp: a client always knows whether a value can be trusted.

7.2 Subscriptions

Reading 2000 variables every 500 ms by polling wastes bandwidth. With a subscription the client says once what it wants; the server samples each monitored item at its sampling interval, keeps only the changes larger than the deadband, and sends them grouped in one notification every publishing interval. A tank level that does not move costs nothing.

# a minimal OPC UA client in Python (library asyncua)
import asyncio
from asyncua import Client

class Handler:
    def datachange_notification(self, node, val, data):
        print("level =", val)

async def main():
    async with Client("opc.tcp://192.168.0.10:4840") as c:   # add certificates in production
        level = c.get_node('ns=3;s="Tank_T101"."Level"')
        print(await level.read_value())
        sub = await c.create_subscription(1000, Handler())   # publishing interval 1000 ms
        await sub.subscribe_data_change(level)
        await asyncio.sleep(60)

asyncio.run(main())

7.3 Security and information models

  • Security mode: None (only for tests), Sign (messages cannot be modified), SignAndEncrypt (and cannot be read). Client and server exchange X.509 certificates and must trust each other: on the first connection you accept the certificate of the client in the PLC.
  • User authentication: anonymous, user name and password, or certificate; give each user only the rights it needs (read only for a dashboard).
  • Companion specifications define the same tree for a whole family of machines: OPC UA for Machinery, Robotics (OPC 40010), Euromap 77 for injection moulding, PackML for packaging, PA-DIM for instruments. A MES then reads "the state of the robot" the same way on an ABB, a KUKA or a Fanuc.
  • PubSub: the server publishes without a client connection, over UDP or through an MQTT broker; with TSN (time-sensitive networking) it aims at real-time between controllers.

7.4 MQTT

MQTT is a light publish/subscribe protocol: devices publish messages on a topic (plant1/line2/filler/level) to a broker (Mosquitto, HiveMQ, a cloud service); every client subscribed to that topic receives them. Only outgoing connections from the plant: easy to pass a firewall. QoS 0 (at most once), 1 (at least once), 2 (exactly once). MQTT says nothing about the content: Sparkplug B adds a standard payload, birth and death messages and state, to make it usable in industry.

OPC UA (client/server)MQTT
Modelthe client asks the server, rich information modelpublish/subscribe through a broker, free content
Best forSCADA, MES, between machines of different brandsmany devices to the cloud, unreliable links
Securitycertificates, users, built inTLS and broker access rights
The essentials
  • OPC UA: a server (often in the PLC) with a browsable tree of nodes; clients Browse, Read, Write, Call.
  • Subscriptions: sampling interval, deadband, publishing interval: only changes travel.
  • Use SignAndEncrypt, certificates and users with minimal rights; None only on the bench.
  • MQTT: publish/subscribe to topics through a broker; Sparkplug B for industrial content.

Key terms

  • OPC UA client, server
  • address space, node, NodeId, namespace
  • Browse, Read, Write, Call
  • subscription, monitored item
  • sampling interval, publishing interval, deadband
  • security mode, X.509 certificate
  • companion specification
  • MQTT broker, topic, QoS, Sparkplug B

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

Which port does an OPC UA server listen on by default?

Solution

Rule used opc.tcp://…:4840 lesson 7 — 7.1

Answer 4840

Level 2 · Intermediate2

A temperature changes by 0.1 °C every second. Deadband 0.5 °C, sampling 1 s. About how many notifications per minute?

Solution

Rule used a notification only when the change since the last one exceeds the deadband lesson 7 — 7.2

  1. It takes about 6 s to move more than 0.5 °C (0.6 °C).
  2. 60 / 6 = 10 instead of 60.

Answer ≈ 10

Level 2 · Intermediate3

With MQTT, which piece receives every message and passes it to the subscribers?

  1. The broker
  2. The PLC
  3. The switch
  4. The OPC UA server

Solution

Rule used publish/subscribe through a broker lesson 7 — 7.4

Answer A

Check yourself
  1. What does the deadband of a monitored item do?

    It ignores changes smaller than its value, so fewer notifications are sent.

  2. Which security mode protects against reading AND modifying the messages?

    SignAndEncrypt.

  3. Who receives an MQTT message published on a topic?

    Every client subscribed to that topic on the broker.

8

EtherNet/IP, EtherCAT, Modbus TCP, security and diagnostics

35 min
You will learn

how EtherNet/IP (CIP, RPI, implicit and explicit messages, EDS), EtherCAT (processing on the fly, distributed clocks, ESI) and Modbus TCP work and how they compare to PROFINET, gateways between networks, cybersecurity of plants (IEC 62443, zones and conduits, defence in depth), and a method to diagnose an industrial network with Wireshark.

In one sentence

All industrial Ethernets use the same cables and frames but organise the cyclic exchange differently; the plant network must then be cut into zones so that a problem in the office never reaches a machine.

8.1 The other industrial Ethernets

  • EtherNet/IP (ODVA; Rockwell, Omron): the CIP protocol over standard TCP/IP. The scanner (PLC) opens connections to adapters; cyclic I/O (implicit messages) goes over UDP 2222 at the RPI (requested packet interval, e.g. 10 ms), parameters (explicit messages) over TCP 44818. Devices are described by EDS files; I/O may be multicast, hence IGMP snooping (lesson 4). DLR for rings, CIP Safety for safety, CIP Motion for axes.
  • EtherCAT (Beckhoff, ETG): one frame leaves the master and passes through every slave, which reads its outputs and writes its inputs on the fly, in hardware, with a delay of about a microsecond, then the frame comes back. 1000 digital I/O in about 30 µs, cycles of 100 µs or less, distributed clocks synchronised under 1 µs. Devices described by ESI files. Used in robots, CNC, packaging; the master can be a standard PC network card.
  • Modbus TCP: the Modbus functions of RTU (03 read holding registers, 06 and 16 write…) inside TCP port 502, with a 7-byte MBAP header instead of the CRC. Simple, open, understood by every brand, but polled by the client and not deterministic: fine for meters, drives, a gateway, not for fast I/O.
PROFINET RTEtherNet/IPEtherCATModbus TCP
Cyclic transportEthernet frame, 0x8892UDP/IPEthernet frame, 0x88A4, on the flyTCP/IP, polled
Typical cycle1–8 ms (IRT 0.25 ms)2–100 ms50 µs–1 ms10–1000 ms
Device fileGSDMLEDSESInone (register map in the manual)
Standard switchesyes (not IRT)yes, IGMP snoopingno, only between segmentsyes
RingMRPDLRcable redundancyRSTP

When two worlds meet (a Modbus RTU meter on a PROFINET PLC, an EtherNet/IP robot in a Siemens line), a gateway (Anybus, HMS, a PN/PN coupler) or a second interface in the PLC copies the data between the two networks. Keep it simple: one gateway per need, and document the mapping of every byte.

8.2 Cybersecurity of a plant

PLCs were designed to be open: anyone on the network can often read, write or stop them. Stuxnet (2010) reprogrammed Siemens PLCs; ransomware in the office has stopped many factories because the networks were flat. The standard IEC 62443 asks to cut the plant into zones (office, DMZ, cell) linked by conduits that are controlled (firewalls that let through only the needed protocols), and to apply defence in depth: several barriers, none of them trusted alone.

  1. No direct link from the office or internet to a PLC; remote access only through a VPN ending in the DMZ, with logging and a person who approves.
  2. Turn on the protections of the PLC: access level with password, write protection, web server off if not used, OPC UA with SignAndEncrypt.
  3. Close unused switch ports, keep an inventory of every device and firmware, back up the programs, and plan updates in the stops of production.

8.3 Diagnosing a network

  1. Look at the LEDs (link, activity, BF/ERROR) and the diagnostics of the PLC: which device, which port, since when.
  2. Check the configuration: names, IP addresses, subnet masks, no duplicate (an "Accessible devices" scan in TIA Portal, or the DHCP/BOOTP tool for EtherNet/IP).
  3. Read the port counters of the switches: CRC errors point to a cable or a connector.
  4. Capture with Wireshark on a mirror port or a TAP: filter pn_rt, enip, ecat, mbtcp, opcua; look at the cycle times, missing frames, alarms, broadcast storms.
Worked example

Every day around 10:00 three ET 200SP stations of a line drop out for a second. The PLC shows "device failure" then "device return"; the CRC counters are at 0. A Wireshark capture on a mirror port shows a burst of 30 Mbit/s of multicast video at that moment: the quality camera, added last month on the same flat network, uploads its images. Fixes: a VLAN for the camera, IGMP snooping, priority for PROFINET, and a watchdog factor adapted. Lesson: the network of a machine is part of its design, not an afterthought.

Back to PLC programming: the industrial automation course →

The essentials
  • EtherNet/IP: CIP over UDP/TCP, RPI, EDS, DLR; EtherCAT: on the fly, µs cycles, ESI; Modbus TCP: simple, port 502, polled.
  • Gateways join networks; document every byte.
  • IEC 62443: zones and conduits, firewalls, DMZ, VPN, PLC protections, inventory, defence in depth.
  • Diagnose: LEDs and PLC diagnostics, configuration, port counters, then Wireshark on a mirror port.

Key terms

  • EtherNet/IP, CIP, scanner, adapter
  • RPI, implicit and explicit messages, EDS
  • EtherCAT, processing on the fly, distributed clocks, ESI
  • Modbus TCP, MBAP header
  • gateway
  • IEC 62443, zone, conduit, DMZ
  • defence in depth, VPN
  • Wireshark, mirror port, TAP

Exercises

Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.

Level 1 · Beginner1

Which network passes one frame through all slaves, processed on the fly?

  1. EtherCAT
  2. Modbus TCP
  3. EtherNet/IP
  4. MQTT

Solution

Rule used processing on the fly lesson 8 — 8.1

Answer A

Level 2 · Intermediate2

An EtherNet/IP connection has an RPI of 20 ms. How many I/O packets per second in one direction?

Solution

Rule used packets per second = 1 / RPI lesson 8 — 8.1

Answer 50

Level 2 · Intermediate3

A supplier needs remote access to a PLC. What is the right solution?

  1. A VPN ending in the DMZ, approved and logged, then a controlled conduit to the cell
  2. A port forwarding from the internet to the PLC
  3. A 4G router plugged into the machine switch
  4. Give him the office Wi-Fi password

Solution

Rule used IEC 62443: zones, conduits, no direct path lesson 8 — 8.2

Answer A

Check yourself
  1. What is the RPI in EtherNet/IP?

    The requested packet interval: the period of the cyclic I/O of a connection.

  2. Why is EtherCAT so fast?

    One frame passes through all slaves, each reads and writes its data on the fly in hardware.

  3. Where should a remote-access VPN end in a plant?

    In the DMZ, never directly in the cell zone of the machines.

Glossary

All the words of the course in one place.

TermMeaning
FieldbusA serial network between a PLC and its sensors, drives and remote I/O (PROFIBUS, CAN, Modbus RTU).
Cyclic dataI/O data sent again and again at a fixed rate.
JitterThe variation of the delivery time from one cycle to the next.
GSD / GSDML / EDS / ESIDevice description files of PROFIBUS, PROFINET, EtherNet/IP and EtherCAT.
TerminationResistors at both ends of an RS-485 bus against reflections.
MAC address48-bit hardware address of a network port.
Subnet maskSays which part of an IP address is the network (255.255.255.0 = /24).
Port (TCP/UDP)Number that picks the service in a device: 502 Modbus, 4840 OPC UA.
SwitchDevice that learns MAC addresses and forwards each frame to the right port.
FloodingCopying a frame with an unknown destination, or a broadcast, to every port.
VLANA logical network inside a switch (IEEE 802.1Q), with a priority field.
Device name (PROFINET)The name by which the controller finds a device (DCP) and gives it its IP.
Update timeThe period of the cyclic PROFINET exchange.
Watchdog timeUpdate time × factor; without data for that long, outputs go to their safe value.
MRPMedia Redundancy Protocol: a ring with a manager that blocks one port; recovery ≤ 200 ms.
OPC UASecure client/server standard to browse, read, write and subscribe to machine data.
SubscriptionOPC UA mechanism where the server sends only changes, at a publishing interval.
MQTTLight publish/subscribe protocol through a broker, with topics and QoS.
RPIRequested packet interval: the I/O period of an EtherNet/IP connection.
Processing on the flyEtherCAT: each slave reads and writes the passing frame in hardware.
IEC 62443Standard for the cybersecurity of industrial systems: zones, conduits, security levels.
DMZBuffer zone between office and plant networks, where shared servers live.

Sources and references

This course was written from these books, papers, standards and documentation. They are also the best way to go further.

  1. PROFIBUS & PROFINET International (PI), PROFINET System Description and PROFIBUS System Description; IEC 61158 and IEC 61784 (fieldbus profiles). used for: PROFIBUS and PROFINET: roles, names, update time, conformance classes
  2. IEC 62439-2:2016, Industrial communication networks — High availability automation networks — Part 2: Media Redundancy Protocol (MRP). used for: ring redundancy and recovery times
  3. IEC 62541 / OPC Foundation, OPC Unified Architecture Specification, parts 1–14 (address space, services, subscriptions, security, PubSub). used for: OPC UA nodes, services and subscriptions
  4. OASIS, MQTT Version 5.0, 2019; Eclipse Foundation, Sparkplug Specification 3.0. used for: MQTT and Sparkplug B
  5. ODVA, The CIP Networks Library, Volume 2: EtherNet/IP Adaptation of CIP; EtherCAT Technology Group, EtherCAT — the Ethernet fieldbus. used for: EtherNet/IP and EtherCAT
  6. IEC 62443-3-3:2013, Industrial communication networks — Network and system security — System security requirements and security levels. used for: zones, conduits and security levels

You can now design, configure and debug the network of a plant!

Next: put it into practice with the automation projects, or go back to the communication course to see every bit of RS-485 and Modbus on a logic analyser.

Go to the automation projects → Home page