You are not logged in.
Pages: 1
Topic closed
Hi,
I am using a 1 wire DS18B20 temperature sensor on a 3rd party device, I then send the temperature reading over Modbus to my unipi.
Question, how do I convert the value which I receive over Modbus to a decimal number to display the actual temperature? Please see the attached.
(16 bit register - Modbus)
Thanks,
Hendrik
Offline
What temperature are you measuring?
This might be the solution :
If the value should be somewhere around 19°C then I think you should divide by 256 (= 8 bit shift to the right) and then divide by 10 to get 19,3°C.
49408 --> 1100000100000000
divide by 256
193 --> 11000001
divide by 10
19,3°C
...I'm just guessing
(edit : maybe it's a big vs little endian thing and you need to swap both bytes and then divide by 10 to get your value....in this case it will be 19,3°C as well. ...)
Last edited by scoobsalamander (2017-05-07 22:02:04)
Offline
Hi,
I am measuring temperatures inside control panels and rooms, the temperature range will be 0 - 50degC
The idea is to display the temperature values on my custom Rex HMI and also use the values (Hi/Lo temp) to perform certain actions
Offline
If my assumption was ok then you could try something like this : EXAMPLE
Offline
@hendrik: Please clarify how the value 49408 is obtained and what value it represents (at least approximately). What 3rd party device are you using?
@scoobsalamander: Excellent work. One could also solve that using standard function blocks. Let's wait for additional input from hendrik.
Jaroslav
Monarco HAT for Raspberry Pi - Lightweight I/O for monitoring, archiving and control.
Raspberry Pi in industrial automation!
Offline
One of the devices I am using is a PLC2011 B1 alarm module. I am connecting a DS18B20 temperature sensor (OWS) to the PLC2011B1
See attached.
Thanks.
Offline
According to the PLC2011 B1 manual, page 111, you should divide the value in the Modbus register by 16 to obtain the value in degrees Celsius.
The value 49408 is 1100000100000000 in binary form which is not a valid value for the DS18B20 sensor. See table 1 in the DS18B20 datasheet. Therefore you need to swap HIGH and LOW bytes of the Modbus register. You can do so in the Modbus driver configuration. Just tick the "Swap bytes" option. Remember to tick also the "Signed" option because DS18B20 uses signed 16-bit numbers.
Afterwards you get the value 193 (0000000011000001 in binary form), which gives you the temperature of 193/16=12.0625 deg Celsius.
Hope I'm right, it's tough without the device to validate my thoughts...
Jaroslav
Monarco HAT for Raspberry Pi - Lightweight I/O for monitoring, archiving and control.
Raspberry Pi in industrial automation!
Offline
Pages: 1
Topic closed