pyupm_l3gd20 module¶
-
class
pyupm_l3gd20.
L3GD20
(*args)[source]¶ Bases:
object
L3GD20 Tri-axis Digital Gyroscope API.
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 IIOExample using I2C
C++ includes: l3gd20.hpp
-
CTRL_REG1_BW0
= 16¶
-
CTRL_REG1_BW1
= 32¶
-
CTRL_REG1_DR0
= 64¶
-
CTRL_REG1_DR1
= 128¶
-
CTRL_REG1_PD
= 8¶
-
CTRL_REG1_XEN
= 2¶
-
CTRL_REG1_YEN
= 1¶
-
CTRL_REG1_ZEN
= 4¶
-
CTRL_REG2_HPCF0
= 1¶
-
CTRL_REG2_HPCF1
= 2¶
-
CTRL_REG2_HPCF2
= 4¶
-
CTRL_REG2_HPCF3
= 8¶
-
CTRL_REG2_HPM0
= 16¶
-
CTRL_REG2_HPM1
= 32¶
-
CTRL_REG3_H_LACTIVE
= 32¶
-
CTRL_REG3_I1_BOOT
= 64¶
-
CTRL_REG3_I1_INT1
= 128¶
-
CTRL_REG3_I2_DRDY
= 8¶
-
CTRL_REG3_I2_EMPTY
= 1¶
-
CTRL_REG3_I2_ORUN
= 2¶
-
CTRL_REG3_I2_WTM
= 4¶
-
CTRL_REG3_PP_OD
= 16¶
-
CTRL_REG4_BDU
= 128¶
-
CTRL_REG4_BLE
= 64¶
-
CTRL_REG4_FS0
= 16¶
-
CTRL_REG4_FS1
= 32¶
-
CTRL_REG4_SIM
= 1¶
-
CTRL_REG5_BOOT
= 128¶
-
CTRL_REG5_FIFO_EN
= 64¶
-
CTRL_REG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_CFG_XLIE
= 1¶
-
INT1_CFG_YHIE
= 8¶
-
INT1_CFG_YLIE
= 4¶
-
INT1_CFG_ZHIE
= 32¶
-
INT1_CFG_ZLIE
= 16¶
-
INT1_DURATION_D0
= 1¶
-
INT1_DURATION_D1
= 2¶
-
INT1_DURATION_D2
= 4¶
-
INT1_DURATION_D3
= 8¶
-
INT1_DURATION_D4
= 16¶
-
INT1_DURATION_D5
= 32¶
-
INT1_DURATION_D6
= 64¶
-
INT1_DURATION_WAIT
= 128¶
-
INT1_SRC_IA
= 64¶
-
INT1_SRC_XH
= 2¶
-
INT1_SRC_XL
= 1¶
-
INT1_SRC_YH
= 8¶
-
INT1_SRC_YL
= 4¶
-
INT1_SRC_ZH
= 32¶
-
INT1_SRC_ZL
= 16¶
-
ODR_CUTOFF_190_12_5
= 4¶
-
ODR_CUTOFF_190_25
= 5¶
-
ODR_CUTOFF_190_50
= 6¶
-
ODR_CUTOFF_190_70
= 7¶
-
ODR_CUTOFF_380_100
= 11¶
-
ODR_CUTOFF_380_20
= 8¶
-
ODR_CUTOFF_380_25
= 9¶
-
ODR_CUTOFF_380_50
= 10¶
-
ODR_CUTOFF_760_100
= 15¶
-
ODR_CUTOFF_760_30
= 12¶
-
ODR_CUTOFF_760_35
= 13¶
-
ODR_CUTOFF_760_50
= 14¶
-
ODR_CUTOFF_95_12_5
= 0¶
-
ODR_CUTOFF_95_25
= 1¶
-
POWER_DOWN
= 0¶
-
POWER_NORMAL
= 2¶
-
POWER_SLEEP
= 1¶
-
REG_CTRL_REG1
= 32¶
-
REG_CTRL_REG2
= 33¶
-
REG_CTRL_REG3
= 34¶
-
REG_CTRL_REG4
= 35¶
-
REG_CTRL_REG5
= 36¶
-
REG_FIFO_CTRL_REG
= 46¶
-
REG_FIFO_SRC_REG
= 47¶
-
REG_INT1_CFG
= 48¶
-
REG_INT1_DURATION
= 56¶
-
REG_INT1_SRC
= 49¶
-
REG_INT1_TSH_XH
= 50¶
-
REG_INT1_TSH_XL
= 51¶
-
REG_INT1_TSH_YH
= 52¶
-
REG_INT1_TSH_YL
= 53¶
-
REG_INT1_TSH_ZH
= 54¶
-
REG_INT1_TSH_ZL
= 55¶
-
REG_OUT_TEMPERATURE
= 38¶
-
REG_OUT_X_H
= 41¶
-
REG_OUT_X_L
= 40¶
-
REG_OUT_Y_H
= 43¶
-
REG_OUT_Y_L
= 42¶
-
REG_OUT_Z_H
= 45¶
-
REG_OUT_Z_L
= 44¶
-
REG_REFERENCE
= 37¶
-
REG_STATUS_REG
= 39¶
-
REG_WHO_AM_I
= 15¶
-
STATUS_REG_XDA
= 1¶
-
STATUS_REG_XOR
= 16¶
-
STATUS_REG_YDA
= 2¶
-
STATUS_REG_YOR
= 32¶
-
STATUS_REG_ZDA
= 4¶
-
STATUS_REG_ZOR
= 64¶
-
STATUS_REG_ZYXDA
= 8¶
-
STATUS_REG_ZYXOR
= 128¶
-
clampGyroReadingsToZero
(x, y, z)[source]¶ void clampGyroReadingsToZero(float *x, float *y, float *z)
Clamp Gyro Readings to Zero
x: X-Axis
y: Y-Axis
z: Z-Axis
-
enableBDU
(enable)[source]¶ void enableBDU(bool 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.
enable: true to enable, false to disable
-
enableBuffer
(length)[source]¶ bool enableBuffer(int length)
Enable trigger buffer. IIO only.
length: buffer length in integer
-
extract3Axis
(data, x, y, z)[source]¶ bool extract3Axis(char *data, float *x, float *y, float *z)
Process enabled channel buffer and return x, y, z axis. IIO only.
data: Enabled channel data, 6 bytes, each axis 2 bytes
x: X-Axis
y: Y-Axis
z: Z-Axis
-
getCalibratedData
(bias_x, bias_y, bias_z)[source]¶ void getCalibratedData(float *bias_x, float *bias_y, float *bias_z)
Get calibrated data
-
getCalibratedStatus
()[source]¶ bool getCalibratedStatus()
Get calibrated status, return true if calibrate successfully
-
getChannelValue
(input, chan)[source]¶ int64_t getChannelValue(unsigned char *input, mraa_iio_channel *chan)
Extract the channel value based on channel type. IIO only.
input: Channel data
chan: MRAA iio-layer channel info
-
getChipID
()[source]¶ uint8_t getChipID()
Return the chip ID. I2C only.
The chip ID (L3GD20_DEFAULT_CHIP_ID).
-
getGyroscope
(x, y, z)[source]¶ void getGyroscope(float *x, float *y, float *z)
Return gyroscope data in radians per second. update() must have been called prior to calling this method. I2C only.
x: Pointer to a floating point value that will have the current x component placed into it.
y: Pointer to a floating point value that will have the current y component placed into it.
z: Pointer to a floating point value that will have the current z component placed into it.
-
getStatusBits
()[source]¶ uint8_t getStatusBits()
Return the bitfields of the Status register. This register provides information on the status of data gathering. I2C only.
The contents of the REG_STATUS_REG register.
-
getTemperature
(fahrenheit=False)[source]¶ float getTemperature(bool fahrenheit=false)
Return the current measured temperature. Note, this is not ambient temperature. update() must have been called prior to calling this method. I2C only.
fahrenheit: true to return data in Fahrenheit, false for Celicus. Celsius is the default.
The temperature in degrees Celsius or Fahrenheit.
-
gyroCollect
(x, y, z)[source]¶ bool gyroCollect(float x, float y, float z)
Calibrate gyro
x: X-Axis
y: Y-Axis
z: Z-Axis
-
gyroDenoiseMedian
(x, y, z)[source]¶ void gyroDenoiseMedian(float *x, float *y, float *z)
Denoise gyro
x: X-Axis
y: Y-Axis
z: Z-Axis
-
initCalibrate
()[source]¶ void initCalibrate()
Reset calibration data and start collect calibration data again
-
installISR
(isr, arg)[source]¶ void installISR(void(*isr)(char *, void *), void *arg)
Installs an interrupt service routine (ISR) to be called when an interrupt occurs. IIO only.
isr: Pointer to a function to be called on interrupt
arg: Pointer to an object to be supplied as an argument to the ISR.
-
loadCalibratedData
(bias_x, bias_y, bias_z)[source]¶ void loadCalibratedData(float bias_x, float bias_y, float bias_z)
Load calibrated data
-
median
(queue, size)[source]¶ float median(float *queue, unsigned int size)
median algorithm
queue:
size:
-
partition
(list, left, right, pivot_index)[source]¶ unsigned int partition(float *list, unsigned int left, unsigned int right, unsigned int pivot_index)
partition algorithm
list:
left:
right:
pivot_index:
-
readReg
(reg)[source]¶ uint8_t readReg(uint8_t reg)
Read a register. I2C mode only.
reg: The register to read.
The value of the register.
-
readRegs
(reg, buffer, len)[source]¶ int readRegs(uint8_t reg, uint8_t *buffer, int len)
Read contiguous registers into a buffer. I2C mode only.
buffer: The buffer to store the results.
len: The number of registers to read.
The number of bytes read.
-
setODR
(odr)[source]¶ void setODR(ODR_CUTOFF_T odr)
Set the output data rate and cut off frequency of the device. I2C only.
odr: One of the ODR_CUTOFF_T values.
-
setPowerMode
(mode)[source]¶ void setPowerMode(POWER_MODES_T mode)
Set the power mode of the device. I2C only.
mode: One of the POWER_MODES_T values.
-
setRange
(range)[source]¶ void setRange(FS_T range)
Set the gyroscope detection scaling range. This device supports 250, 500 and 2000 degree/s ranges. I2C only.
range: One of the FS_T values.
-
setSamplingFrequency
(sampling_frequency)[source]¶ bool setSamplingFrequency(const float sampling_frequency)
Set sampling frequency. IIO only. For I2C operation, use the setODR() method with the appropriate ODR_CUTOFF_T value.
sampling_frequency: sampling frequency in float Available sampling frequency are 95, 190, 380, and 760 Default sampling frequency is 95
-
setScale
(scale)[source]¶ bool setScale(const float scale)
Set scale. IIO only. For I2C operation, use setRange() with the appropriate FS_T value.
scale: in float Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps) Default scale is 0.000153
-