21.02.2021, 13:07
(This post was last modified: 21.02.2021, 13:56 by m.j.sorokin.)
Good day!
There is an unclear problem with the Modbus TCP connection. The controller has restrictions on the number of registers requested at a time (no more than 16), and the controller can only process group requests for reading registers, the function read single registers is not supported. in this regard, I use the program code and not the modbus profiles.
Faced a very strange problem. Initially, I checked by reading the modbus pull program, when using it, I can open and close the connection many times in a row and the controller works it out correctly, but when using a fairly standard code for the logic machine, the datakom controller stops responding after several requests and even to connect the modus pull program as well does not connect. What could be the reason, did anyone come across a similar one?
description of the modus protocol for the datakom d-200 mk2 controller: http://datakom.com.tr/upload/Files/500_MODBUS.pdf
example of code i am using:
To restore communication with the controller, only its power restart helps, reconnecting the etnernet line does not remove the problem
There is an unclear problem with the Modbus TCP connection. The controller has restrictions on the number of registers requested at a time (no more than 16), and the controller can only process group requests for reading registers, the function read single registers is not supported. in this regard, I use the program code and not the modbus profiles.
Faced a very strange problem. Initially, I checked by reading the modbus pull program, when using it, I can open and close the connection many times in a row and the controller works it out correctly, but when using a fairly standard code for the logic machine, the datakom controller stops responding after several requests and even to connect the modus pull program as well does not connect. What could be the reason, did anyone come across a similar one?
description of the modus protocol for the datakom d-200 mk2 controller: http://datakom.com.tr/upload/Files/500_MODBUS.pdf
example of code i am using:
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('10.36.0.25', 502)
--mb:setresponsetimeout(5)
if mb:connect() then
log('connect')
reg10240, reg10241, reg10242, reg10243, reg10244, reg10245, reg10246 = mb:readregisters(10240,7)
if (reg10240 ~= nil) then log('Mains phase L1 voltage: '..reg10240) end
if (reg10242 ~= nil) then log('Mains phase L2 voltage: '..reg10242) end
if (reg10244 ~= nil) then log('Mains phase L3 voltage: '..reg10244) end
if (reg10246 ~= nil) then log('Genset phase L1 voltage: '..reg10246) end
os.sleep(0.5)
reg10338, reg10339, reg10340, reg10341 = mb:readregisters(10338,4)
if (reg10338 ~= nil) then log('Mains frequency: '..reg10338) end
if (reg10339 ~= nil) then log('Genset frequency: '..reg10339) end
if (reg10341 ~= nil) then log('Battery voltage: '..reg10341) end
mb:close()
else
log('read error reg10240...reg10246')
end
mb:close()
To restore communication with the controller, only its power restart helps, reconnecting the etnernet line does not remove the problem