cancel
Showing results for 
Search instead for 
Did you mean: 

lsm330dl output read problem

mengsophia
Associate II
Posted on June 19, 2012 at 16:50

hi, everyone. i don't understand why the output data XH,XL. is unchange all the time , when i  read the status_reg, i find that there is no new data coming ..and sometimes the same code gave me different output ,like the data is keep changing but totally wrong, even my board is stastic on the table, but the output gives me thousands of degrees bias. i really confusing., any one can help me ?

here is a part of my output

part1:

GYRO_XH  [1]

GYRO_XL: [5]

GYRO_XH  [fffffff5]

GYRO_XL: [c7]

GYRO_XH  [ffffff80]

GYRO_XL: [0]

GYRO_XH  [ffffffff]

GYRO_XL: [f3]

GYRO_XH  [fffffffd]

GYRO_XL: [ef]

GYRO_XH  [ffffffe8]

GYRO_XL: [74]

GYRO_XH  [ffffffff]

GYRO_XL: [ba]

part2:

GYRO_XH: [ffffffff]

GYRO_XL: [e6]

GYRO_X: [ffffffe6]

GYRO_X2: [-26] //2's complement always -26

GYRO_XH: [ffffffff]

GYRO_XL: [e6]

GYRO_X: [ffffffe6]

GYRO_X2: [-26]

very urgent ,many thanks for any help,

#gyro-lsm330dl
24 REPLIES 24
frankmeyer9
Associate II
Posted on June 19, 2012 at 21:17

You might either misunderstand the sensor, or he is not actually on.

Did you check the bus ?

By the way, you could have told if you use SPI or I2C.

If you receive data correctly, this could mean the sensor is not in the state you suppose, or you interpret the data in an incorrect way.

 

GYRO_XH  [fffffff5]

 

GYRO_XH  [ffffff80]

 

GYRO_XH  [ffffffff]

 

...

This looks like small negative numbers.

Did you initialize the sensor properly ?

Maybe the gyros are still off, or uninitialized.

very urgent ,...

Don't want to offend you, but this is rarely helpful.

People here are volunteering, and won't take the pressure.

But it might be helpful if you post some of the ''problematic'' code.

Posted on June 19, 2012 at 21:23

It was attached.

The 2's complementing code doesn't make any sense to me, and I would probably cast the floating point conversion differently.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mengsophia
Associate II
Posted on June 20, 2012 at 03:06

thanks for ur suggestion.

i did attached my code. i use spi bus, from now on , the read and write  through spi seems correct.  but still can't get valid value from gyro inside.

by the way , i didn't use any interrupt.  so i don't understand why my senser is not activated. is there something wrong with my configuration? or my define value for the registers are wrong?

mengsophia
Associate II
Posted on June 20, 2012 at 03:14

er, i'm a bit don't understand.so u think my output value unchange has some relationship with the floating point convertion? er ,may i know how u do it? 

frankmeyer9
Associate II
Posted on June 20, 2012 at 09:44

It was attached.

 

Sorry, I didn't notice ..

The 2's complementing code doesn't make any sense to me,

Neither to me.

You just need to put the two byte together properly (i.e. the correct byte order), then you have already a signed short int.

mengsophia
Associate II
Posted on June 20, 2012 at 12:29

but now the problem is that i can't get valid output data from the gyro. no matter how i turn it , it value is still unchange. how come the same value is overwriten all the time? 

frankmeyer9
Associate II
Posted on June 20, 2012 at 13:24

And what about the accelerometer data ?

They are easier to check for correctness, they are supposedly static. Just turn over by 180 deg. in any direction, and one value should change sign (pos.->neg. or vice versa).

Gyro data are the rotation rate, which is harder to check for sanity without proper test rig.

mengsophia
Associate II
Posted on June 20, 2012 at 16:16

thanks for suggestion. but i haven't done the accel part. i change to use another new board, now it can give me some valid data, so maybe it's the hardware problem.:( but the calculated degree seems  incorrectly, it's there some wrong with this part?

GYRO_Y = GYRO_YH<<8 | GYRO_YL;   

    if((GYRO_YH&0x80)==0x80)

     GYRO_Y =-1*  (~GYRO_Y+1);

    GYRO_Yfold = GYRO_Yf;

    GYRO_Yf = GYRO_Y*0.07 - GYRO_Ybias + GYRO_YbiasOffset;

GYRO_Y_Dold = GYRO_Y_D;

GYRO_X_D = (GYRO_Xf  + GYRO_Xfold)*0.5 * (GYRO_X_Time-GYRO_X_TimeOld)*0.00001 + GYRO_X_Dold;

the degree i got are very samll, even i turn 180 degree.it shows me like 20 degrees

frankmeyer9
Associate II
Posted on June 20, 2012 at 16:42

the degree i got are very samll, even i turn 180 degree.

 

If you turn it over, the ACCELEROMETER output will flip sign, whatever axis is up/down.

...it shows me like 20 degrees

 

You might have got this wrong.

A gyro does not give you degrees, it gives you degree per second, i.e. how fast you turn it.

This is not as easy to test manually, as it produces a significant output only while you turn it - therefore my suggestion to look for the accelerometer output.