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  hitechnic-angle.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 54 of file hitechnic-angle.h.

#define HTANG_ACC_ANG_B2   0x04

32 bit accumulated angle 2nd byte

Definition at line 53 of file hitechnic-angle.h.

#define HTANG_ACC_ANG_B3   0x03

32 bit accumulated angle 3rd byte

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

#define HTANG_ACC_ANG_B4   0x02

32 bit accumulated angle 4th byte

Definition at line 51 of file hitechnic-angle.h.

#define HTANG_ANG1   0x01

Current angle (1 deg adder)

Definition at line 50 of file hitechnic-angle.h.

#define HTANG_ANG2   0x00

Current angle (2 deg increments)

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

#define HTANG_CMD_MEASURE   0x00

Normal angle measurement mode

Definition at line 59 of file hitechnic-angle.h.

#define HTANG_CMD_REG   0x41

Command register

Definition at line 45 of file hitechnic-angle.h.

#define HTANG_CMD_RST_ACC_ANG   0x52

Resets the accumulated angle

Definition at line 61 of file hitechnic-angle.h.

#define HTANG_CMD_RST_ANG   0x43

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

Definition at line 60 of file hitechnic-angle.h.

#define HTANG_I2C_ADDR   0x02

HTCS2 I2C device address

Definition at line 44 of file hitechnic-angle.h.

#define HTANG_OFFSET   0x42

Offset for data registers

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

#define HTANG_RPM_H   0x06

16 bit rpms, high byte

Definition at line 55 of file hitechnic-angle.h.

#define HTANG_RPM_L   0x07

16 bit rpms, low byte

Definition at line 56 of file hitechnic-angle.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 241 of file hitechnic-angle.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 150 of file hitechnic-angle.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:
hitechnic-angle-SMUX-test1.c, and hitechnic-angle-test1.c.

Definition at line 127 of file hitechnic-angle.h.

int HTANGreadAngle ( tSensors  link )

Return the current angle

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

Definition at line 87 of file hitechnic-angle.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 107 of file hitechnic-angle.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 194 of file hitechnic-angle.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:
hitechnic-angle-SMUX-test1.c, and hitechnic-angle-test1.c.

Definition at line 173 of file hitechnic-angle.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:
hitechnic-angle-test1.c.

Definition at line 228 of file hitechnic-angle.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:
hitechnic-angle-test1.c.

Definition at line 218 of file hitechnic-angle.h.


Variable Documentation

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

Array to hold SMUX config data for sensor

Definition at line 75 of file hitechnic-angle.h.

Array to hold I2C reply data

Definition at line 79 of file hitechnic-angle.h.

Array to hold I2C command data

Definition at line 78 of file hitechnic-angle.h.