SpaceLogic KNX Forum
Schneider Electric SpaceLogic KNX forum to get support and share knowledge including selection, installation and troubleshooting for spaceLYnk, Wiser for KNX, eConfigure KNX, SpaceLogic KNX Hybrid module and other topics.
Posted: 2014-10-07 01:18 AM . Last Modified: 2024-07-15 12:05 AM
Link copied. Please paste this link to share this article on your social media post.
Reading basic and complete Modbus parameters from Acti9 Power meters via LUA scripts
Link copied. Please paste this link to share this article on your social media post.
Hi Darya,
I've tried your scripts and they work fine.
No I've tried to modify the script for reading values of other power meters like PM800. But against what is written in your AN I can't find supported datapoint formats like Int16 and Int32, only UInt16 and UInt32. Please can you give me a hint, how I will have to modify the script to support signed integers (I can read all the values from the PM800, but negative values are showed as unsigned values e.g. -1 -> 32767)?
Thanks
Daniel
Link copied. Please paste this link to share this article on your social media post.
Hi Daniel,
Darya is not available till wednesday, so here is your answer. Extend your library MbPwmRTU.TYPES definition for these types:
Int16 = {
size = 1,
deltaFunct = 5,
-- function to read value from modbus registed
read = function(mb, address, regsize, debug)
local ret = MbPwmRTU.mbRead(mb, address, regsize or MbPwmRTU.TYPES.UInt16.size, debug)
return bit.band(ret, 0x7fff) * ((bit.rshift(ret, 15) == 0) and 1 or -1)
end,
},
Int32 = {
size = 2,
deltaFunct = 5,
-- function to read value from modbus registed
read = function(mb, address, regsize, debug)
local v1, v2 = MbPwmRTU.mbRead(mb, address, regsize or MbPwmRTU.TYPES.UInt32.size, debug)
return (bit.lshift(bit.band(v1, 0x7fff), 16) + v2) * ((bit.rshift(v1, 15) == 0) and 1 or -1)
end,
},
Link copied. Please paste this link to share this article on your social media post.
Hi Jaroslav,
Thanks a lot for your support. Unfortunately it didn't work that way, so I had to modify your script a little bit like this:
Int16 = {
size = 1,
deltaFunct = MbPwmTCP._numDeltaFunct,
-- function to read value from modbus registed
read = function(mb, address, regsize, debug)
local ret = MbPwmTCP.mbRead(mb, address, regsize or MbPwmTCP.TYPES.UInt16.size, debug)
return bit.band(ret, 0x7fff) + ((bit.rshift(ret, 15) == 0) and 0 or -32768)
end,
},
Link copied. Please paste this link to share this article on your social media post.
Yes, you are right, I see it now, really sorry for misleading you.
It happens when you are used to work mostly with scripting languages and coding and writing to forum when asleep.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.