Code Monkey home page Code Monkey logo

Comments (4)

yphuangms avatar yphuangms commented on August 11, 2024

Hi,

For read operation, address "40001" means a read holding registers at address 1 (https://en.wikipedia.org/wiki/Modbus#Coil.2C_discrete_input.2C_input_register.2C_holding_register_numbers_and_addresses). When convert to PDU data frame, it becomes function code of 3, and starting address as 0. So the StartingAddress shown in the request from Modbus module to your Modbus target is 0 (in PDU format).

Please do double check your configuration and the Modbus device user manual to see if there's holding registers available at address 1.

Could you capture the logs which containing the exception messages? And your module configuration details. Thanks!

from iot-edge-modbus.

fetapsomi avatar fetapsomi commented on August 11, 2024

Hi, thanks for the reply.
I've not done anything with Modbus before so apologies in advance. From what I understand, 40001 contains data, Uint32.

40001 | 40002 | 2 | R | 0x03 | SID | Well-known value....

I've used a tool, modpol.exe to request data starting at the same register and it returned data, 5 registers.

modpoll.exe -c 5 -r 40001 -m tcp 192.168.x.x
modpoll 3.6 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2018 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP
Slave configuration...: address = 1, start reference = 40001, count = 5
Communication.........: 192.168.x.x, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave... (Ctrl-C to stop)
[40001]: 21365
[40002]: 28243
[40003]: 1
[40004]: 65
[40005]: 18034

I changed the register to 40098, float, still have the same problem.
Below is the config of the modbus module, pretty much the same as the example except for the IP and the register.

{
  "properties.desired": {
    "PublishInterval": "60000",
    "SlaveConfigs": {
      "Slave01": {
        "SlaveConnection": "192.168.x.x",
        "HwId": "PowerMeter-0a:01:01:01:01:01",
        "Operations": {
          "Op01": {
            "PollingInterval": "30000",
            "UnitId": "1",
            "StartAddress": "40001",
            "Count": "2",
            "DisplayName": "Voltage"
          }
        }
      }
    }
  }
}

The saved properties according to the modbus module

Saving reported properties: {"PublishInterval":60000,"SlaveConfigs":{"Slave01":{"Operations":{"Op01":{"PollingInterval":30000,"UnitId":1,"StartAddress":"40001","Count":2,"DisplayName":"Voltage","CorrelationId":"DefaultCorrelationId"}},"SlaveConnection":"192.168.x.x","RetryCount":10,"RetryInterval":50,"TcpPort":502,"HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":null,"StopBits":null,"DataBits":null,"Parity":null}}}

And the exception

Modbus exception code: 2

The successful trace results from modpol.exe shows the starting register as 40000
SuccefulTrace
And the unsuccessful trace results from modbus module shows the starting address as 0
UnSuccefulTrace

Thanks again

from iot-edge-modbus.

yphuangms avatar yphuangms commented on August 11, 2024

Based on your master simulator tool "modpoll" document https://www.modbusdriver.com/modpoll.html , I think you misunderstand how to mapping "reference number" to Modbus module configuration "StartAddress".
When use "modpoll", with "-r 40000" only, which means to use default operation type of "-t 4 16-bit output (holding) register data type (default)".
The full compatible command line should be :
modpoll.exe -c 5 -r 40001 -t 4 -a 1 -m tcp 192.168.x.x
To map to the Modbus module configuration, "-a 1" maps to "UnitId": "1"; "-t 4" means to read from holding register, which is function code 3, so the StartAddress will start with digit 4; "-r 40001" means to read holding register from address 40001, and combining with the function code, the starting digit will be 4, so it maps to "StartAddress": "440001".
You should configure Modbus module like this for your test case:

"Op01": {
"PollingInterval": "30000",
"UnitId": "1",
"StartAddress": "440001",
"Count": "2",
"DisplayName": "Voltage"
}

from iot-edge-modbus.

fetapsomi avatar fetapsomi commented on August 11, 2024

Thanks, that sorted it. Appreciate your help!

from iot-edge-modbus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.