I am reading data from an AHRS / IMU sensor via USB with Python 2.7. To obtain the acceleration the manufacturer specifies according to the image below:
supplier's description IMU
My code in python is this, but when the acceleration is negative the values are wrong. I believe I need to check the first bit of the MSB (In this case, the AxH field), if 1 is negative, if 0 is positive.
#....
#data = serial.read(size=11)
#....
#
#Acceleration
elif data[1] == b'\x51':
AxL=int(data[2:3].encode('hex'), 16)
AxH=int(data[3:4].encode('hex'), 16)
AyL=int(data[4:5].encode('hex'), 16)
AyH=int(data[5:6].encode('hex'), 16)
AzL=int(data[6:7].encode('hex'), 16)
AzH=int(data[7:8].encode('hex'), 16)
x = (AxH<<8|AxL)/32768.0*16.0
y = (AyH<<8|AyL)/32768.0*16.0
z = (AzH<<8|AzL)/32768.0*16.0
Anyone have any suggestions?
The complete IMU sensor manual is this: http://wiki.wit-motion.com/english/lib/exe/fetch.php?media=module:wt901:docs:jy901usermanualv4.pdf