AGG Software Forums
November 24, 2024, 08:11:10 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome on our forum!
 
   Home   Help Search Login Register  

Pages: [1]
  Print  
Author Topic: Modbus logging  (Read 70026 times)
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« on: May 10, 2009, 11:41:24 PM »

Hi, i'm currently reviewing the Advanced TCP/IP Data Logger software.
I'm trying to log data from a modbus tcp/ip capable device, without much success.
I don't have experience with modbus at all.

I filled in the following in the modbus tcp query and parser :
Device address 16
Function 3
First register 100
Registers to read 2
Request timeout 300

Reponse items :
Data type Floating point (32 bit)

But i'm only getting asci characters, while i should get numeric values.
If someone can help, then please !

The following info is provided by the hardware manufacturer :

3.3 Modbus Operation
The Analog Module can  read using Modbus/TCP protocol.  This provides a standard means of using the Analog
Module in conjunction with devices and software from other manufacturers.  This section contains the information
necessary to communicate with the Analog Module using Modbus/TCP.  This is not a tutorial on Modbus and it is
assumed that the reader is already familiar with Modbus.  Detailed Modbus information can be found at
http://www.modbus.org
It is important to note that when the control password in the Analog Module is enabled, Modbus/TCP
communications are disabled.  This is because Modbus/TCP does not provide a mechanism for password protection.
Make sure the control password is disabled (default) before using Modbus with the Analog Module.
The Analog Module functions as a Modbus server (slave).   Client (master) devices open a connection with the
Analog Module on port 502 (unless another modbus port is selected) and send commands or requests to read the state
of the analog inputs.  When the Analog Module receives a command, it will perform the desired function and return a
response.  The following commands are available:
Read Holding Registers (Modbus Function Code 03 (0x03)) – read analog values
Multiple commands may be sent without closing and re-opening the connection, but if no data is transferred for 50
seconds the connection will time out.  To keep the connection open, a read request can be sent periodically.  Two
TCP sockets are available for Modbus communications.  If two masters each have a socket open (or a single master
using two sockets) and a third master attempts to open a socket for Modbus communications, the request to open a
third socket will be rejected.
3.3.1 Read Holding Registers (Modbus Function Code 03 (0x03))
This function is used to read the final values (raw values with slope and offset applied) of each input.  One,
multiple, or all values can be read at the same time using this function.
Valid address/quantity combinations
Reading these registers requires that the address be in the range of 16 to 30 (0x10 and 0x1E). Also, the
address must be evenly divisible by 2.  In other words, only address 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, and 0x1E are valid. Each value is returned as two registers in IEEE 754 floating point format. 
The four data bytes are treated as two individual big endian 16-bit words with the least significant word being sent first. 
In other words, the 32 bit floating point number represented as ABCD is sent as CDAB. The following table lists the address that correspond to each input.

Input Address
0 0x10
1 0x12
2 0x14
3 0x16
4 0x18
5 0x1A
6 0x1C
7 0x1E

Note: When the input value is outside the valid range (0 to 5 volts) then a really large value will be
returned,  usually a hex value such as 4F80 XXXX will be returned which is roughly 4294967295 when
converted to a float using the IEEE 754 format..

