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  hitechnic-compass.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 53 of file hitechnic-compass.h.

#define HTMC_HEAD_L   0x43

HTMC Heading Lower bit

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

#define HTMC_HEAD_U   0x42

HTMC Heading Upper bits

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

#define HTMC_I2C_ADDR   0x02

HTMC I2C device address

Definition at line 46 of file hitechnic-compass.h.

#define HTMC_MEASURE_CMD   0x00

HTMC measurement mode command

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

#define HTMC_MODE   0x41

HTMC Mode control

Definition at line 47 of file hitechnic-compass.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:
hitechnic-compass-SMUX-test1.c, and hitechnic-compass-test1.c.

Definition at line 132 of file hitechnic-compass.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 153 of file hitechnic-compass.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:
hitechnic-compass-SMUX-test1.c, and hitechnic-compass-test1.c.

Definition at line 174 of file hitechnic-compass.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 188 of file hitechnic-compass.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:
hitechnic-compass-SMUX-test1.c, and hitechnic-compass-test1.c.

Definition at line 206 of file hitechnic-compass.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 219 of file hitechnic-compass.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:
hitechnic-compass-test2.c.

Definition at line 87 of file hitechnic-compass.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:
hitechnic-compass-test2.c.

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


Variable Documentation

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

Array to hold SMUX config data for sensor

Definition at line 66 of file hitechnic-compass.h.

Array to hold I2C reply data

Definition at line 70 of file hitechnic-compass.h.

Array to hold I2C command data

Definition at line 69 of file hitechnic-compass.h.

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

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