Logic Machine Forum
Modbus cyclic writes - 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 cyclic writes (/showthread.php?tid=6056)



Modbus cyclic writes - Smeagol - 21.07.2025

Hi,

I have a modbus slave on which i want to write a register periodically. Can this be done via the Modbus UI? I have the following profile prepared:
Code:
{
    "manufacturer": "IDM",
    "description": "Heat Pump Injection",
    "mapping": [        
        {
            "name": "Current Injection",
            "bus_datatype": "float32",
            "type": "register",
            "address": 74,            
            "writable": 1,
            "write_only": 1,
            "datatype": "float32",
            "units": "Kw",
            "read_swap": true,
    "value_multiplier": "0.001"
        }
    ]
}

But i have no clue when the value will be written? Is it only on mapped address change? Of can it be set to update no matter what every 30 seconds? If so, how? Or should this be done differently? 

Thanks for the help!


RE: Modbus cyclic writes - Daniel - 21.07.2025

It is on write to the mapped object, create a resident or scheduled script which will write periodically to this object.


RE: Modbus cyclic writes - admin - 21.07.2025

This should be helpful: https://forum.logicmachine.net/showthread.php?tid=1878


RE: Modbus cyclic writes - Smeagol - 21.07.2025

Thanks!


RE: Modbus cyclic writes - Smeagol - 21.07.2025

Follow up question. For reads i need to use the swap_read option. I thus assume i should also swap the write (words) as i attempt to write a float32, meaning two 16 bit registers. Since i send a group address, how can i swap the words? I do not see an option for this in the profile (documentation profile json).


RE: Modbus cyclic writes - admin - 21.07.2025

read_swap works for both reading and writing.