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 that you accept these cookies being set.

Universal Modbus TCP/RTU Slave
#41
(14.03.2023, 06:18)admin Wrote: holdingregisters = registers, you need to use inputregisters instead.
mb.setfloat16precision(2) sets how float16 is converted to integer. By default it's 2 decimals (0.01 precision). Change 2 to 0 to convert to integer without any decimals.

I tried to change "registers" to "inputegisters", but it still doesn't work. I disabled and then re-enabled the resident script, but the address mapped by "inputegister" still doesn't work.

This is the changed code:
Code:
mb.setmapping({
  [7] = {
    coils = {
      [1] = '0/0/1',
      [2] = '0/0/2',
      [3] = '0/0/3',
    },
    registers = {
      [1] = '0/1/1',
      [2] = '0/1/2',
      [3] = '0/1/3',
    } ,
    inputregisters = {
      [1] = '0/1/4',
      [2] = '0/1/5',
    }
  }
})

In addition, I want to implement the knx address' 1/1/1 'to' 1/1/100 'to map the continuous list of registered addresses [0] to [100]. Now I need to write 100 mapping statements to implement it. Is there a fast implementation method?
Reply
#42
Check that the name is exactly inputregisters, you have the name misspelled twice in your post.
Reply
#43
(14.03.2023, 07:39)rw_echo Wrote:
(14.03.2023, 06:18)admin Wrote: holdingregisters = registers, you need to use inputregisters instead.
mb.setfloat16precision(2) sets how float16 is converted to integer. By default it's 2 decimals (0.01 precision). Change 2 to 0 to convert to integer without any decimals.

I tried to change "registers" to "inputegisters", but it still doesn't work. I disabled and then re-enabled the resident script, but the address mapped by "inputegister" still doesn't work.

This is the changed code:
Code:
mb.setmapping({
  [7] = {
    coils = {
      [1] = '0/0/1',
      [2] = '0/0/2',
      [3] = '0/0/3',
    },
    registers = {
      [1] = '0/1/1',
      [2] = '0/1/2',
      [3] = '0/1/3',
    } ,
    inputregisters = {
      [1] = '0/1/4',
      [2] = '0/1/5',
    }
  }
})

In addition, I want to implement the knx address' 1/1/1 'to' 1/1/100 'to map the continuous list of registered addresses [0] to [100]. Now I need to write 100 mapping statements to implement it. Is there a fast implementation method?

ChatGPT will be fast enough 
Code:
inputregisters = {
      [1] = '1/1/0',
      [2] = '1/1/1',
      [3] = '1/1/2',
      [4] = '1/1/3',
      [5] = '1/1/4',
      [6] = '1/1/5',
      [7] = '1/1/6',
      [8] = '1/1/7',
      [9] = '1/1/8',
      [10] = '1/1/9',
      [11] = '1/1/10',
      [12] = '1/1/11',
      [13] = '1/1/12',
      [14] = '1/1/13',
      [15] = '1/1/14',
      [16] = '1/1/15',
      [17] = '1/1/16',
      [18] = '1/1/17',
      [19] = '1/1/18',
      [20] = '1/1/19',
      [21] = '1/1/20',
      [22] = '1/1/21',
      [23] = '1/1/22',
      [24] = '1/1/23',
      [25] = '1/1/24',
      [26] = '1/1/25',
      [27] = '1/1/26',
      [28] = '1/1/27',
      [29] = '1/1/28',
      [30] = '1/1/29',
      [31] = '1/1/30',
      [32] = '1/1/31',
      [33] = '1/1/32',
      [34] = '1/1/33',
      [35] = '1/1/34',
      [36] = '1/1/35',
      [37] = '1/1/36',
      [38] = '1/1/37',
      [39] = '1/1/38',
      [40] = '1/1/39',
      [41] = '1/1/40',
      [42] = '1/1/41',
      [43] = '1/1/42',
      [44] = '1/1/43',
      [45] = '1/1/44',
      [46] = '1/1/45',
      [47] = '1/1/46',
      [48] = '1/1/47',
      [49] = '1/1/48',
      [50] = '1/1/49',
      [51] = '1/1/50',
      [52] = '1/1/51',
      [53] = '1/1/52',
      [54] = '1/1/53',
      [55] = '1/1/54',
      [56] = '1/1/55',
      [57] = '1/1/56',
      [58] = '1/1/57',
      [59] = '1/1/58',
      [60] = '1/1/59',
      [61] = '1/1/60',
      [62] = '1/1/61',
      [63] = '1/1/62',
      [64] = '1/1/63',
      [65] = '1/1/64',
      [66] = '1/1/65',
      [67] = '1/1/66',
      [68] = '1/1/67',
      [69] = '1/1/68',
      [70] = '1/1/69',
      [71] = '1/1/70',
      [72] = '1/1/71',
      [73] = '1/1/72',
      [74] = '1/1/73',
      [75] = '1/1/74',
      [76] = '1/1/75',
      [77] = '1/1/76',
      [78] = '1/1/77',
      [79] = '1/1/78',
      [80] = '1/1/79',
      [81] = '1/1/80',
      [82] = '1/1/81',
      [83] = '1/1/82',
      [84] = '1/1/83',
      [85] = '1/1/84',
      [86] = '1/1/85',
      [87] = '1/1/86',
      [88] = '1/1/87',
      [89] = '1/1/88',
      [90] = '1/1/89',
      [91] = '1/1/90',
      [92] = '1/1/91',
      [93] = '1/1/92',
      [94] = '1/1/93',
      [95] = '1/1/94',
      [96] = '1/1/95',
      [97] = '1/1/96',
      [98] = '1/1/97',
      [99] = '1/1/98',
      [100] = '1/1/99',
      [101] = '1/1/100',
}
    

Attached Files Thumbnail(s)
   
Reply
#44
There was a bug with input registers in the library. Use updated code from the first post and restart the resident script afterwards.
Reply
#45
(14.03.2023, 08:15)admin Wrote: Check that the name is exactly inputregisters, you have the name misspelled twice in your post.

I did make two errors in my post, but I checked that the "inputegisters" in the code were correct.

I saw that there is no relevant description of "inputegisters" in the user library 'mbtcp' script in Daniel's post. Is "user. mbtcp" missing the command statement of "inputegisters"?
Reply
#46
I have tried to connect one LogicMachine ModbusRTU as Slave, and another LogicMachine ModbusRTU as Master (using profiles), and it doesnt word, then
I have tested using one LogicMachine ModbusTCP as Slave, and another LogicMachine ModbusTCP as Master (using profiles), and it works, very well.
I have connected both Logicmachine using interface RS485-1 (A-A, B-B)
The code I am using is:

local mb = require('user.mbslave')
local mbrtu = require('luamodbus').rtu()

mbrtu:open('/dev/RS485-1', 115200, 'E', 8, 1, 'H')
mbrtu:connect()
mbrtuConfusedetslave(1) -- '*' handles multiple RTU slave IDs

mb.setmapping({
--[slave ID = 1]
[1] = {
coils = {
[0] = '32/0/13', -- On/Off Luces Dpto. Técnico
[1] = '32/0/113', -- Estado On/Off Luces Dpto. Técnico

},
registers = {
[0] = '32/2/24', -- Luminosidad Dpto. Técnico
[10] = '32/2/23', -- TConsigna AACC Dpto.Técnico
[11] = '32/2/123', -- Estado TConsigna AACC Dpto.Técnico
}
}
})

mb.setswap('w')
mb.setfloat16precision(2)

while true do
mb.rtuhandler(mbrtu)
end

Am I doing something wrong?, Anybody have tested it?

best regards
Reply
#47
Yes this script was fully tested, make sure you use correct interface and settings are same on master and slave.
------------------------------
Ctrl+F5
Reply
#48
(06.06.2023, 14:18)Daniel Wrote: Yes this script was fully tested, make sure you use correct interface and settings are same on master and slave.

Hello admin:

Yes, I have used correct interface and settings are same on master and slave.

In error log, it show me the next: 

User library mbslave:432: attempt to call method 'send' (a nil value)
stack traceback:
User library mbslave:432: in function 'rtuhandler'


bestregards
Roger
Reply
#49
Install 2023 firmware release.
Reply
#50
(06.06.2023, 15:34)admin Wrote: Install 2023 firmware release.

yes, yes, yes, now it works....

thank you very much..
best regards

Roger
Reply
#51
Hi LM Team,

Many thanks for suppling this scripts! They work perfectly.

One question:
- How can I define a register with a permanent INT16 value = 6? So don‘t use a group-address as source of the register.

Many thanks for your help!

Best Regards
Steffen
Reply
#52
Such feature is not implemented. You can simply use a virtual object for this.
Reply
#53
Hello Dears,
Has any one integrate UPS NETMAN 204 TCP/IP .
Datasheet attached

Attached Files
.pdf   0MNACCSA4ENUB (MAN ACC NETMAN 204 EN).pdf (Size: 1.11 MB / Downloads: 13)
Best Regards,
Reply
#54
Hi @all,

I want to connect a Kostal Smart Energy Meter to the universal Modbus Slave running on LM. Unfortunately I do not know right now what registers the Energy Meter expects to run correctly. Is there any possibility to log/which registers the Energy Meter is requesting/polling from universal Modbus Slave on LM?

Many thanks for your help!

Best regards
Steffen
Reply
#55
No, without documentation of registers and data type used by the devices it’s hardy possible and guessing what registers is used for what..

So you need this documentation …
Reply
#56
Hi Erwin,

many thanks for the quick reply. I having a documentation what registers generally existing, but I don‘t know which one are getting polled. If I would know this I could make a match. Any ideas with this additional information?

Many thanks!

Best regards
Steffen
Reply
#57
That depends on your script or profile, there you set the registers that you want to read/write and is matching the registers described in your device document..
Reply
#58
Not the best thread to place this question as this is slave script topic where you need modbus profile. Please create separate Thread.
------------------------------
Ctrl+F5
Reply
#59
Hi! Please clarify how to change datatype of holdingregister from integer to float16 or 32?

Float temperature value by default is converted to integer x100. How to change it to float ?

   
Reply
#60
This is how it meant to work. You need to convert it back to float on master device.
mb.setfloat16precision(2) sets how float16 is converted to integer. By default it's 2 decimals (0.01 precision). Change 2 to 0 to convert to integer without any decimals.
------------------------------
Ctrl+F5
Reply


Forum Jump: