0
0
FreertosHow-ToBeginner · 4 min read

How to Connect PLC to HMI: Step-by-Step Guide

To connect a PLC to an HMI, first select a common communication protocol like Modbus or Ethernet/IP. Then configure the PLC and HMI with matching settings such as IP addresses and registers, and program the PLC to share data that the HMI will display.
📐

Syntax

Connecting a PLC to an HMI involves setting up communication parameters and programming data exchange. Key parts include:

  • Communication Protocol: Defines how devices talk (e.g., Modbus TCP, Ethernet/IP).
  • IP Address: Network address for each device to identify each other.
  • Data Registers: Memory locations in the PLC holding values to send or receive.
  • Polling or Messaging: How the HMI requests or receives data from the PLC.
text
PLC Configuration:
- Set IP: 192.168.1.10
- Protocol: Modbus TCP
- Data Registers: Holding Registers 40001-40010

HMI Configuration:
- Set IP: 192.168.1.20
- Protocol: Modbus TCP
- Poll Registers: 40001-40010
💻

Example

This example shows a simple Modbus TCP connection setup between a PLC and an HMI. The PLC shares a temperature value in register 40001, and the HMI reads and displays it.

plaintext
/* PLC Side (Structured Text) */
VAR
  Temperature : INT := 250; // 25.0 degrees Celsius (scaled by 10)
END_VAR

// Map Temperature to Modbus Holding Register 40001
Modbus_Holding_Registers[40001] := Temperature;

/* HMI Side Configuration (Example) */
// Protocol: Modbus TCP
// PLC IP: 192.168.1.10
// Read Holding Register 40001
// Display value as Temperature / 10 = degrees Celsius
Output
HMI Display: Temperature = 25.0 °C
⚠️

Common Pitfalls

Common mistakes when connecting PLC to HMI include:

  • Mismatched Protocols: Using different communication protocols on PLC and HMI causes no connection.
  • Incorrect IP Settings: Wrong IP addresses or subnet masks prevent devices from communicating.
  • Wrong Register Mapping: Reading or writing to incorrect registers leads to wrong or no data shown.
  • Firewall or Network Issues: Network blocks or firewalls can stop communication.
plaintext
/* Wrong way: PLC uses Modbus TCP but HMI uses Ethernet/IP */
// No communication established

/* Right way: Both use Modbus TCP with matching IPs and registers */
// Communication works and data is exchanged
📊

Quick Reference

StepDescription
1Choose a common communication protocol (e.g., Modbus TCP, Ethernet/IP)
2Assign IP addresses to PLC and HMI on the same network
3Configure PLC registers to share data
4Set HMI to read/write the correct registers
5Test communication and verify data display

Key Takeaways

Use the same communication protocol on both PLC and HMI for compatibility.
Configure matching IP addresses and network settings to enable connection.
Map PLC data registers correctly so HMI reads the intended values.
Test the connection early to catch network or configuration issues.
Avoid firewall or network blocks that can stop PLC-HMI communication.