0

This must be an obvious and stupid question... I'm working on an Raspberry Pi 3 wired with an BerryIMU (9 ways of freedom). I'm getting the RAW values from the Accelerometer, but what the meaning of those values ?

(x, y)
(-57, 573)
(-56, 567)
(-64, 571)
(-59, 580)
(-56, 569)
(-30, 579)
(-59, 569)
(-61, 567)
(-34, 575)
(-59, 587)
(-43, 573)
(-74, 579)
(-56, 568)
(-58, 569)

If I had well understand, those are the acceleration in x and y. But what I'm not sure is what the unit ? m/s² ? (couldn't find on ozzmaker documentation...) Moreover, those values are taken while being stationary and I'm not sure of those values. I know that there is noise (I should use Kalman filter) that why the values aren't the same on each iteration. If those values are acceleration in m/s², I'm trying to calculate the velocity. Following is my current code :

import smbus
import time
import math
from LSM9DS0 import *
import datetime
bus = smbus.SMBus(1)

def writeACC(register,value):
    bus.write_byte_data(ACC_ADDRESS, register, value)
    return -1

def readACCx():
    acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_X_L_A)
    acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_X_H_A)
    acc_combined = (acc_l | acc_h <<8)

    return acc_combined  if acc_combined < 32768 else acc_combined - 65536

def readACCy():
    acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_Y_L_A)
    acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_Y_H_A)
    acc_combined = (acc_l | acc_h <<8)

    return acc_combined  if acc_combined < 32768 else acc_combined - 65536

def readACCz():
    acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_Z_L_A)
    acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_Z_H_A)
    acc_combined = (acc_l | acc_h <<8)

    return acc_combined  if acc_combined < 32768 else acc_combined - 65536

def millis():
    current_milli_time = int(round(time.time() * 1000))
    return current_milli_time



#initialise the accelerometer
writeACC(CTRL_REG1_XM, 0b01100111) #z,y,x axis enabled, continuos update,  100Hz data rate
writeACC(CTRL_REG2_XM, 0b00100000) #+/- 16G full scale

velocity = 0.0
prevAcc = 0
prevTime = millis()

while True:
    #Read the accelerometer,gyroscope and magnetometer values
    ACCx = readACCx()
    ACCy = readACCy()
    ACCz = readACCz()

    currTime = millis()

    velocity += (ACCx + prevAcc)  / 2 * (currTime - prevTime) / 1000

    prevAcc = ACCx
    prevTime = currTime

    print("Vx:", velocity)

    time.sleep(0.25)

The problem is, the velocity is increasing while the sensors is being stationary.

Thanks for your help.

David Pham
  • 151
  • 1
  • 1
  • 15
  • `velocity += (ACCx + prevAcc) / 2 * (currTime - prevTime) / 1000` This line will keep adding to `velocity`. Remember too that the accelerometer will always have a recorded force even when stationary of gravity. – Tom Myddeltyn May 19 '16 at 20:56
  • http://ozzmaker.com/berryimu/ seems to have a fair amount of info too. – Tom Myddeltyn May 19 '16 at 21:00
  • Are those values from accelerometer can be trust ? And yeah, I already read all of that, thanks ! – David Pham May 19 '16 at 21:05
  • Did you find this datasheet? http://ozzmaker.com/wp-content/uploads/2014/12/LSM9DS0.pdf – Tom Myddeltyn May 20 '16 at 13:42
  • Yes I did. It says "acceleration unit" so I guessed it is m/s² but I'm not 100% sure. My real problem is, I think, that I don't know if those values are ok values. – David Pham May 20 '16 at 15:33
  • If you rotate the device so that different axises are up the values should be relatively consistent between them. What you can do to is convert the values from Cartesian x,y,z to Spherical (https://en.wikipedia.org/wiki/Spherical_coordinate_system) magnitude, which should come out to be the same as the earth's gravitational constant. And should be consistent regardless of orientation of the accelerometer as long as the accelerometer is at rest. – Tom Myddeltyn May 20 '16 at 17:30
  • Thanks, I'm trying now ! – David Pham May 20 '16 at 17:34

0 Answers0