Request:
   Modbus/TCP
         Transaction identifier (2 Bytes): 0x0001
         Protocol identifier (2 Bytes): 0x0000
         Length (2 Bytes): 0x0006
         Unit identifier (1 Byte): 0xff
   Modbus
         Function code (1 Byte): 0x03 (read holding registers)
         Reference number (2 Bytes): 0x0010 to 0x0016
           Register count (2 bytes): 0x02 to 0x08
   
     char write_registers_mb_request[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0
Response:
     Modbus/TCP
           Transaction identifier (2 Bytes): 0x0001
            Protocol identifier (2 Bytes): 0x0000
            Length (2 Bytes): 0x000B
            Unit identifier (1 Byte): 0xff
     Modbus
             Function code (1 Byte): 0x03 (read holding registers)
             Byte count (1 Byte): 0x08
             Register values (2 Bytes): 0xffff – (register count x 2 bytes)
      Modbus Error:
Function code (1 Byte): 0x83
Exception code (1 Byte): 0x01 or 0x02
Exception codes:
0x01 – Function code not supported
0x02 – Incorrect starting address / quantity of outputs combination

char write_registers_mb_request[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0xff, 0x03, 0x08, 0x00, 0x00, 0x00,
           0x00, 0x00, 0x00, 0x00, 0x00};
« Last Edit: May 10, 2009, 11:44:27 PM by mikenl » Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #1 on: May 11, 2009, 07:21:14 AM »

The main program screen shows unparsed data. If you'll activate the DDE server plug-in, then you'll see parsed variables with your values. Please, note that you should activate both query and parser plug-ins and select MODBUS TCP/IP in both fields.

The small part of documentation, that you posted above refers to input address 0x10-0x1E. It is possible you should change the "First register" value to 0x10. I'm not sure, please, refer to your manual for a detailed registers map.

Do you see any response from your device? It is possible the device sends error responses. In this case the program should display it in the log box in the main window.
Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #2 on: May 11, 2009, 10:15:50 AM »

I already selected MODBUS TCP/IP in both fields.
I don't see any error messages just : The data source has successfull opened.
Activating the DDE server plug-in, doesn't help much, in the log window i see :
d
 d
!d
"d
#d
$d
%d
&d
'd
(d
)d
*d
+d
,d
-d
.d
/d
0d
1d
2d
3d
4d
5d
6d
7d
8d
9d
:d
;d
<d
=d
>d
?d
@d
Ad
Bd
Cd
Dd


Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #3 on: May 11, 2009, 08:11:52 PM »

Please, set the following settings and post your data from the main screen. The main screen should display requests and responses. Requests will be highlighted on the screen.


* s1.jpg (45.55 KB, 390x550 - viewed 32 times.)

* s2.JPG (40.2 KB, 467x456 - viewed 18 times.)

* s3.JPG (39.24 KB, 470x456 - viewed 18 times.)
Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #4 on: May 12, 2009, 07:31:50 PM »

Ok,
With the suggested settings i get the following response :
#00#02#00#00#00#06#01#03#00#0A
#00#04
#00#03#00#00#00#06#01#03#00#0A
#00#04
#00#04#00#00#00#06#01#03#00#0A
#00#04
#00#05#00#00#00#06#01#03#00#0A
#00#04
#00#06#00#00#00#06#01#03#00#0A
#00#04
#00#07#00#00#00#06#01#03#00#0A
#00#04
#00#08#00#00#00#06#01#03#00#0A
#00#04
#00#09#00#00#00#06#01#03#00#0A
#00#04
#00#0A
#00#00#00#06#01#03#00#0A
#00#04
#00#0B#00#00#00#06#01#03#00#0A
#00#04

When i asked the hardware manufacturer i got this response :

First, a common problem that people encounter is that often Modbus programs will ask for a specified Unit ID or sometimes it is called the Slave ID.  Our units require this field to be set at 255.
 
From the settings you sent, I have a few other suggestions.  I'm not quite sure what is meant by the Device address field, but I'm guessing you have that filled in correctly.  The first register of the device is 10 in hexadecimal.  This would be the equivalent of 16 in decimal.  Your program may be asking for a decimal number.  Right now your settings are requesting to read two of the inputs.
 
When i set first register to 16, and registers to read to 2, i get :

#00#02#00#00#00#06#10#03#00#10#00#02
#00#03#00#00#00#06#10#03#00#10#00#02
#00#04#00#00#00#06#10#03#00#10#00#02
#00#05#00#00#00#06#10#03#00#10#00#02
#00#06#00#00#00#06#10#03#00#10#00#02
#00#07#00#00#00#06#10#03#00#10#00#02
#00#08#00#00#00#06#10#03#00#10#00#02
#00#09#00#00#00#06#10#03#00#10#00#02
#00#0A
#00#00#00#06#10#03#00#10#00#02
#00#0B#00#00#00#06#10#03#00#10#00#02
#00#0C#00#00#00#06#10#03#00#10#00#02
#00#0D#00#00#00#06#10#03#00#10#00#02
#00#0E#00#00#00#06#10#03#00#10#00#02
#00#0F#00#00#00#06#10#03#00#10#00#02
#00#10#00#00#00#06#10#03#00#10#00#02
#00#13#00#00#00#06#10#03#00#10#00#02
#00#14#00#00#00#06#10#03#00#10#00#02

Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #5 on: May 12, 2009, 08:00:44 PM »

Oh,
and when i set the device id to 255 i get, with a white line and yellow
that i didn't get before :

#00#02#00#00#00#06#FF#03#00#10#00#02
#00#02#00#00#00#07#FF#03#04#F1#4C#3A#1C
#00#03#00#00#00#06#FF#03#00#10#00#02
#00#03#00#00#00#07#FF#03#04#F1#4C#3A#1C
#00#04#00#00#00#06#FF#03#00#10#00#02
#00#04#00#00#00#07#FF#03#04#BF#5B#3A#1E
#00#05#00#00#00#06#FF#03#00#10#00#02
#00#05#00#00#00#07#FF#03#04#55#2D#3A#19
#00#06#00#00#00#06#FF#03#00#10#00#02
#00#06#00#00#00#07#FF#03#04#BD#41#3A#1B
#00#07#00#00#00#06#FF#03#00#10#00#02
#00#07#00#00#00#07#FF#03#04#EF#32#3A#19
#00#08#00#00#00#06#FF#03#00#10#00#02
#00#08#00#00#00#07#FF#03#04#41#53#3A#DB
#00#09#00#00#00#06#FF#03#00#10#00#02
#00#09#00#00#00#07#FF#03#04#57#46#3A#1C
#00#0A
#00#00#00#06#FF#03#00#10#00#02
#00#0A
#00#00#00#07#FF#03#04#23#3C#3A#1B
#00#0B#00#00#00#06#FF#03#00#10#00#02
#00#0B#00#00#00#07#FF#03#04#41#53#3A#DB
#00#0C#00#00#00#06#FF#03#00#10#00#02
#00#0C#00#00#00#07#FF#03#04#41#53#3A#DB
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #6 on: May 13, 2009, 07:52:53 AM »

It seems, that the program reads something. If you activated the DDE server plug-in. Did you see any values on the "Active items" page withing the plug-in?
Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #7 on: May 14, 2009, 01:10:06 AM »

On the "Active items" page it seems that it shows the correct value now , thanks !
I'm now trying to export the data to an MS access ODBC database.
The lines appear in the database but the values are empty in the field.
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #8 on: May 14, 2009, 06:54:41 AM »

You should bind your parser items like ITEM1 to corresponding columns. Please, visit our tutorials section and read about export to a database.

http://www.aggsoft.com/serial-data-logger/tutorials.htm
Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #9 on: July 10, 2009, 01:24:00 AM »

Ok,
I bought the program and continue my quest for logging modbus data.
All is fine now except, i made a local database export, an access database.
Values get logged except, i see the same logged value between 15 and 18 times in the log with the same timestamp. polling intervals are set at 10000ms.

Can you shed some light on this one ?

edit :
In the logging window of Advanced tcp/ip data logger all seems well. (not 15 times the same, just 1 rule every 10 seconds.)
« Last Edit: July 10, 2009, 01:26:35 AM by mikenl » Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #10 on: July 10, 2009, 07:08:30 AM »

Please, create the backup file with your settings from the "File" menu and attach it here. I'll verify it.
Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #11 on: December 16, 2010, 11:00:00 AM »

Ok thanks,
here is my config.

* config.txt (6.39 KB - downloaded 10 times.)
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #12 on: July 13, 2009, 08:24:57 AM »

I'm sorry for my late reply. Please, try to optimize your settings. You need only one MODBUS request and therefore don't need the "Aggregator" plug-in.

Please, look at attached images. Please, note that you should change parser item names in the data export plugin. Unfortunately, I can't test these settings, because don't have a corresponding device.


* s1.jpg (43.83 KB, 375x576 - viewed 14 times.)

* s2.JPG (27.35 KB, 468x300 - viewed 14 times.)

* s3.JPG (49.2 KB, 468x456 - viewed 12 times.)
Logged
mikenl
Jr. Member
**

Karma: +0/-0
Posts: 8


View Profile
« Reply #13 on: July 13, 2009, 10:49:02 PM »

No problem, you gotta have your weekend too !
To simplify things i removed all filters and stripped it down to one modbus request.
Still I'm getting the same value logged multiple times in an Access database.
The excel direct connection works as expected with one modbus request.
With two registers read, then double time stamps gets written.
If i then use the aggregator, then everything gets corrected in excel.
I attached a few examples of what happens.

I don't understand what you mean by changing parser item names.
Are the names Item11 Item21 etc... not correct ?

* log.rar (10.3 KB - downloaded 3 times.)
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #14 on: January 10, 2011, 11:00:00 AM »

The bug with duplicated data has been fixed. Please, download the updated "Local database" plug-in from our site.

http://www.aggsoft.com/download/localdb.exe
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines