Skip to content
Snippets Groups Projects
Commit af2451a7 authored by Andrea Milluzzo's avatar Andrea Milluzzo
Browse files

axel+gyro units adj

parent 2cd790c7
No related branches found
No related tags found
No related merge requests found
...@@ -105,35 +105,28 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen ...@@ -105,35 +105,28 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
} }
void getWhoami()
{
SPITransaction spi(spislave);
uint8_t whoami = spi.read(regMapXLG::WHO_AM_I);
TRACE("whoami: 0x%02X\n", whoami);
}
bool init() override bool init() override
{ {
//Set FSR //Set FSR
switch(axelFSR) switch(axelFSR) //DA RIGUARDARE I COEFFICIENTI: SU DS C'E' SENSITIVITY IN mg/LSB
{ {
case AxelFSR::FS_2: case AxelFSR::FS_2:
axelSensitivity = 0.061f; axelSensitivity = 0.598f;
break; break;
case AxelFSR::FS_4: case AxelFSR::FS_4:
axelSensitivity = 0.122f; axelSensitivity = 1.196f;
break; break;
case AxelFSR::FS_8: case AxelFSR::FS_8:
axelSensitivity = 0.244f; axelSensitivity = 2.393f;
break; break;
case AxelFSR::FS_16: case AxelFSR::FS_16:
axelSensitivity = 0.732f; axelSensitivity = 7.178f;
break; break;
default: default:
axelSensitivity = 0.061f; axelSensitivity = 0.598f;
break; break;
} }
switch (gyroFSR) switch (gyroFSR)
{ {
case GyroFSR::FS_245: case GyroFSR::FS_245:
...@@ -252,16 +245,16 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen ...@@ -252,16 +245,16 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
// TRACE("LSM9DS1 temp: %02X\n, temp"); // TRACE("LSM9DS1 temp: %02X\n, temp");
mLastAccel = mLastAccel =
Vec3(x_xl / axelSensitivity, Vec3(x_xl * axelSensitivity / 1000,
y_xl / axelSensitivity, y_xl * axelSensitivity / 1000,
z_xl / axelSensitivity); z_xl * axelSensitivity / 1000);
mLastGyro = mLastGyro =
Vec3(x_gy / gyroSensitivity, Vec3(x_gy * gyroSensitivity / 1000,
y_gy / gyroSensitivity, y_gy * gyroSensitivity / 1000,
z_gy / gyroSensitivity); z_gy * gyroSensitivity / 1000);
mLastTemp = tempZero + temp / tempSensistivity; //25°C + TEMP/S devo castare a float "temp"? mLastTemp = tempZero + (temp / tempSensistivity); //25°C + TEMP*S devo castare a float "temp"?
} }
else{ //if FIFO enabled: do not store temperature, it can be read using "temperatureUpdate()" function at low sampling frequency else{ //if FIFO enabled: do not store temperature, it can be read using "temperatureUpdate()" function at low sampling frequency
uint8_t buf[384]; uint8_t buf[384];
......
...@@ -76,20 +76,20 @@ int main(){ ...@@ -76,20 +76,20 @@ int main(){
while(!lsm9ds1.init()){} while(!lsm9ds1.init()){}
Thread::sleep(500); Thread::sleep(500);
long long first_tick = miosix::getTick(); printf("ax,ay,az,gx,gy,gz,t\n");
long long first_tick = getTick();
for(;;) for(;;)
{ {
long long tick = miosix::getTick(); long long last_tick = getTick();
lsm9ds1.onSimpleUpdate(); lsm9ds1.onSimpleUpdate();
adata = *(lsm9ds1.accelDataPtr()); adata = *(lsm9ds1.accelDataPtr());
gdata = *(lsm9ds1.gyroDataPtr()); gdata = *(lsm9ds1.gyroDataPtr());
tdata = *(lsm9ds1.tempDataPtr()); tdata = *(lsm9ds1.tempDataPtr());
TRACE("TIMESTAMP:%lld\taxel: %.3f,%.3f,%.3f\tgyro: %.3f,%.3f,%.3f\ttemp: %.3f\n", printf("%d;%.3f;%.3f;%.3f;%.3f;%.3f;%.3f;%.1f\n",
tick-first_tick, (last_tick - first_tick),
adata.getX(), adata.getY(), adata.getZ(), adata.getX(), adata.getY(), adata.getZ(),
gdata.getX(), gdata.getY(), gdata.getZ(), gdata.getX(), gdata.getY(), gdata.getZ(),
tdata); tdata);
Thread::sleep(500);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment