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

AbsoluteIMU Sensor
[Mindsensors]

Files

file  mindsensors-imu.h
 

Mindsensors AbsoluteIMU Sensor driver.


Defines

#define MSIMU_IMU_I2C_ADDR   0x22
#define MSIMU_REG_CMD   0x41
#define MSIMU_REG_TILT_ALL_AXES   0x42
#define MSIMU_REG_ACC_ALL_AXES   0x45
#define MSIMU_REG_COMPASS_HEADING   0x4B
#define MSIMU_REG_COMPASS_ALL_FIELDS   0x4D
#define MSIMU_REG_GYRO_ALL_AXES   0x53
#define MSIMU_REG_GYRO_FILTER   0x5A
#define MSIMU_CMD_COMPASS_START_CAL   0x43
#define MSIMU_CMD_COMPASS_STOP_CAL   0x63
#define MSIMU_CMD_ACC_RANGE_2G   0x31
#define MSIMU_CMD_ACC_RANGE_4G   0x32
#define MSIMU_CMD_ACC_RANGE_8G   0x33
#define MSIMU_CMD_ACC_RANGE_16G   0x34
#define MSIMU_GYRO_FILTER_NONE   0
#define MSIMU_GYRO_FILTER_LEVEL_1   1
#define MSIMU_GYRO_FILTER_LEVEL_2   2
#define MSIMU_GYRO_FILTER_LEVEL_3   3
#define MSIMU_GYRO_FILTER_LEVEL_4   4
#define MSIMU_GYRO_FILTER_LEVEL_5   5
#define MSIMU_GYRO_FILTER_LEVEL_6   6
#define MSIMU_GYRO_FILTER_LEVEL_7   7
#define MSIMU_TILT_X_AXIS   MSIMU_REG_TILT_X_AXIS
#define MSIMU_TILT_Y_AXIS   MSIMU_REG_TILT_Y_AXIS
#define MSIMU_TILT_Z_AXIS   MSIMU_REG_TILT_Z_AXIS
#define MSIMU_ACC_X_AXIS   MSIMU_REG_ACC_X_AXIS
#define MSIMU_ACC_Y_AXIS   MSIMU_REG_ACC_Y_AXIS
#define MSIMU_ACC_Z_AXIS   MSIMU_REG_ACC_Z_AXIS
#define MSIMU_GYRO_X_AXIS   MSIMU_REG_GYRO_X_AXIS
#define MSIMU_GYRO_Y_AXIS   MSIMU_REG_GYRO_Y_AXIS
#define MSIMU_GYRO_Z_AXIS   MSIMU_REG_GYRO_Z_AXIS

Functions

bool _MSIMUsendCMD (tSensors link, ubyte cmd)
bool MSIMUreadTiltAxes (tSensors link, int &_x, int &_y, int &_z)
bool MSIMUreadGyroAxes (tSensors link, int &_x, int &_y, int &_z)
bool MSIMUreadAccelAxes (tSensors link, int &_x, int &_y, int &_z)
bool MSIMUreadMagneticFields (tSensors link, int &_x, int &_y, int &_z)
int MSIMUreadHeading (tSensors link)
bool MSIMUsetGyroFilter (tSensors link, ubyte level)

Variables

tByteArray MSIMU_I2CRequest
tByteArray MSIMU_I2CReply

Detailed Description

Mindsensors AbsoluteIMU Sensor (MSIMU) driver


Define Documentation

#define MSIMU_ACC_X_AXIS   MSIMU_REG_ACC_X_AXIS

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

#define MSIMU_ACC_Y_AXIS   MSIMU_REG_ACC_Y_AXIS

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

#define MSIMU_ACC_Z_AXIS   MSIMU_REG_ACC_Z_AXIS

Definition at line 78 of file mindsensors-imu.h.

#define MSIMU_CMD_ACC_RANGE_16G   0x34

Accelerometer 16G range

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

#define MSIMU_CMD_ACC_RANGE_2G   0x31

Accelerometer 2G range

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

#define MSIMU_CMD_ACC_RANGE_4G   0x32

Accelerometer 4G range

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

#define MSIMU_CMD_ACC_RANGE_8G   0x33

Accelerometer 8G range

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

#define MSIMU_CMD_COMPASS_START_CAL   0x43

Accelerometer 2G range

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

#define MSIMU_CMD_COMPASS_STOP_CAL   0x63

Accelerometer 2G range

Definition at line 55 of file mindsensors-imu.h.

#define MSIMU_GYRO_FILTER_LEVEL_1   1

Gyro filter level: 1

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

#define MSIMU_GYRO_FILTER_LEVEL_2   2

Gyro filter level: 2

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

#define MSIMU_GYRO_FILTER_LEVEL_3   3

Gyro filter level: 3

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

#define MSIMU_GYRO_FILTER_LEVEL_4   4

Gyro filter level: 4 (default)

Definition at line 66 of file mindsensors-imu.h.

#define MSIMU_GYRO_FILTER_LEVEL_5   5

Gyro filter level: 5

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

#define MSIMU_GYRO_FILTER_LEVEL_6   6

Gyro filter level: 6

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

#define MSIMU_GYRO_FILTER_LEVEL_7   7

Gyro filter level: 7 (highest)

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

#define MSIMU_GYRO_FILTER_NONE   0

Gyro filter level: none

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

#define MSIMU_GYRO_X_AXIS   MSIMU_REG_GYRO_X_AXIS

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

#define MSIMU_GYRO_Y_AXIS   MSIMU_REG_GYRO_Y_AXIS

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

#define MSIMU_GYRO_Z_AXIS   MSIMU_REG_GYRO_Z_AXIS

Definition at line 82 of file mindsensors-imu.h.

#define MSIMU_IMU_I2C_ADDR   0x22

IMU I2C address

Definition at line 43 of file mindsensors-imu.h.

#define MSIMU_REG_ACC_ALL_AXES   0x45

All Axes for Accel

Definition at line 48 of file mindsensors-imu.h.

#define MSIMU_REG_CMD   0x41

Command register

Definition at line 45 of file mindsensors-imu.h.

#define MSIMU_REG_COMPASS_ALL_FIELDS   0x4D

All magnetic fields for compass

Definition at line 50 of file mindsensors-imu.h.

#define MSIMU_REG_COMPASS_HEADING   0x4B

Compass heading

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

#define MSIMU_REG_GYRO_ALL_AXES   0x53

All Axes for Gyro

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

#define MSIMU_REG_GYRO_FILTER   0x5A

Filter level for Gyro

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

#define MSIMU_REG_TILT_ALL_AXES   0x42

All Axes for Tilt

Definition at line 47 of file mindsensors-imu.h.

#define MSIMU_TILT_X_AXIS   MSIMU_REG_TILT_X_AXIS

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

#define MSIMU_TILT_Y_AXIS   MSIMU_REG_TILT_Y_AXIS

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

#define MSIMU_TILT_Z_AXIS   MSIMU_REG_TILT_Z_AXIS

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


Function Documentation

bool _MSIMUsendCMD ( tSensors  link,
ubyte  cmd 
)

Send a command to the sensor

Note: this is an internal function and should be called directly

Parameters:
linkthe port number
cmdthe command to be sent
Returns:
true if no error occured, false if it did

Definition at line 104 of file mindsensors-imu.h.

bool MSIMUreadAccelAxes ( tSensors  link,
int &  _x,
int &  _y,
int &  _z 
)

Read all of the accelerometer axes

Parameters:
linkthe port number
_xvariable to hold X axis data
_yvariable to hold Y axis data
_zvariable to hold Z axis data
Returns:
true if no error occured, false if it did
Examples:
mindsensors-imu-test1.c.

Definition at line 170 of file mindsensors-imu.h.

bool MSIMUreadGyroAxes ( tSensors  link,
int &  _x,
int &  _y,
int &  _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:
mindsensors-imu-test1.c.

Definition at line 147 of file mindsensors-imu.h.

int MSIMUreadHeading ( tSensors  link )

Read the current magnetic compass heading

Parameters:
linkthe port number
Returns:
the current heading
Examples:
mindsensors-imu-test2.c, and mindsensors-imu-test3.c.

Definition at line 215 of file mindsensors-imu.h.

bool MSIMUreadMagneticFields ( tSensors  link,
int &  _x,
int &  _y,
int &  _z 
)

Read all the magnetic field strengths

Parameters:
linkthe port number
_xvariable to hold X axis data
_yvariable to hold Y axis data
_zvariable to hold Z axis data
Returns:
true if no error occured, false if it did
Examples:
mindsensors-imu-test3.c.

Definition at line 194 of file mindsensors-imu.h.

bool MSIMUreadTiltAxes ( tSensors  link,
int &  _x,
int &  _y,
int &  _z 
)

Read all three tilt axes

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:
mindsensors-imu-test2.c.

Definition at line 123 of file mindsensors-imu.h.

bool MSIMUsetGyroFilter ( tSensors  link,
ubyte  level 
)

Set the level of filtering of the Gryo readings.

Parameters:
linkthe port number
levelthe level of filtering (0-7) where 0 is none and 7 is the highest amount of filtering, 4 is the default level.
Returns:
true if no error occured, false if it did

Definition at line 234 of file mindsensors-imu.h.


Variable Documentation

Array to hold I2C reply data

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

Array to hold I2C command data

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