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

Angle Sensor
[HiTechnic]

Files

file  HTANG-driver.h
 

HiTechnic Angle Sensor driver.


Defines

#define HTANG_I2C_ADDR   0x02
#define HTANG_CMD_REG   0x41
#define HTANG_OFFSET   0x42
#define HTANG_ANG2   0x00
#define HTANG_ANG1   0x01
#define HTANG_ACC_ANG_B4   0x02
#define HTANG_ACC_ANG_B3   0x03
#define HTANG_ACC_ANG_B2   0x04
#define HTANG_ACC_ANG_B1   0x05
#define HTANG_RPM_H   0x06
#define HTANG_RPM_L   0x07
#define HTANG_CMD_MEASURE   0x00
#define HTANG_CMD_RST_ANG   0x43
#define HTANG_CMD_RST_ACC_ANG   0x52

Functions

int HTANGreadAngle (tSensors link)
long HTANGreadAccumulatedAngle (tSensors link)
int HTANGreadRPM (tSensors link)
bool HTANGresetAngle (tSensors link)
bool HTANGresetAccumulatedAngle (tSensors link)
bool _HTANGsendCommand (tSensors link, byte command)
int HTANGreadAngle (tMUXSensor muxsensor)
long HTANGreadAccumulatedAngle (tMUXSensor muxsensor)
int HTANGreadRPM (tMUXSensor muxsensor)

Variables

tConfigParams HTANG_config = {HTSMUX_CHAN_I2C, 8, 0x02, 0x42}
tByteArray HTANG_I2CRequest
tByteArray HTANG_I2CReply

Detailed Description

HiTechnic Angle Sensor


Define Documentation

#define HTANG_ACC_ANG_B1   0x05

32 bit accumulated angle 1st byte

Definition at line 53 of file HTANG-driver.h.

#define HTANG_ACC_ANG_B2   0x04

32 bit accumulated angle 2nd byte

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

#define HTANG_ACC_ANG_B3   0x03

32 bit accumulated angle 3rd byte

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

#define HTANG_ACC_ANG_B4   0x02

32 bit accumulated angle 4th byte

Definition at line 50 of file HTANG-driver.h.

#define HTANG_ANG1   0x01

Current angle (1 deg adder)

Definition at line 49 of file HTANG-driver.h.

#define HTANG_ANG2   0x00

Current angle (2 deg increments)

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

#define HTANG_CMD_MEASURE   0x00

Normal angle measurement mode

Definition at line 58 of file HTANG-driver.h.

#define HTANG_CMD_REG   0x41

Command register

Definition at line 44 of file HTANG-driver.h.

#define HTANG_CMD_RST_ACC_ANG   0x52

Resets the accumulated angle

Definition at line 60 of file HTANG-driver.h.

#define HTANG_CMD_RST_ANG   0x43

Resets 0 position to current shaft angle, non-volatile setting

Definition at line 59 of file HTANG-driver.h.

#define HTANG_I2C_ADDR   0x02

HTCS2 I2C device address

Definition at line 43 of file HTANG-driver.h.

#define HTANG_OFFSET   0x42

Offset for data registers

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

#define HTANG_RPM_H   0x06

16 bit rpms, high byte

Definition at line 54 of file HTANG-driver.h.

#define HTANG_RPM_L   0x07

16 bit rpms, low byte

Definition at line 55 of file HTANG-driver.h.


Function Documentation

bool _HTANGsendCommand ( tSensors  link,
byte  command 
)

Send a command to the sensor

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

Parameters:
linkthe HTANG port number
commandthe command to be sent to the sensor
Returns:
true if no error occured, false if it did

Definition at line 249 of file HTANG-driver.h.

long HTANGreadAccumulatedAngle ( tMUXSensor  muxsensor )

Return the accumulated angle (signed 32 bit value)

Parameters:
muxsensorthe SMUX sensor port number
Returns:
current angle or -1 if an error occurred.

Definition at line 155 of file HTANG-driver.h.

long HTANGreadAccumulatedAngle ( tSensors  link )

Return the accumulated angle (signed 32 bit value)

Parameters:
linkthe HTANG port number
Returns:
current angle or -1 if an error occurred.
Examples:
HTANG-SMUX-test1.c, and HTANG-test1.c.

Definition at line 129 of file HTANG-driver.h.

int HTANGreadAngle ( tSensors  link )

Return the current angle

Parameters:
linkthe HTANG port number
Returns:
current angle or -1 if an error occurred.
Examples:
HTANG-SMUX-test1.c, and HTANG-test1.c.

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

int HTANGreadAngle ( tMUXSensor  muxsensor )

Return the current angle

Parameters:
muxsensorthe SMUX sensor port number
Returns:
current angle or -1 if an error occurred.

Definition at line 109 of file HTANG-driver.h.

int HTANGreadRPM ( tMUXSensor  muxsensor )

Return the rpm that the shaft is currently rotating at

Parameters:
muxsensorthe SMUX sensor port number
Returns:
the current rpm of the shaft or -1 if an error occurred.

Definition at line 202 of file HTANG-driver.h.

int HTANGreadRPM ( tSensors  link )

Return the rpm that the shaft is currently rotating at

Parameters:
linkthe HTANG port number
Returns:
the current rpm of the shaft or -1 if an error occurred.
Examples:
HTANG-SMUX-test1.c, and HTANG-test1.c.

Definition at line 178 of file HTANG-driver.h.

bool HTANGresetAccumulatedAngle ( tSensors  link )

Reset the accumulated angle

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

Definition at line 236 of file HTANG-driver.h.

bool HTANGresetAngle ( tSensors  link )

Reset the 0 position to the current shaft angle.
Note: this will also reset the accumulated angle counter

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

Definition at line 226 of file HTANG-driver.h.


Variable Documentation

tConfigParams HTANG_config = {HTSMUX_CHAN_I2C, 8, 0x02, 0x42}

Array to hold SMUX config data for sensor

Definition at line 74 of file HTANG-driver.h.

Array to hold I2C reply data

Definition at line 78 of file HTANG-driver.h.

Array to hold I2C command data

Definition at line 77 of file HTANG-driver.h.