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.

F&F LE-03MQ Modbus energy counter
#35
1) I've tried also with switching on Modbus mapper, and after this, reading all of this registers takes only 4 seconds so I see that other RS-485 inputs are connected with themselves.

2) When I switched on the Modbus mapper then still reading the registers via script takes 3-5 seconds. It is enough, but if there would be a possibility to go down to 1 second it would be great from the learning pointWink What I can improve in below script? (When I am changing timeout the interval is still the same)

Code:
start = os.microtime()

require('json')
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485-2', 9600, 'N', 8, 1, 'H')
mb:connect()
timeout = 0.020
mb:setresponsetimeout(timeout)
mb:setslave(4)


energyMeters = [[
{
 "manufacturer": "F&F",
 "description": "Licznik energii LE-03MQ",
 "mapping": [
    { "address": 0, "name": "Napięcie fazowe L1", "delta": 2 },
    { "address": 2, "name": "Napięcie fazowe L2", "delta": 2 },
    { "address": 4, "name": "Napięcie fazowe L3", "delta": 2 },
    { "address": 6, "name": "Natężenie prądu L1", "delta": 0.5 },
    { "address": 8, "name": "Natężenie prądu L2", "delta": 0.5 },
    { "address": 10, "name": "Natężenie prądu L3", "delta": 0.5 },
    { "address": 12, "name": "Moc czynna L1", "delta": 50 },
    { "address": 14, "name": "Moc czynna L2", "delta": 50 },
    { "address": 16, "name": "Moc czynna L3", "delta": 20 },
    { "address": 24, "name": "Moc bierna L1", "delta": 50 },
    { "address": 26, "name": "Moc bierna L2", "delta": 50 },
    { "address": 28, "name": "Moc bierna L3", "delta": 50 },
    { "address": 30, "name": "Współczynnik mocy L1", "delta": 0.01 },
    { "address": 32, "name": "Współczynnik mocy L2", "delta": 0.01 },
    { "address": 34, "name": "Współczynnik mocy L3", "delta": 0.01 },
    { "address": 52, "name": "Całkowita moc układu", "delta": 50 },
    { "address": 60, "name": "Całkowita moc bierna układu", "delta": 50 },
    { "address": 62, "name": "Współczynnik mocy układu", "delta": 0.01 },
    { "address": 70, "name": "Częstotliwość napięć zasilania", "delta": 0.25 },
    { "address": 200, "name": "Napięcie międzyfazowe L1-L2", "delta": 2 },
    { "address": 202, "name": "Napięcie międzyfazowe L2-L3", "delta": 2 },
    { "address": 204, "name": "Napięcie międzyfazowe L3-L1", "delta": 2 },
    { "address": 224, "name": "Prąd przewodu zerowego", "delta": 1 },
    { "address": 234, "name": "Współczynnik zawartości harmonicznych napięcia L1-N", "delta": 1 },
    { "address": 236, "name": "Współczynnik zawartości harmonicznych napięcia L2-N", "delta": 1 },
    { "address": 238, "name": "Współczynnik zawartości harmonicznych napięcia L3-N", "delta": 1 },
    { "address": 240, "name": "Harmoniczne prądu fazy 1", "delta": 1 },
    { "address": 242, "name": "Harmoniczne prądu fazy 2", "delta": 1 },
    { "address": 244, "name": "Harmoniczne prądu fazy 3", "delta": 1 },
    { "address": 334, "name": "Harmoniczna napięcia międzyfazowego L1-L2", "delta": 1 },
    { "address": 336, "name": "Harmoniczna napięcia międzyfazowego L2-L3", "delta": 1 },
    { "address": 338, "name": "Harmoniczna napięcia międzyfazowego L3-L1", "delta": 1 },
    { "address": 342, "name": "Całkowita energia czynna", "delta": 0.1 },
    { "address": 344, "name": "Całkowita energia bierna", "delta": 0.1 }    
 ]
}]]

errors = 0

energyMeters = json.decode(energyMeters)
meterName = 'Licznik 1 - '

function readRegister(meterName, address, name, delta)
 for i = 1, 7, 1 do
   res, err = mb:readinputregistervalue(address, "float32", "w")
   if res then
       GA = meterName .. name
         value = math.round(res, 2)
     grp.checkwrite(GA, value, delta)
     break
   else
     errors = errors + 1
   end
 end
end

for k,meter in pairs(energyMeters.mapping) do
 readRegister(meterName, meter.address, meter.name, meter.delta)
end


mb:close()


developmentInfo = false


if developmentInfo then
log('Duration: ' .. os.microtime()-start .. 's, ' .. errors .. 'errors')
end



If it is about LM Load Balancer please provide some example how can I mount RS-485<>USB converter ch340.

http://blog.lincomatic.com/?p=1616
Reply


Messages In This Thread
RE: F&F LE-03MQ Modbus energy counter - by buuuudzik - 27.09.2017, 13:53

Forum Jump: