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.

Modbus Float32
#1
Hi all need some with a float32 issue. 
When using Modbus profiles like: 
{
"product_code": "Socket Meter",
  "mapping": [
{"name": " Active Power", "bus_datatype": "float32", "datatype": "float32","units": "kWh", "type": "inputregister", "address": 52},
{"name": "Total System", "bus_datatype": "float32", "datatype": "float32","units": "kW", "type": "inputregister", "address": 72}],
  "manufacturer": "Eastron",
  "name": "1Phase Smart Meter",
  "product_range": "SDM-M",
  "description": "Modbus 3 Phase Meter Direct Connect"
}


Works fine and we get the correct values.

But we need to use modbus scripting rather than profiles, so using:

require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485-1', 9600, 'N', 8, 1, 'H')
res, err = mb:connect()
if res then
  mbConfusedetslave(1)
  value1 = mb:readregistervalue(52,"float32","n")  --Meter (n=no swap, w=word swap, b=byte swap, bw=byte and word swap)   
  value2 = mb:readregistervalue(72,"float32","n")
log('V1: ' .. value1 .. ' and V2: '..value2)
else
  log('Umm !!, connection failed : '.. err)
end
mb:close()


But not getting any figures (0 only), So I am assuming there must be a conversion problem with bus data type, I need to do as well.
Any suggestion's would be appreciated.
Reply


Messages In This Thread
Modbus Float32 - by sjfp - 18.09.2021, 12:15
RE: Modbus Float32 - by admin - 18.09.2021, 12:16
RE: Modbus Float32 - by sjfp - 18.09.2021, 13:13
RE: Modbus Float32 - by sjfp - 20.09.2021, 13:21
RE: Modbus Float32 - by admin - 20.09.2021, 15:27
RE: Modbus Float32 - by sjfp - 20.09.2021, 18:55
RE: Modbus Float32 - by Leo681 - 19.03.2022, 21:21
RE: Modbus Float32 - by admin - 21.03.2022, 08:13
RE: Modbus Float32 - by Leo681 - 21.03.2022, 20:59

Forum Jump: