Author Topic: Reading Modbus-RTU device  (Read 11856 times)

Allan

  • Guest
Reading Modbus-RTU device
« on: June 13, 2002, 05:36:17 AM »
Hi

We have a DGH 5V analogue input/ RS-485 output MODBUS-RTU device connected to T100MD888+ RS-485 port.

The DGH device manual gives a typical Modbus Read Input Register command sequence as:

01  04  00 00  00 02  31 CA

where

01 is slave address
04 is Read Input Register command
00 00 is starting register to be read (Modbus address 30001)
00 02 is number of registers to be read (2 in this case)
31 CA is the CRC message

Our question is how do we programme the above sequence in TBasic?

We have tried:

DM[1] = READMODBUS(13, 01 04 00 00 00 02 31 CA)

with no success.  Can anyone help give us some pointers

Allan & Nuri  :'(
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Reading Modbus-RTU device
« Reply #1 on: June 17, 2002, 09:09:30 AM »
You should use READMODBUS command to read 1 register at a time. Use it twice at two different addresses to read two registers:

DM[1] = READMODBUS(13, 1, 0)
DM[2] = READMODBUS(13, 1, 1)

The READMODBUS (13,xx,yy) means to use RTU command to read from COMM port #3 (RS485). xx is the ID of the RTU device, yy is the starting address of the register. The CRC16 is automatically generated by the READMODBUS command and need not be added.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

kkseng

  • Newbie
  • Posts: 1
  • I love YaBB 1G - SP1!
    • View Profile
Re: Reading Modbus-RTU device
« Reply #2 on: July 04, 2003, 06:19:18 PM »
I am also having a simliar problem. I have a Emerson GCX device. I need to read the 3xxxx regidters using Modbus function 04. I understand that Trilogi Modbus protocol does not support function 04. I have tried using OUTCOMM and INCOMM with mixed results(data in INCOMM buffer sometimes are OK-randomly but most time not.). Could anyone show me a example how to use these commands.  I have T100MD888+ r46 and uses Trilogi 5.2
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Reading Modbus-RTU device
« Reply #3 on: July 06, 2003, 03:49:22 PM »
You are right that READMODBUS is implemented using MODBUS function 03 and WRITEMODBUS is implemented using MODBUS function 16. These two functions are considered MODBUS Level 1 functions and are the most fundamental MODBUS command that any MODBUS master has to support.

If your device requires other function, then you can implement it using INCOMM, OUTCOMM and CRC16 (for PLC with firmware revision r44 and above only). We have posted a sample program that you can download from the following link:

http://www.tri-plc.com/trilogi/modbusFunction04.zip

This sample implements the function 04 and is tested to work with a slave T100MD888+.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS