Modbus sent single value bit - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Modbus sent single value bit (/showthread.php?tid=5510) |
Modbus sent single value bit - TomasIha - 12.07.2024 Hello, maybe you can help me, how can I send the value only to 8bit, because if I use this script everything works, but it also activates 1bit as an example. I want to send the value only as an example 8bit require('luamodbus') mb = luamodbus.tcp() mb:open('10.30.0.242', 8000) mb:connect() mbetslave(1) bendra_reiksme = mb:readregisters(1000) function setbit(value, bitnr) local mask = bit.lshift(1, bitnr) return bit.bor(value, mask) end value = setbit(1, 8) mb:writeregisters(1000, value) mb:close() RE: Modbus sent single value bit - admin - 12.07.2024 Try this: Code: require('luamodbus') The recommended approach is to use profiles. RE: Modbus sent single value bit - TomasIha - 12.07.2024 This script is the same as mine. How can I send a value of only 8bit, because now 1bit is momentary, and when I send a value of 8bit, it also activates 1bit RE: Modbus sent single value bit - admin - 12.07.2024 (12.07.2024, 11:33)TomasIha Wrote: This script is the same as mine. It isn't the same (left is original, right is modified): RE: Modbus sent single value bit - TomasIha - 01.08.2024 Hi, I tried this script. Everything works, but when this value is sent to the modbus register, the other bits of the modbus address also receive values and trigger other device functions. How can change only 8bit value RE: Modbus sent single value bit - admin - 01.08.2024 Check if your device supports function code #22 (Mask Write Register). RE: Modbus sent single value bit - TomasIha - 01.08.2024 If I find out that it supports it, maybe you can give an example of the script |