It's my very first time with Modbus but I have worked with some other networking protocols before and programmed PLCs using all of Structured Text, FBD, and LAD.
I have this ModbusTCP code to read the input registers of a connected device. The problem is that the request messages are not being sent (Wireshark does not record any traffic) even though the xExecute input of the ClientRequestReadInputRegisters function block is changing as I desire when the clientTCP object is connected. I have also adjusted the frequency of the requests to ensure that the Modbus server can handle them that fast. However, the value of ClientTCP.udiNumReqNotProcessed keeps rising with each rising edge on ClientRequestReadInputRegisters.xExecute, although ClientTCP.udiNumMsgSent stays at 0. Is there something I need to do to have the requests processed?
It may also be important to know that the ClientRequestReadInputRegisters function block returns no errors or exception codes. I believe that this means I have the correct values for all necessary fields for a ModbusTCP request.
Please help if you have some Modbus experience with Codesys.
I have exactly the same problem and I urgently need help.
When I login and run the program codesyscontrol.log and Wireshark shows the same messages which refer to opening TCP connection. So Modbus TCP/IP connection is opened, but no messages are sent from the program.
β’ udiNumMsgSent is 0 and udiNumReqNotProcessed keeps rising
β’ eErrorID is OK
β’ And the eExecption:= RESPONSE_SUCCESS
Last edit: tuomas 2022-08-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
does anyone has a solution for this issue. I've the same problem.
I've implemented a very simple client based on the Modbus Examples and connected the soft PLC to a Modbus Simulator.
Your code works if the client fb is called cyclic!
IFNOTinitDoneTHENinitDone:=TRUE;// configure clientTcpclientTcp(aIPaddr:=Ethernet.IPAddress,uiPort:=502);// configure clientSerialclientSerial(iPort:=SysCom.SYS_COMPORT2,dwBaudRate:=SysCom.SYS_BR_115200,byDataBits:=8,eParity:=SysCom.SYS_EVENPARITY,eStopBits:=SysCom.SYS_ONESTOPBIT,eRtuAscii:=ModbusFB.RtuAscii.RTU);// configure clientRequestReadCoils_1 clientRequestReadCoils_1(rClient:=clientTcp,uiUnitId:=42,udiTimeout:=TO_UDINT(T#10MS));// configure clientRequestWriteSingleRegisterclientRequestWriteSingleRegister(rClient:=clientTcp,uiUnitId:=43,udiTimeout:=TO_UDINT(T#10MS));// configure clientRequestReadCoils_2 clientRequestReadCoils_2(rClient:=clientTcp,uiUnitId:=44,udiTimeout:=TO_UDINT(T#10MS));// configure clientRequestReadInputRegistersclientRequestReadInputRegisters(rClient:=clientTcp,uiUnitId:=44,udiTimeout:=TO_UDINT(T#10MS));END_IF// call the client FB'sclientTcp();clientSerial();// call client request FB'sclientRequestReadCoils_1(rClient:=clientTcp,xExecute:=TRUE,uiStartItem:=2,uiQuantity:=3,pData:=ADR(aDataCoils_1[0]));// for more details see Example_TCP, especially ClientRequest control (xExecute, xDone, xError).IFclientRequestReadCoils_1.xDoneTHEN// get data from aDataCoils_1 ...END_IFclientRequestWriteSingleRegister(rClient:=clientTcp,xExecute:=TRUE,uiItem:=3,uiValue:=123);clientRequestReadCoils_2(rClient:=clientTcp,xExecute:=TRUE,uiStartItem:=2,uiQuantity:=3,pData:=ADR(aDataCoils_2[0]));clientRequestReadInputRegisters(rClient:=clientTcp,xExecute:=TRUE,uiStartItem:=16,uiQuantity:=3,pData:=ADR(aDataInputRegisters[0]));
Last edit: paro 2024-05-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's my very first time with Modbus but I have worked with some other networking protocols before and programmed PLCs using all of Structured Text, FBD, and LAD.
I have this ModbusTCP code to read the input registers of a connected device. The problem is that the request messages are not being sent (Wireshark does not record any traffic) even though the xExecute input of the ClientRequestReadInputRegisters function block is changing as I desire when the clientTCP object is connected. I have also adjusted the frequency of the requests to ensure that the Modbus server can handle them that fast. However, the value of ClientTCP.udiNumReqNotProcessed keeps rising with each rising edge on ClientRequestReadInputRegisters.xExecute, although ClientTCP.udiNumMsgSent stays at 0. Is there something I need to do to have the requests processed?
It may also be important to know that the ClientRequestReadInputRegisters function block returns no errors or exception codes. I believe that this means I have the correct values for all necessary fields for a ModbusTCP request.
Please help if you have some Modbus experience with Codesys.
Last edit: corriibme 2022-08-04
I have exactly the same problem and I urgently need help.
When I login and run the program codesyscontrol.log and Wireshark shows the same messages which refer to opening TCP connection. So Modbus TCP/IP connection is opened, but no messages are sent from the program.
β’ udiNumMsgSent is 0 and udiNumReqNotProcessed keeps rising
β’ eErrorID is OK
β’ And the eExecption:= RESPONSE_SUCCESS
Last edit: tuomas 2022-08-10
Hi,
does anyone has a solution for this issue. I've the same problem.
I've implemented a very simple client based on the Modbus Examples and connected the soft PLC to a Modbus Simulator.
When the system is running I do get the following on the logs:
But the errorID is jumping between OK and RequestNotProcessed.
Any help is very appreciated which gives me a hint what I'm doing wrong.
Thanks
Hi,
I have the same problem as the guys above. Any solution or hint in the right direction is appreciated.
Codesys version 3.5.19.2, Lib version: 4.4.0.0.
Thank you!
Hi, Problem in your code is that you are not calling the ClientFb cyclic. Please look at the Example from CODESYS: https://forge.codesys.com/prj/codesys-example/modbus/home/Home/
Your code works if the client fb is called cyclic!
Last edit: paro 2024-05-29
I'm using the code bellow which is based on the Codesys example:
As you can see the clientTCP is called cyclically with the same result.
Hi,
works in my case if I increase the timeout!
to_udint(t#100ms) -> 100 -> 100us..
Hi,
Thank you for your suggestion but the problem is fixed after I disabled and enabled the network adapter from Windows settings.