Thank you for your answers.
davidcoton wrote:you will get a constant 1g magnitude Z acceleration (+ or -). The X and Y values will be varying sinusoidally, in quadrature, at the rotation frequency (0.25Hz). The accelerometer does not read rotational acceleration, but linear.
I agree with the +/- 1 g for the vertical Z axis, but why would the X and Y axis show sinusoidal values ?
On my attached drawing, the RPi is rotating with the platform, at the same angular speed, so why would X and Y accelerations would be changing as the rotation speed is constant ?
mwilliams03 wrote:What is this for?
Code: Select all
oriY[i] = (oriY[i] - gapZ) * 245.0 / (65536 / 2)
I use
gapX/
Y/
Z values to calibrate respectively the pitch/roll/yaw measured values : when the Sense HAT is still, I record 100 measures on each axis, sum them, and then divide them by 100 to have an average still value. Then I subtract these values to their respectively measured values (I think it's called "zeroing" ?

)
The
* 245.0 / (65536 / 2) is here to convert raw values recorded with I2C to real values, according to the datasheet with the given ranges (+/- 2 g for the accelerometer, +/- 245 dps for the gyroscope).
mwilliams03 wrote:To get dps from the gyro, you need to multiple the raw by the sensitivity level in mdps (milli).
The table in the datasheet shows for 2000dps it is 70 mdps.
So your math would be.
raw value x 0.07 = dps
With 0.00875 then, as I am using the +/- 245 dps range. I have to try this, thank you !
EDIT : I've just tried, and got as raw values, one line for example :
Code: Select all
accX | accY | accZ | rotX | rotY | rotZ
464 | 65148 | 49356 | 879 | 127 | 42
Which give, once converted (with * 0.000061 for the acceleration, and with * 0.00875 for the angular speed) and rounded :
Code: Select all
accX | accY | accZ | rotX | rotY | rotZ
0.03 | 3.97 | 3.01 | 7.69 | 1.11 | 0.37
About 4 and 3 g is quite a lot, and so is 7 dps..!
The Python 3 code that I used :
Code: Select all
import smbus
nbrOfRec = 1000
bus = smbus.SMBus(1)
# Turning on the gyroscope and the accelerometer.
bus.write_byte_data(0x6a, 0x22, 0x04)
bus.write_byte_data(0x6a, 0x20, 0xe0)
bus.write_byte_data(0x6a, 0x10, 0x0c3)
# Arrays for the 3 axis acceleration (X, Y, Z).
accX = []
accY = []
accZ = []
# Arrays for the 3 axis orientation (pitch, roll, yaw).
oriP = []
oriR = []
oriY = []
# Processing.
for i in range(0, nbrOfRec):
accX.append(bus.read_word_data (0x6a,0x28))
accY.append(bus.read_word_data (0x6a,0x2a))
accZ.append(bus.read_word_data (0x6a,0x2c))
oriP.append(bus.read_word_data (0x6a,0x18))
oriR.append(bus.read_word_data (0x6a,0x1a))
oriY.append(bus.read_word_data (0x6a,0x1c))
# Converting the values.
for i in range(0, nbrOfRec):
accX[i] = accX[i] * 0.000061
accY[i] = accY[i] * 0.000061
accZ[i] = accZ[i] * 0.000061
oriP[i] = oriP[i] * 0.00875
oriR[i] = oriR[i] * 0.00875
oriY[i] = oriY[i] * 0.00875
# Rounding the values.
for i in range(0, nbrOfRec):
accX[i] = round(accX[i], 1)
accY[i] = round(accY[i], 1)
accZ[i] = round(accZ[i], 1)
oriP[i] = round(oriP[i], 1)
oriR[i] = round(oriR[i], 1)
oriY[i] = round(oriY[i], 1)
# The name of the file where the values will be written.
fileName = "recordings.csv"
file = open(fileName, 'a')
file.write("accX;")
file.write("accY;")
file.write("accZ;")
file.write("oriP;")
file.write("oriR;")
file.write("oriY;\n")
for i in range(0, nbrOfRec):
file.write(str(accX[i]) + ';')
file.write(str(accY[i]) + ';')
file.write(str(accZ[i]) + ';')
file.write(str(oriP[i]) + ';')
file.write(str(oriR[i]) + ';')
file.write(str(oriY[i]) + ';\n')
file.close()
Is this a problem that my rotation axis is not the same axis as the Sense HAT's gyroscope ? I assume it is not as I am measuring an angular speed, but I'm not sure...
I'm sorry if some things are unclear, English is not my native language and I may have some issues describing my problem ; thanks for your help and patience !
Raspberry Pi 3 + RetroPie, Raspberry Pi 3 + Sense HAT or Framboisedorf, Raspberry Pi 2 + OpenELEC