L3GD20 Class
- ID: l3gd20
- Name: Tri-axis Digital Gyroscope
- Category: gyroscope
- Manufacturer: stmicro
- Connection: iio i2c
- Link: http://www.st.com/en/mems-and-sensors/l3gd20.html
The L3GD20 The L3GD20 is a low-power three-axis angular rate sensor. This driver supports IIO and I2C modes. Some methods will only work in one mode or the other. See the documentation on the methods to determine whether a given method is operation in a given mode. Both the I2C and IIO mechanisms make use of the calibration and denoise algorithms.
For I2C mode, not all capabilities of the device are supported, but a complete register map and low level read/write methods are provided to add any missing functionality.
Example using IIO Example using I2C
Item Index
Methods
- L3GD20
- L3GD20
- getChipID
- getGyroscope
- setPowerMode
- setRange
- update
- getTemperature
- setODR
- enableBDU
- getStatusBits
- installISR
- getChannelValue
- enableBuffer
- disableBuffer
- setScale
- setSamplingFrequency
- enable3AxisChannel
- extract3Axis
- initCalibrate
- getCalibratedStatus
- getCalibratedData
- loadCalibratedData
- readReg
- readRegs
- writeReg
- gyroCollect
- gyroDenoiseMedian
- median
- partition
- clampGyroReadingsToZero
Properties
- REG_WHO_AM_I
- REG_CTRL_REG1
- REG_CTRL_REG2
- REG_CTRL_REG3
- REG_CTRL_REG4
- REG_CTRL_REG5
- REG_REFERENCE
- REG_OUT_TEMPERATURE
- REG_STATUS_REG
- REG_OUT_X_L
- REG_OUT_X_H
- REG_OUT_Y_L
- REG_OUT_Y_H
- REG_OUT_Z_L
- REG_OUT_Z_H
- REG_FIFO_CTRL_REG
- REG_FIFO_SRC_REG
- REG_INT1_CFG
- REG_INT1_SRC
- REG_INT1_TSH_XH
- REG_INT1_TSH_XL
- REG_INT1_TSH_YH
- REG_INT1_TSH_YL
- REG_INT1_TSH_ZH
- REG_INT1_TSH_ZL
- REG_INT1_DURATION
- CTRL_REG1_YEN
- CTRL_REG1_XEN
- CTRL_REG1_ZEN
- CTRL_REG1_PD
- CTRL_REG1_BW0
- CTRL_REG1_BW1
- _CTRL_REG1_BW_MASK
- _CTRL_REG1_BW_SHIFT
- CTRL_REG1_DR0
- CTRL_REG1_DR1
- _CTRL_REG1_DR_MASK
- _CTRL_REG1_DR_SHIFT
- _CTRL_REG1_ODR_CUTOFF0
- _CTRL_REG1_ODR_CUTOFF1
- _CTRL_REG1_ODR_CUTOFF2
- _CTRL_REG1_ODR_CUTOFF3
- _CTRL_REG1_ODR_CUTOFF_MASK
- _CTRL_REG1_ODR_CUTOFF_SHIFT
- ODR_CUTOFF_95_12_5
- ODR_CUTOFF_95_25
- ODR_CUTOFF_190_12_5
- ODR_CUTOFF_190_25
- ODR_CUTOFF_190_50
- ODR_CUTOFF_190_70
- ODR_CUTOFF_380_20
- ODR_CUTOFF_380_25
- ODR_CUTOFF_380_50
- ODR_CUTOFF_380_100
- ODR_CUTOFF_760_30
- ODR_CUTOFF_760_35
- ODR_CUTOFF_760_50
- ODR_CUTOFF_760_100
- POWER_DOWN
- POWER_SLEEP
- POWER_NORMAL
- _CTRL_REG2_RESERVED_BITS
- CTRL_REG2_HPCF0
- CTRL_REG2_HPCF1
- CTRL_REG2_HPCF2
- CTRL_REG2_HPCF3
- _CTRL_REG2_HPCF_MASK
- _CTRL_REG2_HPCF_SHIFT
- CTRL_REG2_HPM0
- CTRL_REG2_HPM1
- _CTRL_REG2_HPM_MASK
- _CTRL_REG2_HPM_SHIFT
- HPCF_7_2
- HPCF_3_5
- HPCF_1_8
- HPCF_0_9
- HPCF_0_45
- HPCF_0_18
- HPCF_0_09
- HPCF_0_045
- HPCF_0_018
- HPCF_0_009
- HPM_NORMAL_RESET_FILTER
- HPM_REFERENCE_SIGNAL
- HPM_NORMAL
- HPM_AUTORESET_ON_INT
- CTRL_REG3_I2_EMPTY
- CTRL_REG3_I2_ORUN
- CTRL_REG3_I2_WTM
- CTRL_REG3_I2_DRDY
- CTRL_REG3_PP_OD
- CTRL_REG3_H_LACTIVE
- CTRL_REG3_I1_BOOT
- CTRL_REG3_I1_INT1
- _CTRL_REG4_RESERVED_BITS
- CTRL_REG4_SIM
- CTRL_REG4_FS0
- CTRL_REG4_FS1
- _CTRL_REG4_FS_MASK
- _CTRL_REG4_FS_SHIFT
- CTRL_REG4_BLE
- CTRL_REG4_BDU
- FS_250
- FS_500
- FS_2000
- _CTRL_REG5_RESERVED_BITS
- CTRL_REG5_OUT_SEL0
- CTRL_REG5_OUT_SEL1
- _CTRL_REG5_OUT_SEL_MASK
- _CTRL_REG5_OUT_SEL_SHIFT
- CTRL_REG5_INT1_SEL0
- CTRL_REG5_INT1_SEL1
- _CTRL_REG5_INT1_SEL_MASK
- _CTRL_REG5_INT1_SEL_SHIFT
- CTRL_REG5_HPEN
- CTRL_REG5_FIFO_EN
- CTRL_REG5_BOOT
- STATUS_REG_XDA
- STATUS_REG_YDA
- STATUS_REG_ZDA
- STATUS_REG_ZYXDA
- STATUS_REG_XOR
- STATUS_REG_YOR
- STATUS_REG_ZOR
- STATUS_REG_ZYXOR
- FIFO_CTRL_REG_WTM0
- FIFO_CTRL_REG_WTM1
- FIFO_CTRL_REG_WTM2
- FIFO_CTRL_REG_WTM3
- FIFO_CTRL_REG_WTM4
- _FIFO_CTRL_REG_WTM_MASK
- _FIFO_CTRL_REG_WTM_SHIFT
- FIFO_CTRL_REG_FM0
- FIFO_CTRL_REG_FM1
- FIFO_CTRL_REG_FM2
- _FIFO_CTRL_REG_FM_MASK
- _FIFO_CTRL_REG_FM_SHIFT
- FIFO_MODE_BYPASS
- FIFO_MODE_FIFO
- FIFO_MODE_STREAM
- FIFO_MODE_STREAM_TO_FIFO
- FIFO_MODE_BYPASS_TO_STREAM
- FIFO_SRC_REG_FSS0
- FIFO_SRC_REG_FSS1
- FIFO_SRC_REG_FSS2
- FIFO_SRC_REG_FSS3
- FIFO_SRC_REG_FSS4
- _FIFO_SRC_REG_FSS_MASK
- _FIFO_SRC_REG_FSS_SHIFT
- FIFO_SRC_REG_EMPTY
- FIFO_SRC_REG_OVRN
- FIFO_SRC_REG_WTM
- INT1_CFG_XLIE
- INT1_CFG_XHIE
- INT1_CFG_YLIE
- INT1_CFG_YHIE
- INT1_CFG_ZLIE
- INT1_CFG_ZHIE
- INT1_CFG_LIR
- INT1_CFG_AND_OR
- _INT1_SRC_RESERVED_BITS
- INT1_SRC_XL
- INT1_SRC_XH
- INT1_SRC_YL
- INT1_SRC_YH
- INT1_SRC_ZL
- INT1_SRC_ZH
- INT1_SRC_IA
- INT1_DURATION_D0
- INT1_DURATION_D1
- INT1_DURATION_D2
- INT1_DURATION_D3
- INT1_DURATION_D4
- INT1_DURATION_D5
- INT1_DURATION_D6
- INT1_DURATION_WAIT
Methods
L3GD20
-
device
L3GD20 Tri-axis Digital Gyroscope Contructor for IIO operation
Parameters:
-
device
Numberiio device number
Returns:
L3GD20
-
bus
-
addr
L3GD20 Tri-axis Digital Gyroscope Contructor for I2C operation
Parameters:
-
bus
Numberi2c bus
-
addr
NumberI2C address
Returns:
getChipID
()
Number
Return the chip ID. I2C only.
Returns:
The chip ID (L3GD20_DEFAULT_CHIP_ID).
getGyroscope
-
x
-
y
-
z
Return gyroscope data in radians per second. update() must have been called prior to calling this method. I2C only.
Parameters:
-
x
Float *Pointer to a floating point value that will have the current x component placed into it.
-
y
Float *Pointer to a floating point value that will have the current y component placed into it.
-
z
Float *Pointer to a floating point value that will have the current z component placed into it.
setPowerMode
-
mode
Set the power mode of the device. I2C only.
Parameters:
-
mode
POWER_MODES_TOne of the POWER_MODES_T values.
setRange
-
range
Set the gyroscope detection scaling range. This device supports 250, 500 and 2000 degree/s ranges. I2C only.
Parameters:
-
range
FS_TOne of the FS_T values.
update
()
Update the internal stored values from sensor data. This method must be called before querying any data ( getTemperature() and getGyroscope() ). I2C only.
getTemperature
-
fahrenheit
Return the current measured temperature. Note, this is not ambient temperature. update() must have been called prior to calling this method. I2C only.
Parameters:
-
fahrenheit
Booleantrue to return data in Fahrenheit, false for Celicus. Celsius is the default.
Returns:
The temperature in degrees Celsius or Fahrenheit.
setODR
-
odr
Set the output data rate and cut off frequency of the device. I2C only.
Parameters:
-
odr
ODR_CUTOFF_TOne of the ODR_CUTOFF_T values.
enableBDU
-
enable
Enable or disable Block Data Update. When enabled, this ensures that LSB's or MSB's of a given axis are not being updated while the other is being read. This is enabled by default. I2C only.
Parameters:
-
enable
Booleantrue to enable, false to disable
getStatusBits
()
Number
Return the bitfields of the Status register. This register provides information on the status of data gathering. I2C only.
Returns:
The contents of the REG_STATUS_REG register.
installISR
-
isr
-
arg
Installs an interrupt service routine (ISR) to be called when an interrupt occurs. IIO only.
Parameters:
-
isr
Void()(char *, void *)Pointer to a function to be called on interrupt
-
arg
Void *Pointer to an object to be supplied as an argument to the ISR.
getChannelValue
-
input
-
chan
Extract the channel value based on channel type. IIO only.
Parameters:
-
input
StringChannel data
-
chan
Mraa_iio_channel *MRAA iio-layer channel info
Returns:
enableBuffer
-
length
Enable trigger buffer. IIO only.
Parameters:
-
length
Numberbuffer length in integer
Returns:
disableBuffer
()
Boolean
Disable trigger buffer. IIO only.
Returns:
setScale
-
scale
Set scale. IIO only. For I2C operation, use setRange() with the appropriate FS_T value.
Parameters:
-
scale
Numberin float Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps) Default scale is 0.000153
Returns:
setSamplingFrequency
-
sampling_frequency
Set sampling frequency. IIO only. For I2C operation, use the setODR() method with the appropriate ODR_CUTOFF_T value.
Parameters:
-
sampling_frequency
Numbersampling frequency in float Available sampling frequency are 95, 190, 380, and 760 Default sampling frequency is 95
Returns:
enable3AxisChannel
()
Boolean
Enable 3 axis scan element. IIO only.
Returns:
extract3Axis
-
data
-
x
-
y
-
z
Process enabled channel buffer and return x, y, z axis. IIO only.
Parameters:
-
data
StringEnabled channel data, 6 bytes, each axis 2 bytes
-
x
Float *X-Axis
-
y
Float *Y-Axis
-
z
Float *Z-Axis
Returns:
initCalibrate
()
Reset calibration data and start collect calibration data again
getCalibratedStatus
()
Boolean
Get calibrated status, return true if calibrate successfully
Returns:
getCalibratedData
-
bias_x
-
bias_y
-
bias_z
Get calibrated data
Parameters:
-
bias_x
Float *undefined
-
bias_y
Float *undefined
-
bias_z
Float *undefined
loadCalibratedData
-
bias_x
-
bias_y
-
bias_z
Load calibrated data
Parameters:
-
bias_x
Numberundefined
-
bias_y
Numberundefined
-
bias_z
Numberundefined
readReg
-
reg
Read a register. I2C mode only.
Parameters:
-
reg
NumberThe register to read.
Returns:
The value of the register.
readRegs
-
reg
-
buffer
-
len
Read contiguous registers into a buffer. I2C mode only.
Parameters:
-
reg
Numberundefined
-
buffer
Uint8_t *The buffer to store the results.
-
len
NumberThe number of registers to read.
Returns:
The number of bytes read.
writeReg
-
reg
-
val
Write to a register. I2C mode only.
Parameters:
-
reg
NumberThe register to write to.
-
val
NumberThe value to write.
gyroCollect
-
x
-
y
-
z
Calibrate gyro
Parameters:
-
x
NumberX-Axis
-
y
NumberY-Axis
-
z
NumberZ-Axis
Returns:
gyroDenoiseMedian
-
x
-
y
-
z
Denoise gyro
Parameters:
-
x
Float *X-Axis
-
y
Float *Y-Axis
-
z
Float *Z-Axis
median
-
queue
-
size
median algorithm
Parameters:
-
queue
Float * -
size
Number
Returns:
partition
-
list
-
left
-
right
-
pivot_index
partition algorithm
Parameters:
-
list
Float * -
left
Number -
right
Number -
pivot_index
Number
Returns:
clampGyroReadingsToZero
-
x
-
y
-
z
Clamp Gyro Readings to Zero
Parameters:
-
x
Float *X-Axis
-
y
Float *Y-Axis
-
z
Float *Z-Axis