Bird
Raised Fist0
PLC Programmingscripting~10 mins

PLC-to-PLC communication in PLC Programming - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - PLC-to-PLC communication
PLC1 prepares data
↓
PLC1 sends data via communication link
↓
Communication medium transmits data
↓
PLC2 receives data
↓
PLC2 processes received data
↓
PLC2 sends response or acknowledgment (optional)
↓
Communication medium transmits response
↓
PLC1 receives response (optional)
This flow shows how one PLC sends data to another PLC through a communication link, how the data is transmitted, received, and optionally acknowledged.
Execution Sample
PLC Programming
PLC1_Data := 100;
SendData(PLC1_Data);
PLC2_Data := ReceiveData();
IF PLC2_Data = 100 THEN
  Output := TRUE;
END_IF;
PLC1 sets data to 100, sends it; PLC2 receives data and sets output TRUE if data equals 100.
Execution Table
StepActionPLC1_DataPLC2_DataConditionOutputNotes
1PLC1 sets PLC1_Data to 100100undefinedN/AundefinedPLC1 prepares data
2PLC1 sends data100undefinedN/AundefinedData sent over link
3PLC2 receives data100100N/AundefinedPLC2 gets data
4PLC2 checks if PLC2_Data = 100100100TrueundefinedCondition true
5PLC2 sets Output to TRUE100100TrueTRUEOutput updated
6End of communication cycle100100N/ATRUEProcess complete
💡 Communication cycle ends after PLC2 processes data and updates output.
Variable Tracker
VariableStartAfter Step 1After Step 3After Step 5Final
PLC1_Dataundefined100100100100
PLC2_Dataundefinedundefined100100100
OutputundefinedundefinedundefinedTRUETRUE
Key Moments - 3 Insights
Why does PLC2_Data remain undefined until step 3?
PLC2_Data is undefined before step 3 because PLC2 has not yet received any data; it only gets assigned when data arrives (see execution_table row 3).
What happens if the condition PLC2_Data = 100 is false?
If false, PLC2 does not set Output to TRUE, so Output remains undefined or FALSE (not shown here), as explained in execution_table row 4.
Is the response from PLC2 to PLC1 mandatory?
No, the response or acknowledgment is optional depending on the communication design; this example shows a simple one-way data send and process.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of PLC2_Data at step 2?
A0
B100
Cundefined
DTRUE
💡 Hint
Check the 'PLC2_Data' column at step 2 in the execution_table.
At which step does the Output variable become TRUE?
AStep 5
BStep 3
CStep 4
DStep 6
💡 Hint
Look at the 'Output' column in the execution_table and find when it changes to TRUE.
If PLC1_Data was set to 50 instead of 100, what would happen at step 4?
ACondition would be True
BCondition would be False
COutput would be TRUE
DPLC2_Data would be undefined
💡 Hint
Refer to the condition check in execution_table row 4 and consider the value comparison.
Concept Snapshot
PLC-to-PLC communication involves one PLC sending data to another via a communication link.
Data is prepared, sent, received, and processed.
Conditions can trigger actions based on received data.
Responses or acknowledgments may be optional.
This enables coordinated control between PLCs.
Full Transcript
In PLC-to-PLC communication, one PLC prepares data and sends it through a communication link. The other PLC receives this data and processes it. For example, PLC1 sets a data value to 100 and sends it. PLC2 receives this value and checks if it equals 100. If true, PLC2 sets an output to TRUE. This process allows PLCs to share information and coordinate actions. The communication can include optional responses or acknowledgments. Variables change state step-by-step as data moves from one PLC to another and conditions are evaluated.

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