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

3D Compass Sensor
[Dexter Industries]

Files

file  dexterind-compass.h
 

Dexter Industries IMU Sensor driver.


Defines

#define DIMCDAT   "dimc.dat"
#define DIMC_I2C_ADDR   0x3C
#define DIMC_REG_CONFIG_A   0x00
#define DIMC_REG_CONFIG_B   0x01
#define DIMC_REG_MODE   0x02
#define DIMC_REG_X_MSB   0x03
#define DIMC_REG_X_LSB   0x04
#define DIMC_REG_Z_MSB   0x05
#define DIMC_REG_Z_LSB   0x06
#define DIMC_REG_Y_MSB   0x07
#define DIMC_REG_Y_LSB   0x08
#define DIMC_REG_STATUS   0x09
#define DIMC_REG_IDENT_A   0x0A
#define DIMC_REG_IDENT_B   0x0B
#define DIMC_REG_IDENT_C   0x0C
#define DIMC_STATUS_LOCK   2
#define DIMC_STATUS_RDY   1
#define DIMC_MODE_CONTINUOUS   0
#define DIMC_MODE_SINGLE   1
#define DIMC_MODE_IDLE_A   2
#define DIMC_MODE_IDLE_B   3
#define DIMC_MODE_MASK   3
#define DIMC_CONF_A_SAMPLES_1   0x00
#define DIMC_CONF_A_SAMPLES_2   0x20
#define DIMC_CONF_A_SAMPLES_4   0x40
#define DIMC_CONF_A_SAMPLES_8   0x60
#define DIMC_CONF_A_SAMPLES_MASK   0x60
#define DIMC_CONF_A_RATE_0_75   0x00
#define DIMC_CONF_A_RATE_1_5   0x04
#define DIMC_CONF_A_RATE_3   0x08
#define DIMC_CONF_A_RATE_7_5   0x0C
#define DIMC_CONF_A_RATE_15   0x10
#define DIMC_CONF_A_RATE_30   0x14
#define DIMC_CONF_A_RATE_75   0x18
#define DIMC_CONF_A_RATE_RESERVED   0x1C
#define DIMC_CONF_A_RATE_MASK   0x1C
#define DIMC_CONF_A_BIAS_NORMAL   0x00
#define DIMC_CONF_A_BIAS_POSITIVE   0x01
#define DIMC_CONF_A_BIAS_NEGATIVE   0x02
#define DIMC_CONF_A_BIAS_RESERVED   0x03
#define DIMC_CONF_A_BIAS_MASK   0x03
#define DIMC_CONF_B_GAIN_0_88   0x00
#define DIMC_CONF_B_GAIN_1_3   0x20
#define DIMC_CONF_B_GAIN_1_9   0x40
#define DIMC_CONF_B_GAIN_2_5   0x60
#define DIMC_CONF_B_GAIN_4_0   0x80
#define DIMC_CONF_B_GAIN_4_7   0xA0
#define DIMC_CONF_B_GAIN_5_6   0xC0
#define DIMC_CONF_B_GAIN_8_1   0xE0
#define DIMC_CONF_B_GAIN_MASK   0xE0
#define DIMC_GAIN_SCALE_0_88   0.73
#define DIMC_GAIN_SCALE_1_3   0.92
#define DIMC_GAIN_SCALE_1_9   1.22
#define DIMC_GAIN_SCALE_2_5   1.52
#define DIMC_GAIN_SCALE_4_0   2.27
#define DIMC_GAIN_SCALE_4_7   2.56
#define DIMC_GAIN_SCALE_5_6   3.03
#define DIMC_GAIN_SCALE_8_1   4.35

Functions

bool DIMCinit (tSensors link, ubyte range, bool lpfenable=true)
bool DIMCreadAxes (tSensors link, int &_x, int &_y, int &_z)
float DIMCreadHeading (tSensors link)
void DIMCstartCal (tSensors link)
void DIMCstopCal (tSensors link)
void _DIMCreadCalVals ()
void _DIMCwriteCalVals ()
bool DIMCinit (tSensors link)

Variables

tByteArray DIMC_I2CRequest
tByteArray DIMC_I2CReply
bool DIMCcalibrating [4] = {false, false, false, false }
bool DIMCcalibrationDataLoaded = false
int DIMCminVals [4][3] = {{32767, 32767, 32767}, {32767, 32767, 32767}, {32767, 32767, 32767}, {32767, 32767, 32767}}
int DIMCmaxVals [4][3] = {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}
int DIMCoffsets [4][3] = {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}

Detailed Description

