To read negative values of Modbus registers, one must subtract the number 65536 from the read value from the register

Below is an example of how this can be done:


1. We create a user variable to which the result of the action in the script will be passed


2. Then we will prepare the script:


if(ModBus->Reading_value->Value>=32768) then
ModBus->temp=(ModBus->Reading_value->Value-65536)/10
else
ModBus->temp=ModBus->Reading_value->Value/10
end



3. The script will be triggered by the OnChange event in the ModBus virtual object



4. After sending the configuration, a negative value should be returned to the user property: