Negative values in the Modbus registers

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->Rejestr_odczytu->RegisterValue>=32768) then





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: