How to judge the touch screen and PLC communication failure through the program?
Many engineers and technicians have faced a common issue: how can the touch screen communicate with the PLC? Below are two typical problems encountered in practice:
1. The Weiluntong touch screen is unable to communicate with the Siemens PLC, constantly showing a "PLC not responding" error. How should this be configured?
Solution: Ensure that both the touch screen and the PLC have the same baud rate, data bits, and stop bits. Also, make sure that their station numbers are different—meaning the PLC address and the touch screen address must not be the same. Then check if the communication cable is properly connected and functioning.
2. How can you detect a communication failure between the touch screen and the PLC through programming?
Solution: A common method is to use a heartbeat detection mechanism. Define a boolean variable in the HMI (Human-Machine Interface) that is set at fixed intervals. When the PLC receives the ON signal, it resets the variable. If the ON signal isn't received within a certain time, such as 5 seconds, it's considered a communication failure.
Another approach is for the PLC to send a memory clock byte to the touch screen. The touch screen then uses a script to assign this value to another address in the PLC. The PLC checks whether the returned byte has the same scan cycle. If it does, it indicates a communication interruption.
For example, here’s a step-by-step process:
1. Create a DB1 data block in the PLC with two switches: "PLC second switch" and "human machine response switch."
2. Connect these variables to the touch screen.
3. In the properties of the "PLC second switch," go to the Event tab and add a "reverse bit" action so that the "human-machine response switch" changes when the "PLC second switch" changes.
4. In the PLC program, set the "PLC second switch" to toggle every 0.5 seconds, and use a TON timer to ensure the "human-machine response switch" remains active for at least 1 second. If communication is lost, the "human-machine response switch" will no longer change, indicating an issue.
This is a practical solution. Take it away and thank you!
In fact, any communication between a touch screen and a PLC on the market typically comes down to four key factors:
1. Are the PLC parameters consistent with the project settings?
2. Is the communication cable connected correctly according to the wiring diagram?
3. Is the correct COM port selected in the project when connecting to the touch screen?
4. After confirming the parameters and cabling, check if the issue lies with the PLC program or address configuration.
Here’s how to approach it:
First, verify the parameters:
1. Connect the PLC using the programming software and check its actual parameters. Ensure they match what's set in the project.
2. Perform an online simulation using your configuration software. Connect the PLC via its own communication cable to the computer and simulate the project to see if communication is established. Use a numerical input or switch component to test. If the values don’t update after the simulation starts, there may be an issue.
Test the cable:
Use a multimeter to check the wiring based on the pinout diagram.
Check the touch screen parameters:
Several settings are crucial:
1. Communication port setting – confirm whether it's COM1 or COM2 connected to the PLC.
2. Device type – this is the most important parameter. If the protocol is not selected correctly, other settings won’t matter.
3. Connection method – confirm whether it’s RS485 or RS232C, depending on the PLC model.
4. Interface parameters and PLC station number – these must match the PLC settings exactly.
Second, if the parameters are correct, check the wiring. Confirm that the RS485 or RS232C connection is correct and that the touch screen is wired properly for the specific PLC. You can refer to the communication wiring guide provided by the manufacturer for more details. This is the basic troubleshooting method for communication issues.
Next, I’ll show you how to bypass the touch screen problem using online simulation. When communication fails, some users may suspect the touch screen or the interface. Online simulation allows you to connect directly to the PLC using a computer, effectively skipping the touch screen.
Here’s how to do it:
1. Connect the PLC to the computer via RS232. Some PLCs have an RS232 port; others may require an adapter.
2. Create a simple project with two components: one for displaying a value and one for inputting a value. Set the address to match the PLC's.
3. Ensure the project settings match the PLC configuration.
4. Click on the online simulation function.
If the PLC communicates with the PC successfully, the issue is likely not with the PLC or the settings. This helps isolate the problem quickly and efficiently.
FME Connector, FME Male Connector,FME Female Connector, FME Male plug connector. FME Coaxial connector
Changzhou Kingsun New Energy Technology Co., Ltd. , https://www.aioconn.com