I’m trying to integrate some custom AC control software with Velbus.
I see that the current temperature is sent onto the bus for many nodes with a built in sensor, such as the VMBGP4-20. Typically this will be by sending a message of type 0xE6 “COMMAND_SENSOR_TEMPERATURE”
The module protocol shows Databytes 2 and 3 transmitting the current temperature in two’s complement format.
[This is effectively the whole number of the current temp (in degrees C) is divided by the resolution (0.0625 degrees).]
There is a table showing the two bytes for various sample temps. There are a couple of typos which I found using the calculator at Two's (2s) Complement Calculator to understand how this works.
-
Let’s start with the positive values. The values for 0.5, 0.25, 0.125 and 0,0625 are just the binary format of the multiples of the resolution i.e. 8, 4, 2, and 1 - being shifted 5 bits to the left. They are not two’s complement and require not complex maths.
-
The next value is the one shown for 63.5 - this is 1016 times the resolution. The binary version of this is 0b0011 1111 1000 , shift this 5 bits to the left gives 0111 1111 0000 0000 which is not what is in the table.
Taking the value in the table “0111 1111 111x xxxx” and shifting 5 bits to the right gives 0b0011 1111 1111 which is decimal 1023. 1023 x 0.0625 = 63.9375 degrees - close but just enough to be misleading. -
The negative values are the twos complement of the multiple with the sign removed.
So for -0.0625 this is -1, which becomes 1 and the two complement is 111 1111 1111. Shift this 5 bits to the left and the values line up with the table.
The same sort of thing works for -0.125 (-2 times resolution), -0.25 (-4 times resolution).
The value shown for -0.5 appears to be wrong. This is actually -8 times the resolution. The twos comp calculator shows 111 1111 1000 for 8. Shift this 5 bits to the left gives 0b 1111 1111 0000 0000.
The value shown in the table is “1111 1110 000x xxxx” (flip the bits and shift it right and and one) it becomes 0b0001 0000 which is actually 16 times the resolution, or -1.0 degrees.
For -55 (which is 880) the calculator shows 1001 0010 000. Shift this 5 bits to the left for 0b1001 0010 000x xxxx which is correct.
I think the negative values could go as high as the positive with a transmitted value of “1000 0000 000x xxxx” which can be translated back to -1023 (x 0.0625) that gives -69.9375 degrees.
Whether this would be of practical use apart from Arctic conditions is a moot point though
Anyway I hope this helps people get their heads around how these temperature readings work (along with the small corrections required).