This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Modbus register type
#1
Hello,

I'm having difficulties writing to one particular register. I don't know if the device or the documentation is faulty, or if we are sending out wrong type to it.

Code:
0x00001 Unit on
0x00002 Overpressure mode
0x00003 Boost mode
0x00004 Away mode
0x00005 Clear Alarms Write 1 to clear alarm, reads always 0
0x00006 Reset filter timer Write 1 to reset filter timer, reads always 0



Manufacturer say: Discrete output - 0x0006 (this is the register I'm having trouble with)

In LM it should be
Code:
{ "name": "Reset filter timer", "bus_datatype": "bool", "type": "coil", "address": 5, "writable": 1, "bus_address": "2/1/5" },


I can read on Modbus documention that there are different commands, FC01 = read, FC05 = Write single, FC15 = Write multiple.
Can I in JSON mapper define for example FC05?

I have spoke with one guy that say he doesn't have any trouble resetting the filter timer over modbus using 0x0006 register.
However, he uses a Siemens Pxc100 with RTU module, and his command is "5x00005", I was thinking the 5x=FC05?

Funny thing is, I'm able to write to the first 4 registers in above list without problem and the JSON is identical, so I believe it should work as I have written in the JSON and something must be wrong in the device handling Modbus.

Code:
   
.........................
   { "name": "Unit ON", "bus_datatype": "bool", "type": "coil", "address": 0, "writable": 1, "bus_address": "2/1/0" },
   { "name": "Overpressure mode", "bus_datatype": "bool", "type": "coil", "address": 1, "writable": 1, "bus_address": "2/1/1" },
   { "name": "Boost mode", "bus_datatype": "bool", "type": "coil", "address": 2, "writable": 1, "bus_address": "2/1/2" },
   { "name": "Away mode", "bus_datatype": "bool", "type": "coil", "address": 3, "writable": 1, "bus_address": "2/1/3" },
   { "name": "Clear Alarms", "bus_datatype": "bool", "type": "coil", "address": 4, "writable": 1, "bus_address": "2/1/4" },
   { "name": "Reset filter timer", "bus_datatype": "bool", "type": "coil", "address": 5, "writable": 1, "bus_address": "2/1/5" },
.........................
Reply
#2
Profile entry looks correct. Do you get anything in ModBus error log? Have you tried using RTU read test to check other coil values?
Reply
#3
No errors in the log.
I have tested reading, however this particular coil I have problem with always reads 0, so it would be hard to find the correct coil this way.
When I write 1 to the coil, it returns to 0 after a second or two. I have tried reading the coil as fastest I can after I've have sent 1 (< 1sec), but always read 0.

Reading Coil-0 return true, which is correct. The rest are false. (as it should be)

   

Reading coils >5 gives "Illegal data address", so probably coil 5 is correct.. And if we are using correct command I guess something is corrupted in device firmware!?
Reply
#4
The documentation states that read always returns 0 for this coil. And since addressing starts with 1 there the correct address for filter reset is 5 that you are already using.
Reply
#5
Hello,

I am fiddling with a UIO20E, with the intention of configuring it as outputs.

I have the mapping like this.


Code:
{
  "manufacturer": "Indomogal",
  "description": "Universal 16+4 I/O module",
  "mapping": [
    {
      "name": "Output 1",
      "bus_datatype": "1",
      "type": "coil",
      "address": 0,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 2",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 1,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 3",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 2,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 4",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 3,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 5",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 4,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 6",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 5,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 7",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 6,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 8",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 7,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 9",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 8,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 10",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 9,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 11",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 10,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 12",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 11,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 13",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 12,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 14",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 13,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 15",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 14,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 16",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 15,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}

    }
  ]
}

In principle it works correctly, since I get voltage at the outputs.

But in registers, I get this: Modbus (RTU 1 slave 1) read failed: Illegal data value.


I installed a 120 ohm resistor, so I saw in another post, before installing it it gave me more errors.
Reply
#6
Please post full profile. What baud rate are you using?
Reply
#7
(12.03.2020, 19:35)admin Wrote: Please post full profile. What baud rate are you using?


RTU 1
RTU (serial) enabled: ok
Port: /dev/RS485-1
Baud rate: 115200
Parity: Even
Duplex: Half-duplex
----------------------------------------------------
Connection type: RTU 1
Device address: 1
Poll interval (seconds): 5
Timeout (seconds):  0.5


I increased the timeout even to 5 seconds but it does the same. In the log, after overnight, Read failed: Illegal data value and read failed: Operation timed out
Reply
#8
Try lowering baud rate to 19200. You will need to change baud rate in RTU settings first then do write address to UIO20.
Reply
#9
(13.03.2020, 07:58)admin Wrote: Try lowering baud rate to 19200. You will need to change baud rate in RTU settings first then do write address to UIO20.
I made the changes and it gives me the same errors ... If I remove the load 120 Ohms the device flashes red.
Reply
#10
Hi
Any other tests you can do? From what I saw in some other post, these types of errors are frequent. I don't know if anyone managed to fix it.
Cheers
Reply
#11
You still haven't provided full profile that you are using for reading registers. You can also test using second RS-485 port if there's a hardware issue of some sort.
Another thing to try is to read register data via script. You need to disable modbus mapper before running this script. Post what you get in Logs tab. Change baud rate (19200) if needed.

Code:
require('luamodbus')
mb = luamodbus.rtu()

mb:open('/dev/RS485-1', 19200, 'E', 8, 1, 'H')
mb:connect()

buffer = {}

mb:setdebug(function(msg)
  buffer[ #buffer + 1 ] = msg
end)

mb:setslave(1)

res = { mb:readinputregisters(0, 16) }
log(res)

mb:close()

log(table.concat(buffer))
Reply
#12
(16.03.2020, 11:16)admin Wrote: You still haven't provided full profile that you are using for reading registers. You can also test using second RS-485 port if there's a hardware issue of some sort.
Another thing to try is to read register data via script. You need to disable modbus mapper before running this script. Post what you get in Logs tab. Change baud rate (19200) if needed.

Code:
require('luamodbus')
mb = luamodbus.rtu()

mb:open('/dev/RS485-1', 19200, 'E', 8, 1, 'H')
mb:connect()

buffer = {}

mb:setdebug(function(msg)
  buffer[ #buffer + 1 ] = msg
end)

mb:setslave(1)

res = { mb:readinputregisters(0, 16) }
log(res)

mb:close()

log(table.concat(buffer))

Code:
initscript 16.03.2020 19:22:02
* table:
[1]
  * number: 22810
[2]
  * number: 22845
[3]
  * number: 22748
[4]
  * number: 22828
[5]
  * number: 22854
[6]
  * number: 22819
[7]
  * number: 22872
[8]
  * number: 0
[9]
  * number: 0
[10]
  * number: 0
[11]
  * number: 0
[12]
  * number: 0
[13]
  * number: 0
[14]
  * number: 0
[15]
  * number: 0
[16]
  * number: 0

Code:
initscript 16.03.2020 19:22:02
* string: [01][04][00][00][00][10][F1][C6]
Waiting for a confirmation...
<01><04><20><59><1A><59><3D><58><DC><59><2C><59><46><59><23><59><58><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><85><1D>
the profile is this
Code:
{
  "manufacturer": "Indomogal",
  "description": "Universal 16+4 I/O module",
  "mapping": [
    {
      "name": "Output 1",
      "bus_datatype": "1",
      "type": "coil",
      "address": 0,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 2",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 1,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 3",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 2,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 4",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 3,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 5",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 4,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 6",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 5,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 7",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 6,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 8",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 7,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 9",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 8,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 10",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 9,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 11",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 10,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 12",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 11,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 13",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 12,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 14",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 13,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 15",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 14,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}
    },
    {
      "name": "Output 16",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 15,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"}

    }
  ]
}
Reply
#13
The reading looks ok. You said this, but your profile only has outputs:
Quote:But in registers, I get this: Modbus (RTU 1 slave 1) read failed: Illegal data value.
Reply
#14
(16.03.2020, 18:35)admin Wrote: The reading looks ok. You said this, but your profile only has outputs:
Quote:But in registers, I get this: Modbus (RTU 1 slave 1) read failed: Illegal data value.
Yes, I only have exits. So I don't understand the error messages. Do I need to change something somewhere?
Reply
#15
You can add "write_only": true to all profile fields to disable reading completely.
Reply
#16
Code:
"name": "Output 1",
      "bus_datatype": "bool",
      "type": "coil",
      "address": 0,
      "writable": 1,
      "value_custom": {"0": "Off", "1": "On"},
      "write_only": true


What do I need to add to get the channel status? when i reset the power supply i dont get the actual status of the channel. Is there a possibility to register it in a different object?

Whenever this happens, it is always off. Is there a chance it will keep the last state?
Reply
#17
You can copy definition for each coil and set "writable": true, "write_only": true for control and "writable": false, "write_only": false for status. This way you can map different objects to control and status.
Reply
#18
(04.06.2020, 11:16)admin Wrote: You can copy definition for each coil and set "writable": true, "write_only": true for control and "writable": false, "write_only": false for status. This way you can map different objects to control and status.
Thanks Admin for the help! Smile
Reply


Forum Jump: