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

IR Link Sensor
[HiTechnic]

Files

file  HTIRL-driver.h
 

HiTechnic IR Link Sensor driver.


Defines

#define BUF_HEADSIZE   3
#define BUF_DATASIZE   11
#define BUF_TAILSIZE   3
#define START_HEAD   0
#define START_DATA   3
#define START_TAIL   15
#define PFSPORT(X)   X / 8
#define PFCHAN(X)   (X % 8) / 2
#define PFMOT(X)   X % 2

Enumerations

enum  tPFmotor {
  pfmotor_S1_C1_A = 0, pfmotor_S1_C1_B, pfmotor_S1_C2_A, pfmotor_S1_C2_B,
  pfmotor_S1_C3_A, pfmotor_S1_C3_B, pfmotor_S1_C4_A, pfmotor_S1_C4_B,
  pfmotor_S2_C1_A, pfmotor_S2_C1_B, pfmotor_S2_C2_A, pfmotor_S2_C2_B,
  pfmotor_S2_C3_A, pfmotor_S2_C3_B, pfmotor_S2_C4_A, pfmotor_S2_C4_B,
  pfmotor_S3_C1_A, pfmotor_S3_C1_B, pfmotor_S3_C2_A, pfmotor_S3_C2_B,
  pfmotor_S3_C3_A, pfmotor_S3_C3_B, pfmotor_S3_C4_A, pfmotor_S3_C4_B,
  pfmotor_S4_C1_A, pfmotor_S4_C1_B, pfmotor_S4_C2_A, pfmotor_S4_C2_B,
  pfmotor_S4_C3_A, pfmotor_S4_C3_B, pfmotor_S4_C4_A, pfmotor_S4_C4_B
}
enum  ePWMMotorCommand {
  MOTOR_FLOAT = 0, MOTOR_FWD_PWM_1 = 1, MOTOR_FWD_PWM_2 = 2, MOTOR_FWD_PWM_3 = 3,
  MOTOR_FWD_PWM_4 = 4, MOTOR_FWD_PWM_5 = 5, MOTOR_FWD_PWM_6 = 6, MOTOR_FWD_PWM_7 = 7,
  MOTOR_BRAKE = 8, MOTOR_REV_PWM_7 = 9, MOTOR_REV_PWM_6 = 10, MOTOR_REV_PWM_5 = 11,
  MOTOR_REV_PWM_4 = 12, MOTOR_REV_PWM_3 = 13, MOTOR_REV_PWM_2 = 14, MOTOR_REV_PWM_1 = 15
}
enum  eCDMMotorCommand { CDM_MOTOR_FLOAT = 0, CDM_MOTOR_FWD = 1, CDM_MOTOR_BAK = 2, CDM_MOTOR_BRAKE = 3 }

Functions

void PFcomboDirectMode (tSensors link, int channel, eCDMMotorCommand _motorB, eCDMMotorCommand _motorA)
void PFcomboPwmMode (tSensors link, int channel, ePWMMotorCommand _motorB, ePWMMotorCommand _motorA)
void encodeBuffer (tByteArray &iBuffer, tByteArray &oBuffer)
void transmitIR (tSensors link, tByteArray &oBuffer, int channel)
void decToBin (int number, int length, string &output)
void debugIR (tByteArray &data)
void PFsinglePinOutputMode (tSensors link, byte channel, byte _motor, ePWMMotorCommand _motorCmd)
void PFMotor (tPFmotor pfmotor, ePWMMotorCommand _motorCmd)

Variables

byte toggle [4] = {0, 0, 0, 0}

Detailed Description

HiTechnic IR Link Sensor driver


Define Documentation

#define BUF_DATASIZE   11

max size of encoded buffer

Definition at line 57 of file HTIRL-driver.h.

#define BUF_HEADSIZE   3

I2C buff size, address and register

Definition at line 56 of file HTIRL-driver.h.

#define BUF_TAILSIZE   3

IR data length, IR Link mode and start transmission

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

#define PFCHAN (   X )    (X % 8) / 2

Definition at line 64 of file HTIRL-driver.h.

#define PFMOT (   X )    X % 2

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

