Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Functions | Variables

IMU Sensor
[Dexter Industries]

Files

file  dexterind-imu.h
 

Dexter Industries IMU Sensor driver.


Defines

#define DIMU_GYRO_I2C_ADDR   0xD2
#define DIMU_GYRO_RANGE_250   0x00
#define DIMU_GYRO_RANGE_500   0x10
#define DIMU_GYRO_RANGE_2000   0x30
#define DIMU_CTRL4_BLOCKDATA   0x80
#define DIMU_GYRO_CTRL_REG1   0x20
#define DIMU_GYRO_CTRL_REG2   0x21
#define DIMU_GYRO_CTRL_REG3   0x22
#define DIMU_GYRO_CTRL_REG4   0x23
#define DIMU_GYRO_CTRL_REG5   0x24
#define DIMU_GYRO_ALL_AXES   0x28
#define DIMU_GYRO_X_AXIS   0x2A
#define DIMU_GYRO_Y_AXIS   0x28
#define DIMU_GYRO_Z_AXIS   0x2C
#define DIMU_ACC_I2C_ADDR   0x3A
#define DIMU_ACC_RANGE_2G   0x04
#define DIMU_ACC_RANGE_4G   0x08
#define DIMU_ACC_RANGE_8G   0x00
#define DIMU_ACC_MODE_STBY   0x00
#define DIMU_ACC_MODE_MEAS   0x01
#define DIMU_ACC_MODE_LVLD   0x02
#define DIMU_ACC_MODE_PLSE   0x03
#define DIMU_ACC_X_AXIS   0x00
#define DIMU_ACC_Y_AXIS   0x02
#define DIMU_ACC_Z_AXIS   0x04
#define DIMUreadGyroXAxis(X)   DIMUreadGyroAxis(X, DIMU_GYRO_X_AXIS)
#define DIMUreadGyroYAxis(X)   DIMUreadGyroAxis(X, DIMU_GYRO_Y_AXIS)
#define DIMUreadGyroZAxis(X)   DIMUreadGyroAxis(X, DIMU_GYRO_Z_AXIS)
#define DIMUreadAccelXAxis10Bit(X)   DIMUreadAccelAxis10Bit(X, DIMU_ACC_X_AXIS)
#define DIMUreadAccelYAxis10Bit(X)   DIMUreadAccelAxis10Bit(X, DIMU_ACC_Y_AXIS)
#define DIMUreadAccelZAxis10Bit(X)   DIMUreadAccelAxis10Bit(X, DIMU_ACC_Z_AXIS)
#define DIMUreadAccelXAxis8Bit(X)   DIMUreadAccelAxis8Bit(X, DIMU_ACC_X_AXIS)
#define DIMUreadAccelYAxis8Bit(X)   DIMUreadAccelAxis8Bit(X, DIMU_ACC_Y_AXIS)
#define DIMUreadAccelZAxis8Bit(X)   DIMUreadAccelAxis8Bit(X, DIMU_ACC_Z_AXIS)

Functions

bool DIMUconfigGyro (tSensors link, ubyte range, bool lpfenable=true)
float DIMUreadGyroAxis (tSensors link, ubyte axis)
void DIMUreadGyroAxes (tSensors link, float &_x, float &_y, float &_z)
bool DIMUconfigAccel (tSensors link, ubyte range)
float DIMUreadAccelAxis8Bit (tSensors link, ubyte axis)
bool DIMUsetAccelAxisOffset (tSensors link, ubyte drift_reg, ubyte drift_LSB, ubyte drift_MSB)
float DIMUreadAccelAxis10Bit (tSensors link, ubyte axis, bool calibrate=false)
void DIMUreadAccelAxes8Bit (tSensors link, float &_x, float &_y, float &_z)
void DIMUreadAccelAxes10Bit (tSensors link, float &_x, float &_y, float &_z)
void DIMUcalAccel (tSensors link)
bool DIMUconfigIMU (tSensors link, ubyte accelRange=DIMU_ACC_RANGE_8G, ubyte gyroRange=DIMU_GYRO_RANGE_250, bool lpfenable=true)

Variables

float DIMU_Gyro_divisor [4] = {0.0, 0.0, 0.0, 0.0}
float DIMU_Accel_divisor [4] = {0.0, 0.0, 0.0, 0.0}
tByteArray DIMU_I2CRequest
tByteArray DIMU_I2CReply

Detailed Description

Dexter Industries DIMU Sensor driver


Define Documentation

#define DIMU_ACC_I2C_ADDR   0x3A

Accelerometer I2C address

Definition at line 67 of file dexterind-imu.h.

#define DIMU_ACC_MODE_LVLD   0x02

Accelerometer level detect mode

Definition at line 73 of file dexterind-imu.h.

#define DIMU_ACC_MODE_MEAS   0x01

Accelerometer measurement mode

Definition at line 72 of file dexterind-imu.h.

#define DIMU_ACC_MODE_PLSE   0x03

Accelerometer pulse detect mode

Definition at line 74 of file dexterind-imu.h.

#define DIMU_ACC_MODE_STBY   0x00

Accelerometer standby mode

Definition at line 71 of file dexterind-imu.h.

#define DIMU_ACC_RANGE_2G   0x04

Accelerometer 2G range

Examples:
dexterind-imu-test1.c, and dexterind-imu-test2.c.

Definition at line 68 of file dexterind-imu.h.

#define DIMU_ACC_RANGE_4G   0x08

Accelerometer 4G range

Definition at line 69 of file dexterind-imu.h.

#define DIMU_ACC_RANGE_8G   0x00

Accelerometer 8G range

Definition at line 70 of file dexterind-imu.h.

#define DIMU_ACC_X_AXIS   0x00

X Axis for Accel

Examples:
dexterind-imu-test1.c.

Definition at line 75 of file dexterind-imu.h.

#define DIMU_ACC_Y_AXIS   0x02

Y Axis for Accel

Examples:
dexterind-imu-test1.c.

Definition at line 76 of file dexterind-imu.h.

#define DIMU_ACC_Z_AXIS   0x04

Z Axis for Accel

Examples:
dexterind-imu-test1.c.

Definition at line 77 of file dexterind-imu.h.

#define DIMU_CTRL4_BLOCKDATA   0x80

Definition at line 54 of file dexterind-imu.h.

#define DIMU_GYRO_ALL_AXES   0x28

All Axes for Gyro

Definition at line 62 of file dexterind-imu.h.

#define DIMU_GYRO_CTRL_REG1   0x20

CTRL_REG1 for Gyro

Definition at line 56 of file dexterind-imu.h.

#define DIMU_GYRO_CTRL_REG2   0x21

CTRL_REG2 for Gyro

Definition at line 57 of file dexterind-imu.h.

#define DIMU_GYRO_CTRL_REG3   0x22

CTRL_REG3 for Gyro

Definition at line 58 of file dexterind-imu.h.

#define DIMU_GYRO_CTRL_REG4   0x23

CTRL_REG4 for Gyro

Definition at line 59 of file dexterind-imu.h.

#define DIMU_GYRO_CTRL_REG5   0x24

CTRL_REG5 for Gyro

Definition at line 60 of file dexterind-imu.h.

#define DIMU_GYRO_I2C_ADDR   0xD2

Gyro I2C address

Definition at line 49 of file dexterind-imu.h.

#define DIMU_GYRO_RANGE_2000   0x30

2000 dps range

Definition at line 53 of file dexterind-imu.h.

#define DIMU_GYRO_RANGE_250   0x00

250 dps range

Examples:
dexterind-imu-test2.c.

Definition at line 51 of file dexterind-imu.h.

#define DIMU_GYRO_RANGE_500   0x10

500 dps range

Examples:
dexterind-imu-test1.c.

Definition at line 52 of file dexterind-imu.h.

#define DIMU_GYRO_X_AXIS   0x2A

X Axis for Gyro

Definition at line 63 of file dexterind-imu.h.

#define DIMU_GYRO_Y_AXIS   0x28

Y Axis for Gyro

Definition at line 64 of file dexterind-imu.h.

#define DIMU_GYRO_Z_AXIS   0x2C

Z Axis for Gyro

Definition at line 65 of file dexterind-imu.h.

#define DIMUreadAccelXAxis10Bit (   X )    DIMUreadAccelAxis10Bit(X, DIMU_ACC_X_AXIS)

Definition at line 83 of file dexterind-imu.h.

#define DIMUreadAccelXAxis8Bit (   X )    DIMUreadAccelAxis8Bit(X, DIMU_ACC_X_AXIS)

Definition at line 87 of file dexterind-imu.h.

#define DIMUreadAccelYAxis10Bit (   X )    DIMUreadAccelAxis10Bit(X, DIMU_ACC_Y_AXIS)

Definition at line 84 of file dexterind-imu.h.

#define DIMUreadAccelYAxis8Bit (   X )    DIMUreadAccelAxis8Bit(X, DIMU_ACC_Y_AXIS)

Definition at line 88 of file dexterind-imu.h.

#define DIMUreadAccelZAxis10Bit (   X )    DIMUreadAccelAxis10Bit(X, DIMU_ACC_Z_AXIS)

Definition at line 85 of file dexterind-imu.h.

#define DIMUreadAccelZAxis8Bit (   X )    DIMUreadAccelAxis8Bit(X, DIMU_ACC_Z_AXIS)

Definition at line 89 of file dexterind-imu.h.

#define DIMUreadGyroXAxis (   X )    DIMUreadGyroAxis(X, DIMU_GYRO_X_AXIS)

Definition at line 79 of file dexterind-imu.h.

#define DIMUreadGyroYAxis (   X )    DIMUreadGyroAxis(X, DIMU_GYRO_Y_AXIS)

Definition at line 80 of file dexterind-imu.h.

#define DIMUreadGyroZAxis (   X )    DIMUreadGyroAxis(X, DIMU_GYRO_Z_AXIS)

Definition at line 81 of file dexterind-imu.h.


Function Documentation

void DIMUcalAccel ( tSensors  link )

Calibrate the Accelerometer. The sensor must be stationary and assumes the Z axis is facing up.

Parameters:
linkthe port number

Definition at line 397 of file dexterind-imu.h.

bool DIMUconfigAccel ( tSensors  link,
ubyte  range 
)

Wait for the I2C bus to be ready for the next message

Parameters:
linkthe port number
rangethe range at which to operate the Accelerometer, can be 2, 4 and 8G
Returns:
true if no error occured, false if it did
Examples:
dexterind-imu-test1.c, and dexterind-imu-test2.c.

Definition at line 252 of file dexterind-imu.h.

bool DIMUconfigGyro ( tSensors  link,
ubyte  range,
bool  lpfenable 
)

Configure the gyro

Parameters:
linkthe port number
rangethe operating range of the gyro
lpfenableEnable built-in Low Pass Filter to reduce spikes in data, optional, defaults to true.
Returns:
true if no error occured, false if it did
Examples:
dexterind-imu-test1.c, and dexterind-imu-test2.c.

Definition at line 144 of file dexterind-imu.h.

bool DIMUconfigIMU ( tSensors  link,
ubyte  accelRange = DIMU_ACC_RANGE_8G,
ubyte  gyroRange = DIMU_GYRO_RANGE_250,
bool  lpfenable = true 
)

Definition at line 405 of file dexterind-imu.h.

void DIMUreadAccelAxes10Bit ( tSensors  link,
float &  _x,
float &  _y,
float &  _z 
)

Read the specified accelerometer axis, returns an 10 bit answer

Parameters:
linkthe port number
_xvariable to hold X axis data
_yvariable to hold Y axis data
_zvariable to hold Z axis data

Definition at line 386 of file dexterind-imu.h.

void DIMUreadAccelAxes8Bit ( tSensors  link,
float &  _x,
float &  _y,
float &  _z 
)

Read the specified accelerometer axis, returns an 8 bit answer

Parameters:
linkthe port number
_xvariable to hold X axis data
_yvariable to hold Y axis data
_zvariable to hold Z axis data

Definition at line 372 of file dexterind-imu.h.

float DIMUreadAccelAxis10Bit ( tSensors  link,
ubyte  axis,
bool  calibrate 
)

Read the specified accelerometer axis, returns an 10 bit answer

Parameters:
linkthe port number
axisthe specific axis
calibrateoptional argument, if set to to true, the sensor will calibrate this axis first.
Returns:
gravity in G with 10 bit accuracy
Examples:
dexterind-imu-test1.c.

Definition at line 329 of file dexterind-imu.h.

float DIMUreadAccelAxis8Bit ( tSensors  link,
ubyte  axis 
)

Read the specified accelerometer axis, returns an 8 bit answer

Parameters:
linkthe port number
axisthe specific axis
Returns:
gravity in G with 8 bit accuracy

Definition at line 280 of file dexterind-imu.h.

void DIMUreadGyroAxes ( tSensors  link,
float &  _x,
float &  _y,
float &  _z 
)

Read all three axes of the gyro

Parameters:
linkthe port number
_xdata for x axis in degrees per second
_ydata for y axis in degrees per second
_zdata for z axis in degrees per second
Returns:
true if no error occured, false if it did
Examples:
dexterind-imu-test1.c, and dexterind-imu-test2.c.

Definition at line 230 of file dexterind-imu.h.

float DIMUreadGyroAxis ( tSensors  link,
ubyte  axis 
)

Retrieve the axis data

Parameters:
linkthe port number
axisthe specified axis
Returns:
the axis data in degrees per second

Definition at line 205 of file dexterind-imu.h.

bool DIMUsetAccelAxisOffset ( tSensors  link,
ubyte  drift_reg,
ubyte  drift_LSB,
ubyte  drift_MSB 
)

Confgures an offset register for the accelerometer.

Parameters:
linkthe port number
drift_regthe register to write to
drift_LSBdrift value LSB
drift_MSBdrift value MSB
Returns:
true if no error occured, false if it did

Definition at line 307 of file dexterind-imu.h.


Variable Documentation

float DIMU_Accel_divisor[4] = {0.0, 0.0, 0.0, 0.0}

Array to hold divisor data for 8 bit measurements

Definition at line 109 of file dexterind-imu.h.

float DIMU_Gyro_divisor[4] = {0.0, 0.0, 0.0, 0.0}

Array to hold divisor data for 8 bit measurements

Definition at line 108 of file dexterind-imu.h.

Array to hold I2C reply data

Definition at line 112 of file dexterind-imu.h.

Array to hold I2C command data

Definition at line 111 of file dexterind-imu.h.