Hi,
We are in the process of designing a Modbus slave web service over Modbus tcp but we are getting strange behavior on the plc side. Hope you can help us find the problem.
Here's the PLC code
S = STATUS(3)
if(S = 1) THEN PRINT #4 "</>" ENDIF
//CONNECT TO THE REMOTE DEVICE
PRINT #4 "<MBTCPCONNECT IPAddress:502>"
Call wait4conn //WAIT FOR CONNECTION
//GET CONNECTION STATUS
S = STATUS(3) //S=1 = CONNECTED, S=0 = NOT CONNECTED
IF S = 1 THEN
setlcd 2,1, "Reading TEMP... "
READMB2 4,1,40004,DM[151],2
//DM[153] = ReadModbus(4,1,4)
N$ = "Waiting response....."
Call WaitForDataInD
IF STATUS(2) = 0 THEN
f$ = input$(4)
DM[151]=999
DM[152]=999
setlcd 2,1, "Reading TEMP failed!!!! "
ELSE
setlcd 2,1, "Reading TEMP success!!!!!"
ENDIF
PRINT #4 "</>"
ENDIF
The actual stream of two requests between the PLC and the slave service is below:
At the ModbusSlave web Service:
Recv From PLC: 006700000006 01 04 9C 44 00 02 | Send From WebSVC: 006700000007 01 04 04 00 00 42 34
Recv From PLC: 008D00000006 01 04 9C 44 00 02 | Send From WebSVC: 008D00000007 01 04 04 00 00 42 34
I can't see where is failing...