Bird
Raised Fist0
PLC Programmingscripting~5 mins

PLC-to-PLC communication in PLC Programming

Choose your learning style10 modes available
Introduction
PLC-to-PLC communication lets two or more controllers share data to work together smoothly.
When one machine needs to tell another machine to start or stop.
When sharing sensor data between different parts of a factory line.
When coordinating actions between robots and conveyors.
When sending status updates from one PLC to another for monitoring.
When controlling multiple machines from a central PLC.
Syntax
PLC Programming
(* Example: Sending a BOOL from PLC1 to PLC2 using Modbus TCP *)
// On PLC1 (Sender):
ModbusWriteCoil(Address := 1, CoilNumber := 10, Value := StartSignal);

// On PLC2 (Receiver):
StartSignal := ModbusReadCoil(Address := 1, CoilNumber := 10);
PLC communication often uses protocols like Modbus TCP, Ethernet/IP, or Profinet.
Addresses and coil numbers depend on your network and PLC setup.
Examples
This sends a start signal to another PLC at coil number 5.
PLC Programming
(* Send a BOOL signal *)
ModbusWriteCoil(Address := 1, CoilNumber := 5, Value := MotorStart);
This reads the start signal from another PLC.
PLC Programming
(* Read a BOOL signal *)
MotorStart := ModbusReadCoil(Address := 1, CoilNumber := 5);
This sends a speed setpoint value as an integer.
PLC Programming
(* Send an INT value *)
ModbusWriteRegister(Address := 1, RegisterNumber := 20, Value := SpeedSetpoint);
This reads the speed setpoint value from another PLC.
PLC Programming
(* Read an INT value *)
SpeedSetpoint := ModbusReadRegister(Address := 1, RegisterNumber := 20);
Sample Program
This example shows PLC1 sending a start signal to PLC2. PLC2 reads the signal and starts a motor if the signal is TRUE.
PLC Programming
(* Simple PLC-to-PLC communication example using Modbus TCP *)
PROGRAM PLC1_Sender
VAR
  StartSignal : BOOL := TRUE;
END_VAR

// Send start signal to PLC2
ModbusWriteCoil(Address := 1, CoilNumber := 10, Value := StartSignal);
END_PROGRAM

PROGRAM PLC2_Receiver
VAR
  StartSignal : BOOL := FALSE;
  MotorRunning : BOOL;
END_VAR

// Read start signal from PLC1
StartSignal := ModbusReadCoil(Address := 1, CoilNumber := 10);

// Use the signal to start a motor
IF StartSignal THEN
  MotorRunning := TRUE;
ELSE
  MotorRunning := FALSE;
END_IF;
END_PROGRAM;
OutputSuccess
Important Notes
PLC communication requires network setup and matching protocols on both sides.
Test communication with simple BOOL signals before sending complex data.
Always handle communication errors to avoid machine faults.
Summary
PLC-to-PLC communication shares data between controllers for teamwork.
Use protocols like Modbus TCP to send and receive signals or values.
Start simple and test signals before complex data exchange.

Practice

(1/5)
1. What is the main purpose of PLC-to-PLC communication?
easy
A. To share data between controllers for coordinated control
B. To program the PLC using a computer
C. To power the PLC devices
D. To store data permanently in the PLC

Solution

  1. Step 1: Understand PLC communication basics

    PLC-to-PLC communication allows multiple controllers to exchange data and work together.
  2. Step 2: Identify the main goal

    The main goal is to share data for coordinated control, not programming or power supply.
  3. Final Answer:

    To share data between controllers for coordinated control -> Option A
  4. Quick Check:

    PLC communication = data sharing [OK]
Hint: PLC communication means controllers talk to share data [OK]
Common Mistakes:
  • Confusing communication with programming
  • Thinking PLC communication powers devices
  • Assuming it stores data permanently
2. Which of the following is the correct syntax to define a Modbus TCP client in a PLC script?
easy
A. modbusClient = ModbusTCPClient('192.168.1.10')
B. modbusClient = TCPModbus('192.168.1.10', 502)
C. modbusClient = ModbusTCP('192.168.1.10', 502)
D. modbusClient = Modbus('192.168.1.10', 80)

Solution

  1. Step 1: Identify correct class and parameters

    The standard syntax uses ModbusTCP with IP and port 502 for Modbus TCP.
  2. Step 2: Check options for correct syntax

    modbusClient = ModbusTCP('192.168.1.10', 502) matches the correct class name and port number for Modbus TCP client.
  3. Final Answer:

    modbusClient = ModbusTCP('192.168.1.10', 502) -> Option C
  4. Quick Check:

    ModbusTCP + port 502 = correct client syntax [OK]
Hint: Modbus TCP uses port 502 and class ModbusTCP [OK]
Common Mistakes:
  • Using wrong class names like TCPModbus
  • Using incorrect port numbers
  • Omitting the port parameter
3. Given the following PLC script snippet for sending a signal:
modbusClient.write_coil(1, True)
status = modbusClient.read_coil(1)

What will be the value of status after execution?
medium
A. False
B. Error
C. 0
D. True

Solution

  1. Step 1: Understand write_coil and read_coil functions

    write_coil(1, True) sets coil 1 to True; read_coil(1) reads its current value.
  2. Step 2: Trace the code execution

    After writing True to coil 1, reading coil 1 returns True.
  3. Final Answer:

    True -> Option D
  4. Quick Check:

    Write True then read coil = True [OK]
Hint: Write True, then read coil returns True [OK]
Common Mistakes:
  • Assuming read_coil returns False immediately
  • Confusing coil values with integers
  • Expecting an error without connection
4. Identify the error in this PLC-to-PLC communication code snippet:
modbusClient = ModbusTCP('192.168.1.20')
modbusClient.write_register(10, 123)
medium
A. Missing port number in ModbusTCP initialization
B. write_register function does not exist
C. IP address format is incorrect
D. Register address 10 is invalid

Solution

  1. Step 1: Check ModbusTCP initialization parameters

    ModbusTCP requires IP address and port number (usually 502).
  2. Step 2: Identify missing port parameter

    The code only provides IP, missing port number causes connection error.
  3. Final Answer:

    Missing port number in ModbusTCP initialization -> Option A
  4. Quick Check:

    ModbusTCP needs IP and port [OK]
Hint: Always include port number when creating ModbusTCP client [OK]
Common Mistakes:
  • Forgetting the port number argument
  • Assuming default port without specifying
  • Misreading IP address format
5. You want to synchronize two PLCs so that PLC A sends a temperature value to PLC B every second using Modbus TCP. Which approach best ensures reliable data transfer?
hard
A. PLC A sends temperature as a coil value; PLC B reads it once at startup
B. PLC A writes the temperature to a holding register; PLC B reads it every second with error checking
C. PLC B writes a command to PLC A; PLC A sends temperature only on command
D. PLC A broadcasts temperature on UDP; PLC B listens without confirmation

Solution

  1. Step 1: Identify reliable data transfer method

    Using holding registers with regular writes and reads plus error checking is reliable.
  2. Step 2: Evaluate other options

    Coils are for binary signals, not values; reading once or UDP without confirmation is unreliable.
  3. Final Answer:

    PLC A writes the temperature to a holding register; PLC B reads it every second with error checking -> Option B
  4. Quick Check:

    Regular register write/read with error check = reliable [OK]
Hint: Use holding registers and error checks for reliable data [OK]
Common Mistakes:
  • Using coils for analog values
  • Reading data only once instead of periodically
  • Using UDP without confirmation for critical data
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard