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 script problem - Timeout
#1
Hi!

I'm facing some problems with modbus script over some time.
After some time (about week or two) communication goes to timeout (all reading/writing parameters). After I disable modbus script, enabling port on modbus tab, going to scan modbus devices on specific port (and system finds device with address), disable port on modbus tab, enable script again - everything starts to work again via script.

I attach code in here.
What can cause this?

Resident script with 10s sleep
Mitsubishi frequency converter
Code:
require('luamodbus')
vent_command = grp.getvalue('1/3/13')
reset_command = grp.getvalue('34/1/4')


control_motor = true
motor_on = vent_command

speed_value_perc = grp.getvalue('34/1/2')
hz_sp = math.floor(speed_value_perc*50)

mb = luamodbus.rtu()
mb:open('/dev/RS485-2', 19200, 'E', 8, 1)
mb:connect()
mb:setslave(5)


speed_read,err= mb:readregisters(202)
--log('Speed read22',speed_read,err)

read_mode,err= mb:readregisters(8)
--log('Read mode',read_mode,err)

read_speed,err= mb:readregisters(13)
log('Read speed',read_speed,err)



read_inputs,err= mb:readregisters(214)
--log('Read inputs',read_inputs,err)

read_alarm,err= mb:readregisters(500)
--log('Read alarms',read_alarm,err)


if control_motor then
  if motor_on then
    if read_mode ~= 75 then
      res,err = mb:writeregisters(8,2)
      --log('Write_motor_to_on',res,err)
    end

    if read_speed ~=hz_sp then
      res,err =mb:writeregisters(13,hz_sp)
      --log('Write_motor speed',res,err)
    end
  else
    if read_mode ~= 0 then
      res,err = mb:writeregisters(8,0)
      --log('Write motor off',res,err)
    end
  end
end

if reset_command then
  --log('Reseting frequency converter')
  log(mb:writeregisters(1,1))
  grp.checkupdate('34/1/4', 0)
end

mb:close()

if read_mode == 75 or read_mode == 67 then
  grp.update('34/1/3', read_speed/50)
elseif read_mode == 0 then
  grp.update('34/1/3', 0)
end

I have seen this kind of problem with some other devices as well (chiller cooling units and swegon ventilation unit).
Reply


Messages In This Thread
Modbus script problem - Timeout - by fleeceable - 27.08.2024, 08:13

Forum Jump: