0

I'm using python on my raspbian testing system. For communicating with a 10Channel devices (Temco P3-PT10) connected with PT100 temperature sensors im using minimalmodbus.

Therefor i want to read register 100~101 for the temperature of Channel 1: The description says: "When set INT, 100 will show 0 and 101 show the temperature for channel 1, 250= 25.0C when set flaot,100 and 101 show 25.0000C"

I started reading with:

temperaturef = instrument.read_float(r, 3, 2)
temperature = instrument.read_register(r, 0)

I got the output of:

Address 100 R: 62915 F: -4.95029165077e+32 // Address 101 R: 16684 F: 10.7924995422

The first column shows the register values the second column the float values comming back.

My question: - what ist stored as register values? Can i convert them to float? - and why is the first value of float negative?

Am i doeing something wrong?

thx for helping!

user3882511
  • 125
  • 1
  • 10

1 Answers1

1

For reading the Mod bus register you can follow this link

Yes you can covert hex value to float or viz. After reading the register using above method you will get register value.

For converting hex to signed float you can use:

import struct
var='0xbf99999a'
var = var.replace('x',' ')
var1 = var[2:len(var)]
print var1
a= struct.unpack('!f', var1.decode('hex'))[0]
print "%.3f"%round(a,3)
tanmayee
  • 15
  • 1