Internet PLC Forum
General => Technical support => Topic started by: EDGAR on December 03, 2014, 11:26:46 AM
-
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...
-
Sorry pressed enter too soon.
We even added a chr 10 and 13 at the end of the byte just in case the plc is looking for that but is not working anyway.
We will keep trying and update later tonight...
Thanks,
Ed
-
I just changed the address from 40004 to 30004 thinking that may be causing register overflow but nothing yet. Still having the issue...
Thanks,
Ed
-
This is what I found using a third party testing software... Image attached...
-
Ok, I have not found the issue but the problem is in the PLC program that's currently running. I tested with the Ethernet Modbus sample and everything works great!
So keep everyone posted when I find the solution...
Thanks,
Ed
PS: the image was never uploaded on the previous post, it was too large...
-
I think you are trying to read from Modicon address 40004 - this means you should be reading from binary address = 40004-40001 = 3.
Try reading from address 3 and see if you get your expected result.
-
Thank you! It works great using the sample project that comes with your programming software. I will make changes to the current program to see if it works.
Thanks, again and keep you posted.
Ed