10868 questions

12950 answers

20197 comments

25858 members

0 votes
37 views 1 comments
by
Gday, Wondering if anyone has any insight into the gps data format sent by the RUT955 in TCP modbus?

i can get most data off the device, fairly straightfoward. 2 words to double word using a 16 bit shift + OR, and convert to the desired format. (codesys)

but the GPS lat and long registers 143 and 145 converted to real come out with some wild values. tried shifting bit orders, changing word orders, all the basics, but not much progress.

anyone got any ideas?

Thanks

2 Answers

0 votes
by
Hello,

The data format for 32bit float with order 1 2 3 4 and start register should be 144 and 146
0 votes
ago by

There have been a couple of questions on this:

https://community.teltonika-networks.com/28727/accuracy-of-gps-data-via-modbus

Using Python and PyModbus I have the same problem as the above, I get an answer that is in the right country, but not the right place in the right country.

There is this that helps a bit but still blows my mind, and I haven't understood it enough to be able to try to see if I get the right location this way:

https://community.teltonika-networks.com/1199/rut955-modbus-parameters-interpretation

I should have an HMI that can read and convert Modbus with me in a few days, I will try using that and see if I get nearer to the right answer.

If the Python program would help, this is where I got to:


import time
import struct
from pyModbusTCP.client import ModbusClient
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder

# init modbus client
c = ModbusClient(host="10.100.1.1", port=502, unit_id=1, debug=False, auto_open=True)

# main read loop
while True:
    # read 10 registers at address 0, store result in regs list
    #a = 17138
    #b = 59381
    #a = 18154
    #b = 21826
    #registers = [a, b]
    #registers = c.read_holding_registers(144, 2)
    registers = c.read_holding_registers(146, 2)

    if registers:
        decoder = BinaryPayloadDecoder.fromRegisters(registers, byteorder=Endian.Little)
        #decoder = BinaryPayloadDecoder.fromRegisters(registers, byteorder=Endian.Big)
        result = decoder.decode_32bit_float()  # type: float
        print('reg ad #0 to 9: %s' %registers)
        print('reg ad #0 to 9: %s' %result)

    else:
        print('unable to read registers')

    # sleep 2s before next polling
    time.sleep(2)

ago by
I found this website that does Binary to Float conversion:

https://www.binaryconvert.com/result_float.html

The values I got for Latitude from the modem were 21826 and 65514

65514 in binary is 1111111111101010

21826 in binary is 0101010101000010

If am pretty certain that this should be Little Endianess, so I swapped the first and second bytes (8 bits) of each 16 bit word, giving

1110101011111111 and 0100001001010101

I know that the value is positive so the number has to start with a 0.
Giving one big 32 bit number of 01000010010101011110101011111111

Putting that in to the web page above gives me 5.3479488372802734375E1, which matches the 53.479488372802734 given by the Python program I gave in my last post.  The problem is that the correct latitude reported by the modem web page is 53.390019, which I know to be correct.  So there does seem to be a problem in the Teltonika conversion of GPS data to Modbus data.  Anybody from Teltonika available to look at this?