Skip to main content
mengsophia
Associate II
Jun 19, 2012 2:50 PM UTC
Question

lsm330dl output read problem

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
    This topic has been closed for replies.

    24 replies

    mengsophia
    Associate II
    Jun 21, 2012 4:37 AM UTC
    Posted on June 21, 2012 at 06:37

    i change the code as u say, but sometimes i still got this  GYRO_XH[ffffffff].  confusing..

    now when i put the board stastic on the table, the output value are between ±1 degree .

    GYRO_X_D1[0.00] GYRO_X_D[0.04]

    GYRO_XH[0]

    GYRO_XL[4]

    GYRO_X2[4]

    GYRO_X_D1[0.04] GYRO_X_D[0.15]

    GYRO_XH[0]

    GYRO_XL[5]

    GYRO_X2[5]

    GYRO_X_D1[0.15] GYRO_X_D[0.33]

    GYRO_XH[0]

    GYRO_XL[3]

    GYRO_X2[3]

    GYRO_X_D1[0.33] GYRO_X_D[0.48]

    GYRO_XH[0]

    GYRO_XL[0]

    GYRO_X2[0]

    GYRO_X_D1[0.48] GYRO_X_D[0.54]

    GYRO_XH[0]

    GYRO_XL[2]

    GYRO_X2[2]

    GYRO_X_D1[0.54] GYRO_X_D[0.58]

    GYRO_XH[ffffffff]

    GYRO_XL[ff]

    GYRO_X2[-1]

    GYRO_X_D1[0.58] GYRO_X_D[0.60]

    GYRO_XH[ffffffff]

    GYRO_XL[fb]

    GYRO_X2[-5]

    GYRO_X_D1[-0.04] GYRO_X_D[-0.14]

    GYRO_XH[0]

    GYRO_XL[4]

    GYRO_X[4]

    GYRO_X2[4]

    GYRO_X_D1[-0.14] GYRO_X_D[-0.16]

    GYRO_XH[0]

    GYRO_XL[1]

    GYRO_X2[1]

    GYRO_X_D1[-0.16] GYRO_X_D[-0.06]

     

    is it normal? or i need to care the  zero tolerance?

    when i turn it 90 degrees, it still shows like  arround -7,  and ,when i turn it back, the degree doesn't follow to change back, but i observe the angular rate seems change correctly.

    GYRO_XH[ffffffff]

    GYRO_XL[fa]

    GYRO_X[fffffffa]

    GYRO_X2[-6]

    GYRO_X_D[-0.31]

    GYRO_XH[0]

    GYRO_XL[b]

    GYRO_X2[11]

    GYRO_X_D[-0.21]

    GYRO_XH[fffffffc]

    GYRO_XL[b8]

    GYRO_X[fffffcb8]

    GYRO_X2[-840]

     GYRO_X_D[-16.19]

    GYRO_XH[0]

    GYRO_XL[3c]

    GYRO_X[3c]

    GYRO_X2[60]

    GYRO_X_D[-31.22]

    GYRO_XH[ffffffff]

    GYRO_XL[fc]

    GYRO_X[fffffffc]

    GYRO_X2[-4]

    GYRO_X_D[-30.14]

    GYRO_XH[0]

    GYRO_XL[6]

    GYRO_X[6]

    GYRO_X2[6]

    GYRO_X_D[-30.10] i think my integration part is correct, there is something wrong with data read frequency? 

    or my define value for registers?  

    frankmeyer9
    Associate III
    Jun 21, 2012 6:33 AM UTC
    Posted on June 21, 2012 at 08:33

    At the first glance, the data seem plausible.

    You should keep in mind that this MEMS are mechanical systems with analog/digital interface electronics, you will always have some noise and some bias. In comparision to full scale, this values seem normal. Having the interface to this sensor finished is the first step. I would definitely implement a zero point calibration, and observe the drift behavior. If you read the accelerometer data (coming back to this topic), you should read a value that evaluates to 1g for an axis aligned downwards. That value should turn negative (i.e. factor -1) if flipping over. To use the gyro data for integration, you will certainly need a constant sampling rate, i.e. read your sensor at regulat intervalls. A suggestion: To make up a short int from two byte, you can use a union. Something like:

    union {
    uint8_t bytes[2];
    int16_t sensorvalue;
    };

    Just write the high/low byte from the gyro in the correct order in (observe endianess), and read out the value - no need to do any conversion.
    mengsophia
    Associate II
    Jun 21, 2012 10:21 AM UTC
    Posted on June 21, 2012 at 12:21

    is theconstant sampling rate same as output data rate?cause i didn't see sampling rate in the PDF.

    About the zero calibration, are u talking about the typical zero-rate level? cause i choose 2000dps, so is it no need to care about it?

    another question.how toread sensor at regulat intervalls?

    i'm the first time dealling with gyro. so a lot of puzzles.

    i attached the PDF

    ________________

    Attachments :

    ST_lsm330dl_.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtVP&d=%2Fa%2F0X0000000aQy%2F6PYiIZ9cW12mslWJhw2Vnmv1CJc8NF4wc2.2MJPHL8Y&asPdf=false
    frankmeyer9
    Associate III
    Jun 21, 2012 11:30 AM UTC
    Posted on June 21, 2012 at 13:30

    And I'm dealing the first time with this LSM330 device.

    But it is similiar to other gyro/accelerometer, and even more similiar to other ST MEMS.

    As I recall, you have to configure a device-internal sampling rate anyway. In the datasheet, it is mentioned as Data Rate. You can use the interrupt capability of the device, i.e. connect the interrupt outputs to a GPIO, configure an interrupt-on-change, and thus read data when new are available.

    About the zero calibration, are u talking about the typical zero-rate level? cause i choose ..

     

    Just put the device on the table and don't move, while measuring.

    You will see a non-zero output for all axes, that changes with temperature.

    If you can live with that, it's ok - it depends on your application.

    If the application is an IMU, this is usually done when installed in the vehicle.

    For something like a mobile phone, it is probably irrelevant...

    mengsophia
    Associate II
    Jun 22, 2012 12:31 AM UTC
    Posted on June 22, 2012 at 02:31

    hi , may i have ur email address whoever is farmiar with gyro, i got some more questions about it .

    now i'm doing a project which needs to write a gyro software that provides degree readout .this will be used on the robot to keep it balance.

    now i really get stuck. cann't find any source code about it.

    mengsophia
    Associate II
    Jun 22, 2012 8:15 AM UTC
    Posted on June 22, 2012 at 10:15

    Now i think my GYRO_XH value which get from gyro is too small , are there something wrong with my setting? which output rate should i use ?

    frankmeyer9
    Associate III
    Jun 22, 2012 10:10 AM UTC
    Posted on June 22, 2012 at 12:10

    If you code from the first post is still valid in this case :

    #define GYRO_VALUE_CTRL_REG4    0xA0       //DISCONTINUES UPDATE#F0, LITTLE ENDIAN. 2000 DPS, 4-WIRE

    This might be a little much. Try the smallest value of 250dps.

    which output rate should i use ?

     

    This is not the output rate, but the full scale value, i.e. the value your GYRO_<n> values are scaled to. 2000 means, the SHORT_MAX value (32767) equals a rate of 2000 degree per second. That would mean, in this range you can measure rotation rates of up to 5.5 turns per second.

    Since I don't know the application, I can't comment on that.

    For balancing a robot, this seems quite a lot.

    frankmeyer9
    Associate III
    Jun 22, 2012 10:52 AM UTC
    Posted on June 22, 2012 at 12:52

    ...may i have ur email address whoever is farmiar...

    I would hesitate to reveal my mail address here publicly, there are some trolls around.

    now i'm doing a project which needs to write a gyro software that provides degree readout .this will be used on the robot to keep it balance.

     

     

    Sound like a project in the educational field, like an university.

    There are several papers and examples around, just include the search words IMU and kalman filter. That examples will probably not include code for the LSM330. That sensor seems relatively new, and more targeted to the mobile phone/device market. And it would be too simple, then ...

    mengsophia
    Associate II
    Jun 22, 2012 11:04 AM UTC
    Posted on June 22, 2012 at 13:04

    i changed to 250dps and printf some part of data when i slowly turn 90 degrees ,and then i turn it back to 90 degrees. it only shows me aroud 4 degrees, the sign also don't follow

    it seems that the output data from gyro is too small,

    i find that when i slowly turn the board, the degree sometimes don't change, or change very few. no matter how much i turn.

    and when the output is being added to a degree, it's hard to change back

    frankmeyer9
    Associate III
    Jun 22, 2012 11:59 AM UTC
    Posted on June 22, 2012 at 13:59

    The output should become bigger if you turn faster.

    i find that when i slowly turn the board, the degree sometimes don't change, or change very few. no matter how much i turn.

     

    There are some enable registers and bits to set.

    Did you check this, maybe the gyro is still disabled ?

    For 250dps, you should get about 20.000, if you turn it over in 1 second.

    ...it only shows me aroud 4 degrees, the sign also don't follow...

    That looks more like noise, not senseful data.