Dexter Industries DIMC 3D Compass Sensor driver


Define Documentation

#define DIMC_CONF_A_BIAS_MASK   0x03

Mask for setting measurement bias

Definition at line 101 of file dexterind-compass.h.

#define DIMC_CONF_A_BIAS_NEGATIVE   0x02

Negative bias configuration for X, Y and Z axes.

Definition at line 99 of file dexterind-compass.h.

#define DIMC_CONF_A_BIAS_NORMAL   0x00

Normal measurement configuration (Default)

Definition at line 97 of file dexterind-compass.h.

#define DIMC_CONF_A_BIAS_POSITIVE   0x01

Positive bias configuration for X, Y, and Z axes.

Definition at line 98 of file dexterind-compass.h.

#define DIMC_CONF_A_BIAS_RESERVED   0x03

Definition at line 100 of file dexterind-compass.h.

#define DIMC_CONF_A_RATE_0_75   0x00

Data Output Rate: 0.75 Hz

Definition at line 86 of file dexterind-compass.h.

#define DIMC_CONF_A_RATE_15   0x10

Data Output Rate: 15 Hz

Definition at line 90 of file dexterind-compass.h.

#define DIMC_CONF_A_RATE_1_5   0x04

Data Output Rate: 1.5 Hz

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

#define DIMC_CONF_A_RATE_3   0x08

Data Output Rate: 3 Hz

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

#define DIMC_CONF_A_RATE_30   0x14

Data Output Rate: 30 Hz

Definition at line 91 of file dexterind-compass.h.

#define DIMC_CONF_A_RATE_75   0x18

Data Output Rate: 75 Hz

Definition at line 92 of file dexterind-compass.h.

#define DIMC_CONF_A_RATE_7_5   0x0C

Data Output Rate: 7.5 Hz

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

#define DIMC_CONF_A_RATE_MASK   0x1C

Mask for setting Data Output Rate

Definition at line 94 of file dexterind-compass.h.

#define DIMC_CONF_A_RATE_RESERVED   0x1C

Definition at line 93 of file dexterind-compass.h.

#define DIMC_CONF_A_SAMPLES_1   0x00

Number of samples averaged: 1

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

#define DIMC_CONF_A_SAMPLES_2   0x20

Number of samples averaged: 2

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

#define DIMC_CONF_A_SAMPLES_4   0x40

Number of samples averaged: 4

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

#define DIMC_CONF_A_SAMPLES_8   0x60

Number of samples averaged: 8

Definition at line 82 of file dexterind-compass.h.

#define DIMC_CONF_A_SAMPLES_MASK   0x60

Mask for setting sample number

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

#define DIMC_CONF_B_GAIN_0_88   0x00

Sensor Field Range ±0.88 Ga

Definition at line 104 of file dexterind-compass.h.

#define DIMC_CONF_B_GAIN_1_3   0x20

Sensor Field Range ±1.3 Ga

Definition at line 105 of file dexterind-compass.h.

#define DIMC_CONF_B_GAIN_1_9   0x40

Sensor Field Range ±1.9 Ga

Definition at line 106 of file dexterind-compass.h.

#define DIMC_CONF_B_GAIN_2_5   0x60

Sensor Field Range ±2.5 Ga

Definition at line 107 of file dexterind-compass.h.

#define DIMC_CONF_B_GAIN_4_0   0x80

Sensor Field Range ±4.0 Ga

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

#define DIMC_CONF_B_GAIN_4_7   0xA0

Sensor Field Range ±4.7 Ga

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

#define DIMC_CONF_B_GAIN_5_6   0xC0

Sensor Field Range ±5.6 Ga

Definition at line 110 of file dexterind-compass.h.

#define DIMC_CONF_B_GAIN_8_1   0xE0

Sensor Field Range ±8.1 Ga

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

#define DIMC_CONF_B_GAIN_MASK   0xE0

Mask for setting Sensor Field Range

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

#define DIMC_GAIN_SCALE_0_88   0.73

Ramge multiplier for ±0.88 Ga

Definition at line 115 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_1_3   0.92

Ramge multiplier for ±1.3 Ga

Definition at line 116 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_1_9   1.22

Ramge multiplier for ±1.9 Ga

Definition at line 117 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_2_5   1.52

Ramge multiplier for ±2.5 Ga

Definition at line 118 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_4_0   2.27

Ramge multiplier for ±4.0 Ga

Definition at line 119 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_4_7   2.56

Ramge multiplier for ±4.7 Ga

Definition at line 120 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_5_6   3.03

