13.11.2019, 09:43
Hello Erwin,
everything ok, except energy metering. I have a script for energy metering which is executed every 30 min. I have checked in logs and the script is executed every 30 mins. Also the AMEM3155 is operated well and measures values.
But the object doesn't be updated. The script is below. In the previous Homelynk I didn't have any problem. Can you help?
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
end
-- 19200 baud rate, even parity, 8 data bits, 1 stop bit, half duplex
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mbetslave(1)
-- Total active energy import
total1, total2, total3, total4 = mb:readregisters(3203,4)
if total1 then
total5=bit.lshift(total1,48)+bit.lshift(total2,32)+bit.lshift(total3,16)+total4
total5=total5/1000
log('act pwr 10/0/1',total5)
grp.write('10/0/1',total5)
end
-- Partial active energy import
partial1, partial2, partial3, partial4 = mb:readregisters(3255,4)
if partial1 then
partial5=bit.lshift(partial1,48)+bit.lshift(partial2,32)+bit.lshift(partial3,16)+partial4
partial5=partial5/1000
log('act pwr 10/0/2',partial5)
grp.write('10/0/2',partial5)
end
-- Phase1 active energy import
phase1, phase2, phase3, phase4 = mb:readregisters(3517,4)
if phase1 then
phase5=bit.lshift(phase1,48)+bit.lshift(phase2,32)+bit.lshift(phase3,16)+phase4
phase5=phase5/1000
log('act pwr 10/0/3',phase5)
grp.write('10/0/3',phase5)
end
-- Tarrif Day active energy import
day1, day2, day3, day4 = mb:readregisters(4195,4)
if day1 then
day5=bit.lshift(day1,48)+bit.lshift(day2,32)+bit.lshift(day3,16)+day4
day5=day5/1000
log('act pwr 10/0/4',day5)
grp.write('10/0/4',day5)
end
-- Tarrif Night active energy import
night1, night2, night3, night4 = mb:readregisters(4199,4)
if night1 then
night5=bit.lshift(night1,48)+bit.lshift(night2,32)+bit.lshift(night3,16)+night4
night5=night5/1000
log('act pwr 10/0/5',night5)
grp.write('10/0/5',night5)
end
-- Multi Tarrif active energy rate
tarrif1 = mb:readregisters(4190)
--if tarrif1 then
--tarrif2=bit.lshift(tarrif1,16)
--tarrif2=tarrif2/1000
log('act pwr 10/0/6',tarrif1)
grp.write('10/0/6',tarrif1)
--end
I
everything ok, except energy metering. I have a script for energy metering which is executed every 30 min. I have checked in logs and the script is executed every 30 mins. Also the AMEM3155 is operated well and measures values.
But the object doesn't be updated. The script is below. In the previous Homelynk I didn't have any problem. Can you help?
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
end
-- 19200 baud rate, even parity, 8 data bits, 1 stop bit, half duplex
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mbetslave(1)
-- Total active energy import
total1, total2, total3, total4 = mb:readregisters(3203,4)
if total1 then
total5=bit.lshift(total1,48)+bit.lshift(total2,32)+bit.lshift(total3,16)+total4
total5=total5/1000
log('act pwr 10/0/1',total5)
grp.write('10/0/1',total5)
end
-- Partial active energy import
partial1, partial2, partial3, partial4 = mb:readregisters(3255,4)
if partial1 then
partial5=bit.lshift(partial1,48)+bit.lshift(partial2,32)+bit.lshift(partial3,16)+partial4
partial5=partial5/1000
log('act pwr 10/0/2',partial5)
grp.write('10/0/2',partial5)
end
-- Phase1 active energy import
phase1, phase2, phase3, phase4 = mb:readregisters(3517,4)
if phase1 then
phase5=bit.lshift(phase1,48)+bit.lshift(phase2,32)+bit.lshift(phase3,16)+phase4
phase5=phase5/1000
log('act pwr 10/0/3',phase5)
grp.write('10/0/3',phase5)
end
-- Tarrif Day active energy import
day1, day2, day3, day4 = mb:readregisters(4195,4)
if day1 then
day5=bit.lshift(day1,48)+bit.lshift(day2,32)+bit.lshift(day3,16)+day4
day5=day5/1000
log('act pwr 10/0/4',day5)
grp.write('10/0/4',day5)
end
-- Tarrif Night active energy import
night1, night2, night3, night4 = mb:readregisters(4199,4)
if night1 then
night5=bit.lshift(night1,48)+bit.lshift(night2,32)+bit.lshift(night3,16)+night4
night5=night5/1000
log('act pwr 10/0/5',night5)
grp.write('10/0/5',night5)
end
-- Multi Tarrif active energy rate
tarrif1 = mb:readregisters(4190)
--if tarrif1 then
--tarrif2=bit.lshift(tarrif1,16)
--tarrif2=tarrif2/1000
log('act pwr 10/0/6',tarrif1)
grp.write('10/0/6',tarrif1)
--end
I