L3GD20H Gyro Sensor SPI reading error

I am L3GD20H gyro sensor with my mbed processor, the connection between these 2 are 4-wire SPI, with L3GD20H as SPI slave, the connection is:

Master SPI Slave SPI (L3GD20H)
MOSI SDI
MISO SDO
SCL SCL
CS CS

Of couse, i connect the VDD to 3.3V input, and GND to mbed processor common GND.

I just want to test the reading of WHO_AM_I register like:

while (1) { CS = 0; Read(0x0F); char whoamI = Read(0x00); CS = 1; }

the reading of register (WHO_AM_I) is always 0xFF, i can see bus activities on scope for SDI/SCL/CS, but not SDO (always 3.3V). Anything wrong here?

Thanks,

How, where, and to what value, do you set the device address?

HI, Jim, this is the SPI communication, my processor use one delicated chip select line to select the L3GD20H, when this CS (chip select) line is low, L3GD20H can be used as SPL slave. /Thanks

Hello.

It is unclear from your code if you are sending the SPI Read command correctly. According to the SPI read section of the L3GD20H datatsheet, you need to send a byte with the READ bit (bit 0) set high and the address of the register you are trying to read in bits 2-7. Is your Read() command performing this task? If you continue to have problems, you might try following this SPI example from mbed’s website.

- Jeremy

Just some update here: since I posted this question about using L3GD20H with SPI interface a few months ago, things are getting much better now. I can read the X,Y,Z angular rotation data without problem. The L3GD20H is pretty sensitive to detect tiny rotation is either direction of all direction (X,Y,Z).

The only thing right now for me is how to use/interpret this data. For example, I captured some output data from L3GD20H this morning (data is updated every 50 ms).

[quote]
X:+3951 Y:-966 Z:-71
X:+3951 Y:-966 Z:-71
X:+3951 Y:-966 Z:-71
X:+1942 Y:-1040 Z:-1492
X:+1942 Y:-1040 Z:-1492
X:+1942 Y:-1040 Z:-1492
X:+1093 Y:+596 Z:-366
X:+1093 Y:+596 Z:-366
X:+1093 Y:+596 Z:-366
X:+792 Y:+757 Z:+113
X:+792 Y:+757 Z:+113
X:+792 Y:+757 Z:+113
X:+792 Y:+757 Z:+113
X:+630 Y:-897 Z:+900[/quote]

My first question is what the unit of these X,Y,Z output? is dps (degree per second) or mdps? I tend to believe it’s in mdps from below driver code, also the L3GD20H is configured as ±245 for the Measurement Range, but someone please confirm.

if(_config.CTRL_REG4.B.FS==0x00) { val->x=8.75*(float)val->X; val->y=8.75*(float)val->Y; val->z=8.75*(float)val->Z; } else if(_config.CTRL_REG4.B.FS==0x01) { val->x=17.5*(float)val->X; val->y=17.5*(float)val->Y; val->z=17.5*(float)val->Z; } else if((_config.CTRL_REG4.B.FS==0x10)|(_config.CTRL_REG4.B.FS==0x11)) { val->x=70.0*(float)val->X; val->y=70.0*(float)val->Y; val->z=70.0*(float)val->Z; }

Hello.

The L3GD20H outputs gyroscope data in units of mdps. For the ±245 FS setting you are using, the So specification in the L3GD20H datasheet (page 10) states a conversion factor of 8.75 mdps/LSB (least significant bit). You would just multiply your raw result by that factor to get a rotation rate in units of mdps. For example, if you got a result of +345, your result in mdps would be 345 * 8.75 = 3020 mdps (3.02 dps).

-Jon