Ramge multiplier for ±5.6 Ga

Definition at line 121 of file dexterind-compass.h.

#define DIMC_GAIN_SCALE_8_1   4.35

Ramge multiplier for ±8.1 Ga

Definition at line 122 of file dexterind-compass.h.

#define DIMC_I2C_ADDR   0x3C

Compass I2C address

Definition at line 45 of file dexterind-compass.h.

#define DIMC_MODE_CONTINUOUS   0

Continuous-Measurement Mode

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

#define DIMC_MODE_IDLE_A   2

Idle Mode

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

#define DIMC_MODE_IDLE_B   3

Idle Mode

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

#define DIMC_MODE_MASK   3

Mask for setting mode

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

#define DIMC_MODE_SINGLE   1

Single-Measurement Mode (Default)

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

#define DIMC_REG_CONFIG_A   0x00

250 dps range

Definition at line 47 of file dexterind-compass.h.

#define DIMC_REG_CONFIG_B   0x01

500 dps range

Definition at line 48 of file dexterind-compass.h.

#define DIMC_REG_IDENT_A   0x0A

Identification Register A

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

#define DIMC_REG_IDENT_B   0x0B

Identification Register B

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

#define DIMC_REG_IDENT_C   0x0C

Identification Register C

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

#define DIMC_REG_MODE   0x02

2000 dps range

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

#define DIMC_REG_STATUS   0x09

Status register

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

#define DIMC_REG_X_LSB   0x04

Register LSB X axis

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

#define DIMC_REG_X_MSB   0x03

Register MSB X axis

Definition at line 50 of file dexterind-compass.h.

#define DIMC_REG_Y_LSB   0x08

Register LSB Y axis

Definition at line 55 of file dexterind-compass.h.

#define DIMC_REG_Y_MSB   0x07

Register MSB Y axis

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

#define DIMC_REG_Z_LSB   0x06

Register LSB Z axis

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

#define DIMC_REG_Z_MSB   0x05

Register MSB Z axis

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

#define DIMC_STATUS_LOCK   2

Data output register lock active

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

#define DIMC_STATUS_RDY   1

Data is ready for reading

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

#define DIMCDAT   "dimc.dat"

Definition at line 43 of file dexterind-compass.h.


Function Documentation

void _DIMCreadCalVals (  )

Read the calibration values from a data file.

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

Definition at line 325 of file dexterind-compass.h.

void _DIMCwriteCalVals (  )

Write the calibration values to a data file.

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

Definition at line 268 of file dexterind-compass.h.

bool DIMCinit ( tSensors  link )

Configure the Compass

Parameters:
linkthe port number
Returns:
true if no error occured, false if it did

Definition at line 146 of file dexterind-compass.h.

bool DIMCinit ( tSensors  link,
ubyte  range,
bool  lpfenable = true 
)
bool DIMCreadAxes ( tSensors  link,
int &  _x,
int &  _y,
int &  _z 
)

Read all three axes of the Compass

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-compass-test1.c, dexterind-compass-test2.c, and dexterind-compass-test3.c.

Definition at line 185 of file dexterind-compass.h.

float DIMCreadHeading ( tSensors  link )

Read the current heading

Returns:
the heading in degrees.
Examples:
dexterind-compass-test1.c, and dexterind-compass-test2.c.

Definition at line 226 of file dexterind-compass.h.

void DIMCstartCal ( tSensors  link )

Start calibration. The robot should be made to rotate about its axis at least twice to get an accurate result. Stop the calibration with DIMCstopCal()

Examples:
dexterind-compass-test2.c.

Definition at line 243 of file dexterind-compass.h.

void DIMCstopCal ( tSensors  link )

Stop calibration. The appropriate offsets will be calculated for all the axes.

Examples:
dexterind-compass-test2.c.

Definition at line 253 of file dexterind-compass.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 125 of file dexterind-compass.h.

Array to hold I2C command data

Definition at line 124 of file dexterind-compass.h.

bool DIMCcalibrating[4] = {false, false, false, false }

Definition at line 135 of file dexterind-compass.h.

Definition at line 136 of file dexterind-compass.h.

int DIMCmaxVals[4][3] = {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}

Definition at line 138 of file dexterind-compass.h.

int DIMCminVals[4][3] = {{32767, 32767, 32767}, {32767, 32767, 32767}, {32767, 32767, 32767}, {32767, 32767, 32767}}

Definition at line 137 of file dexterind-compass.h.

int DIMCoffsets[4][3] = {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}

Definition at line 139 of file dexterind-compass.h.