Having difficultty communicating with Keyence NC32T PLC via ethernet using pymodbus

33 views Asked by At

I have installed pymodbus to communicate with Keyence PLC. I am using NC32t PLC with NC1EP Ethernet module. I just want to read the data from a register just to test and in the future reading and writing data to and from the registers. however, i always get an error of Transaction failed. (Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (2 received)). based from the debug logging i can connect to the device. it seems there is an error on the receiving of the initial command. Here are my debug logs:

2024-02-01 22:03:38,631 DEBUG logging:103 Connection to Modbus server established. Socket ('192.168.8.21', 55487)
Connected to device
2024-02-01 22:03:38,633 DEBUG logging:103 Current transaction state - IDLE
2024-02-01 22:03:38,633 DEBUG logging:103 Running transaction 1
2024-02-01 22:03:38,634 DEBUG logging:103 SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0x0 0x63 0x0 0x1
2024-02-01 22:03:38,634 DEBUG logging:103 New Transaction state "SENDING"
2024-02-01 22:03:38,635 DEBUG logging:103 Changing transaction state from "SENDING" to "WAITING FOR REPLY"
2024-02-01 22:03:41,651 DEBUG logging:103 Transaction failed. (Modbus Error: [Invalid Message] Incomplete message received, expected at least 8 bytes (2 received)) 
2024-02-01 22:03:41,653 DEBUG logging:103 Processing:
2024-02-01 22:03:41,654 DEBUG logging:103 Frame check failed, ignoring!!
2024-02-01 22:03:41,655 DEBUG logging:103 Getting transaction 1
2024-02-01 22:03:41,656 DEBUG logging:103 Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
Failed to read data at address 99

Based on the pymodbus output, I should have used port 502. I cant seem to connect using 502 that's why i used port 5000. it can connect to the device now. But I also read that port 5000 is also the port for MC protocol. I tried pycomm3 mcprotocol module but it seems kinda harder to use (I am having hard time getting stuck on the 'get_plc_info' part. As for pymodbus if i change ports to 8501 it gets me 0 bytes received instead of 2.

0

There are 0 answers