Author Topic: ReadMB2  (Read 7088 times)

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
ReadMB2
« 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...

Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:ReadMB2
« Reply #1 on: December 03, 2014, 11:29:54 AM »
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
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:ReadMB2
« Reply #2 on: December 03, 2014, 11:52:14 AM »
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
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:ReadMB2
« Reply #3 on: December 03, 2014, 03:27:27 PM »
This is what I found using a third party testing software... Image attached...
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:ReadMB2
« Reply #4 on: December 03, 2014, 07:17:24 PM »
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...
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3170
    • View Profile
    • Internet Programmable PLCs
Re:ReadMB2
« Reply #5 on: December 03, 2014, 08:04:44 PM »
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.
« Last Edit: December 03, 2014, 08:07:10 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

EDGAR

  • Jr. Member
  • Posts: 60
  • Automating concepts around the world!
    • View Profile
    • Kinemics
Re:ReadMB2
« Reply #6 on: December 04, 2014, 06:05:59 AM »
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
Low cost Modbus OPC DA Server, supporting Modbus RTU, ASCII, and TCP. Download your demo today! Go to www.kinemics.com/modbus.