#define PFSPORT (   X )    X / 8

Definition at line 63 of file HTIRL-driver.h.

#define START_DATA   3

index of start of data payload

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

#define START_HEAD   0

index of start of header

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

#define START_TAIL   15

index of start of tail

Definition at line 61 of file HTIRL-driver.h.


Enumeration Type Documentation

Enumerator:
CDM_MOTOR_FLOAT 

Float the motor

CDM_MOTOR_FWD 

Forward

CDM_MOTOR_BAK 

Reverse

CDM_MOTOR_BRAKE 

Brake the motor

Definition at line 127 of file HTIRL-driver.h.

Enumerator:
MOTOR_FLOAT 

Float the motor

MOTOR_FWD_PWM_1 

Forward speed 1

MOTOR_FWD_PWM_2 

Forward speed 2

MOTOR_FWD_PWM_3 

Forward speed 3

MOTOR_FWD_PWM_4 

Forward speed 4

MOTOR_FWD_PWM_5 

Forward speed 5

MOTOR_FWD_PWM_6 

Forward speed 6

MOTOR_FWD_PWM_7 

Forward speed 7

MOTOR_BRAKE 

Brake the motor

MOTOR_REV_PWM_7 

Reverse speed 7

MOTOR_REV_PWM_6 

Reverse speed 6

MOTOR_REV_PWM_5 

Reverse speed 5

MOTOR_REV_PWM_4 

Reverse speed 4

MOTOR_REV_PWM_3 

Reverse speed 3

MOTOR_REV_PWM_2 

Reverse speed 2

MOTOR_REV_PWM_1 

Reverse speed 1

Definition at line 107 of file HTIRL-driver.h.

enum tPFmotor
Enumerator:
pfmotor_S1_C1_A 

Motor A, Channel 1, IR Link connected to S1

pfmotor_S1_C1_B 

Motor B, Channel 1, IR Link connected to S1

pfmotor_S1_C2_A 

Motor A, Channel 2, IR Link connected to S1

pfmotor_S1_C2_B 

Motor B, Channel 2, IR Link connected to S1

pfmotor_S1_C3_A 

Motor A, Channel 3, IR Link connected to S1

pfmotor_S1_C3_B 

Motor B, Channel 3, IR Link connected to S1

pfmotor_S1_C4_A 

Motor A, Channel 4, IR Link connected to S1

pfmotor_S1_C4_B 

Motor B, Channel 4, IR Link connected to S1

pfmotor_S2_C1_A 

Motor A, Channel 1, IR Link connected to S2

pfmotor_S2_C1_B 

Motor B, Channel 1, IR Link connected to S2

pfmotor_S2_C2_A 

Motor A, Channel 2, IR Link connected to S2

pfmotor_S2_C2_B 

Motor B, Channel 2, IR Link connected to S2

pfmotor_S2_C3_A 

Motor A, Channel 3, IR Link connected to S2

pfmotor_S2_C3_B 

Motor B, Channel 3, IR Link connected to S2

pfmotor_S2_C4_A 

Motor A, Channel 4, IR Link connected to S2

pfmotor_S2_C4_B 

Motor B, Channel 4, IR Link connected to S2

pfmotor_S3_C1_A 

Motor A, Channel 1, IR Link connected to S3

pfmotor_S3_C1_B 

Motor B, Channel 1, IR Link connected to S3

pfmotor_S3_C2_A 

Motor A, Channel 2, IR Link connected to S3

pfmotor_S3_C2_B 

Motor B, Channel 2, IR Link connected to S3

pfmotor_S3_C3_A 

Motor A, Channel 3, IR Link connected to S3

pfmotor_S3_C3_B 

Motor B, Channel 3, IR Link connected to S3

pfmotor_S3_C4_A 

Motor A, Channel 4, IR Link connected to S3

pfmotor_S3_C4_B 

Motor B, Channel 4, IR Link connected to S3

pfmotor_S4_C1_A 

Motor A, Channel 1, IR Link connected to S4

pfmotor_S4_C1_B 

Motor B, Channel 1, IR Link connected to S4

pfmotor_S4_C2_A 

Motor A, Channel 2, IR Link connected to S4

