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

Compass Sensor
[HiTechnic]

Files

file  HTMC-driver.h
 

HiTechnic Magnetic Compass Sensor Driver.


Defines

#define HTMC_I2C_ADDR   0x02
#define HTMC_MODE   0x41
#define HTMC_HEAD_U   0x42
#define HTMC_HEAD_L   0x43
#define HTMC_MEASURE_CMD   0x00
#define HTMC_CALIBRATE_CMD   0x43

Functions

bool HTMCstartCal (tSensors link)
bool HTMCstopCal (tSensors link)
int HTMCreadHeading (tSensors link)
int HTMCreadRelativeHeading (tSensors link)
int HTMCsetTarget (tSensors link, int offset=0)
int HTMCreadHeading (tMUXSensor muxsensor)
int HTMCreadRelativeHeading (tMUXSensor muxsensor)
int HTMCsetTarget (tMUXSensor muxsensor, int offset=0)

Variables

tConfigParams HTMC_config = {HTSMUX_CHAN_I2C, 2, 0x02, 0x42}
tByteArray HTMC_I2CRequest
tByteArray HTMC_I2CReply
int target [][]

Detailed Description

HiTechnic Compass Sensor


Define Documentation

#define HTMC_CALIBRATE_CMD   0x43

HTMC calibrate mode command

Definition at line 52 of file HTMC-driver.h.

#define HTMC_HEAD_L   0x43

HTMC Heading Lower bit

Definition at line 48 of file HTMC-driver.h.

#define HTMC_HEAD_U   0x42

HTMC Heading Upper bits

Definition at line 47 of file HTMC-driver.h.

#define HTMC_I2C_ADDR   0x02

HTMC I2C device address

Definition at line 45 of file HTMC-driver.h.

#define HTMC_MEASURE_CMD   0x00

HTMC measurement mode command

Definition at line 51 of file HTMC-driver.h.

#define HTMC_MODE   0x41

HTMC Mode control

Definition at line 46 of file HTMC-driver.h.


Function Documentation

int HTMCreadHeading ( tSensors  link )

Return the current absolute heading

Parameters:
linkthe HTMC port number
Returns:
heading in degrees (0 - 359) or -1 if an error occurred.
Examples:
HTMC-SMUX-test1.c, and HTMC-test1.c.

Definition at line 134 of file HTMC-driver.h.

int HTMCreadHeading ( tMUXSensor  muxsensor )

Return the current absolute heading

Parameters:
muxsensorthe SMUX sensor port number
Returns:
heading in degrees (0 - 359) or -1 if an error occurred.

Definition at line 158 of file HTMC-driver.h.

int HTMCreadRelativeHeading ( tSensors  link )

Return the current relative heading, value between -179 and 180

Parameters:
linkthe HTMC port number
Returns:
relative heading in degrees or -255 if an error occurred.
Examples:
HTMC-SMUX-test1.c, and HTMC-test1.c.

Definition at line 179 of file HTMC-driver.h.

int HTMCreadRelativeHeading ( tMUXSensor  muxsensor )

Return the current relative heading, value between -179 and 180

Parameters:
muxsensorthe SMUX sensor port number
Returns:
relative heading in degrees or -255 if an error occurred.

Definition at line 193 of file HTMC-driver.h.

int HTMCsetTarget ( tSensors  link,
int  offset 
)

Set the value for the offset to be used as the new zero-point for the relative heading returned by HTMCreadRelativeHeading()

Parameters:
linkthe HTMC port number
offsetto be used to calculate relative heading (0-360 degrees). If unspecified, uses current heading.
Returns:
the current target heading
Examples:
HTMC-SMUX-test1.c, and HTMC-test1.c.

Definition at line 211 of file HTMC-driver.h.

int HTMCsetTarget ( tMUXSensor  muxsensor,
int  offset 
)

Set the value for the offset to be used as the new zero-point for the relative heading returned by HTMCreadRelativeHeading()

Parameters:
muxsensorthe SMUX sensor port number
offsetto be used to calculate relative heading (0-360 degrees). If unspecified, uses current heading.

Definition at line 224 of file HTMC-driver.h.

bool HTMCstartCal ( tSensors  link )

Start the calibration. The sensor should be rotated a little more than 360 along the horizontal plane in no less than 20 seconds. After the sensor has been rotated, call HTMCstopCal() to set the sensor back in measurement mode and save the calibration data. This calibration data is stored in the sensor until the next calibration.

Parameters:
linkthe HTMC port number
Returns:
true if no error occured, false if it did
Examples:
HTMC-test2.c.

Definition at line 86 of file HTMC-driver.h.

bool HTMCstopCal ( tSensors  link )

Stop the calibration. This should be called no less than 20 seconds after HTMCstartCal() and only if the sensor has been rotated more than 360 degrees

Parameters:
linkthe HTMC port number
Returns:
true if no error occured, false if it did
Examples:
HTMC-test2.c.

Definition at line 105 of file HTMC-driver.h.


Variable Documentation

tConfigParams HTMC_config = {HTSMUX_CHAN_I2C, 2, 0x02, 0x42}

Array to hold SMUX config data for sensor

Definition at line 65 of file HTMC-driver.h.

Array to hold I2C reply data

Definition at line 69 of file HTMC-driver.h.

Array to hold I2C command data

Definition at line 68 of file HTMC-driver.h.

int target[][]
Initial value:
 {{0, 0, 0, 0},   
                  {0, 0, 0, 0},
                  {0, 0, 0, 0},
                  {0, 0, 0, 0}}

Definition at line 71 of file HTMC-driver.h.