Modbux (Modbus) results - misconfiguration, wrong usage?

Hi,

I have a gateway which is configured as modbus master and there are 2 slave devices. One inverter and one heat pump. I don’t use Nerves, but plain Linux and Elixir codebase. Package that I am using is Modbux.

On the linux part I am using mbpoll to test req/res to/from modbus slave.

One of the commands I do is

$ mbpoll -a 20 -b 19200 -t 4 -r 2103 -1 /dev/ttyAMA10
mbpoll 1.0-0 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.

Protocol configuration: Modbus RTU
Slave configuration...: address = [20]
                        start reference = 2103, count = 1
Communication.........: /dev/ttyAMA10,      19200-8E1
                        t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave 20...
[2103]: 	299

The result here is outside temperature of a Heat pump. In my case it is 29.9 degrees celsius.

So above flags are

  • 20 is a slave id
  • b is baudrate
  • t 4 is 16-bit output (holding) register data type (default)
  • r is register address
  • -1 is to read only once

Then I try to do the same with modbux in iex and I get totaly different numbers/result. And I still don’t understand why? I assume I don’t use library correctly. Can someone please point me to the right direction?

iex(1)> alias Modbux.Rtu.Master
Modbux.Rtu.Master
iex(2)> uart_opts = [
...(2)>   speed: 19200,
...(2)>   data_bits: 8,
...(2)>   parity: :none,
...(2)>   stop_bits: 1,
...(2)>   framing_timeout: 1000
...(2)> ]
[speed: 19200, data_bits: 8, parity: :none, stop_bits: 1, framing_timeout: 1000]
iex(3)> {:ok, pid} = Master.start_link(tty: "/dev/ttyAMA10", active: false, timeout: 5000, uart_opts: uart_opts)

13:59:01.920 [debug] (Elixir.Modbux.Rtu.Master) Starting Modbux Master at "/dev/ttyAMA10"

13:59:01.959 [debug] (Elixir.Modbux.Rtu.Master) Reported UART configuration: "{"/dev/ttyAMA10", [speed: 19200, data_bits: 8, stop_bits: 1, parity: :none, flow_control: :none, active: false, id: :name, rx_framing_timeout: 0, framing: Modbux.Rtu.Framer]}"
{:ok, #PID<0.190.0>}
iex(4)> Master.request(pid, {:rhr, 20, 2103, 1})

13:59:04.900 [debug] (Elixir.Modbux.Rtu.Master) Frame: <<0x14, 0x3, 0x8, 0x37, 0x0, 0x1, 0x35, 0x61>>
{:ok, [184]}
iex(5)> 

Is it conversion needed? Frame? I am a bit lost right now. I would appreciate any kind of help. Thanks in advance.

Looks like I didn’t fully understand register numbers vs register addresses. In my case in documentation for heat pump numbers were register numbers and inverter has register addresses. And somehow I couldn’t find any text regarding this in the Modbux documentation. Modbux uses register addresses. So when I lowered the address -1 it all worked. Or is there a better way?

1 Like

In my experience, it depends on the manufacturer. Some write the address starting at 1 and others at 0. Sometimes the bytes are swapped and I think sometimes even the bits are ordered in reverse.