pfmotor_S4_C2_B 

Motor B, Channel 2, IR Link connected to S4

pfmotor_S4_C3_A 

Motor A, Channel 3, IR Link connected to S4

pfmotor_S4_C3_B 

Motor B, Channel 3, IR Link connected to S4

pfmotor_S4_C4_A 

Motor A, Channel 4, IR Link connected to S4

pfmotor_S4_C4_B 

Motor B, Channel 4, IR Link connected to S4

Definition at line 70 of file HTIRL-driver.h.


Function Documentation

void debugIR ( tByteArray data )

Print out the buffer in question to the screen using the following format:

<index> <binary reprentation> <hex representation>

0 11001100 0xCC

It pauses for 10 seconds between each screenful, accompanied by a beep.

Note: this function is only available when driver is compiled with _DEBUG_DRIVER_ defined.

Parameters:
datathe data to be displayed as binary/hex numbers

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

void decToBin ( int  number,
int  length,
string &  output 
)

Returns a binary representation in a string of an int with specified length

Note: this function is only available when driver is compiled with _DEBUG_DRIVER_ defined.

Parameters:
numberthe number to be converted to a binary representation
lengthnumber of bits to convert
outputthe number converted to binary representation

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

void encodeBuffer ( tByteArray iBuffer,
tByteArray oBuffer 
)

Encode the input buffer into a special format for the IRLink.

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

Parameters:
iBufferthe data that is be encoded
oBufferoutput buffer for encoded data

Definition at line 343 of file HTIRL-driver.h.

void PFcomboDirectMode ( tSensors  link,
int  channel,
eCDMMotorCommand  _motorB,
eCDMMotorCommand  _motorA 
)

Control two motors using the ComboDirectMode. This mode does not allow for fine grained speed control.

Parameters:
linkthe sensor port number
channelthe channel of the receiver we wish to communicate with, numbered 0-3
_motorBthe command to be sent to Motor B
_motorAthe command to be sent to Motor A
Examples:
HTIRL-test1.c.

Definition at line 203 of file HTIRL-driver.h.

void PFcomboPwmMode ( tSensors  link,
int  channel,
ePWMMotorCommand  _motorB,
ePWMMotorCommand  _motorA 
)

Control two motors using the ComboPWMMode. This mode allows for fine grained speed control.

Parameters:
linkthe sensor port number
channelthe channel of the receiver we wish to communicate with, numbered 0-3
_motorBthe command to be sent to Motor B
_motorAthe command to be sent to Motor A
Examples:
HTIRL-test1.c.

Definition at line 248 of file HTIRL-driver.h.

void PFMotor ( tPFmotor  pfmotor,
ePWMMotorCommand  _motorCmd 
)

Control one motor with no timeout. This mode allows for fine grained speed control.

Parameters:
pfmotorthe motor to which to send the command
_motorCmdthe command to send to the motor, 0-15
Examples:
HTIRL-test1.c.

Definition at line 331 of file HTIRL-driver.h.

void PFsinglePinOutputMode ( tSensors  link,
byte  channel,
byte  _motor,
ePWMMotorCommand  _motorCmd 
)

Control one motor with no timeout. This mode allows for fine grained speed control.

Parameters:
linkthe sensor port number
channelthe channel of the receiver we wish to communicate with, numbered 0-3
_motorthe motor to be controlled, 0 or 1, for A or B
_motorCmdthe command to send to the motor, 0-15
Examples:
HTIRL-test1.c.

Definition at line 294 of file HTIRL-driver.h.

void transmitIR ( tSensors  link,
tByteArray oBuffer,
int  channel 
)

Send the command to the IRLink Sensor for transmission.

Note: this is an internal function and should not be called directly. If the driver is compiled with _DEBUG_DRIVER_, this function will call debugIR() prior to transmitting the data for debugging purposes.

Parameters:
linkthe sensor port number
oBufferthe data that is be transmitted
channelthe channel number of the receiver

Definition at line 390 of file HTIRL-driver.h.


Variable Documentation

byte toggle[4] = {0, 0, 0, 0}

Motor connections

Definition at line 67 of file HTIRL-driver.h.