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 > writeregisters for INT
#3
Hi,

when I write an INT16 in the register concerned, the value is taken into account by the slave, but the slave then goes into error when its "time out" time is reached. It seems that the Modbus frame is misinterpreted.

This does not happen when I write UINT16 in the registers of the same slave.

Here is my script (reduced to the problem section) :

------------------------------------------------------------------------------
modbus_slave_num = 7

-- eval temps execution de ce script
local ts, tus = os.microtime()

-- nom de ce script
log("--------------------------------------------------------------------")
log(_SCRIPTNAME)

-- Init Modbus
modbus_slave_num = 7

if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open("/dev/RS485", 19200, "E", 8, 1,"H")
mb:connect()
end

mbConfusedetslave(modbus_slave_num)

-- register 11410 = INT16 <<<<<<<<< PROBLEM >>>>>>>>>>>>>
result1 = mb:writeregisters(11410, 130)
log ("Result1 = ",result1)

-- Fermer la connexion Modbus
mb:close()

-- eval temps execution de ce script
log("TEMPS EXCE : ", os.udifftime(ts, tus))

------------------------------------------------------------------------------

Have a nice end of day,
Dominique
Reply


Messages In This Thread
Modbus > writeregisters for INT - by SigmaTec - 08.11.2018, 08:58
RE: Modbus > writeregisters for INT - by SigmaTec - 08.11.2018, 14:23

Forum Jump: