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  hitechnic-irlink.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, ubyte channel, ubyte _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 58 of file hitechnic-irlink.h.

#define BUF_HEADSIZE   3

I2C buff size, address and register

Definition at line 57 of file hitechnic-irlink.h.

#define BUF_TAILSIZE   3

IR data length, IR Link mode and start transmission

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

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

Definition at line 65 of file hitechnic-irlink.h.

#define PFMOT (   X )    X % 2

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

#define PFSPORT (   X )    X / 8

Definition at line 64 of file hitechnic-irlink.h.

#define START_DATA   3

index of start of data payload

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

#define START_HEAD   0

index of start of header

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

#define START_TAIL   15

index of start of tail

Definition at line 62 of file hitechnic-irlink.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 128 of file hitechnic-irlink.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 108 of file hitechnic-irlink.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 71 of file hitechnic-irlink.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 179 of file hitechnic-irlink.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 156 of file hitechnic-irlink.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 344 of file hitechnic-irlink.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:
hitechnic-irlink-test1.c.

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

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

Definition at line 332 of file hitechnic-irlink.h.

void PFsinglePinOutputMode ( tSensors  link,
ubyte  channel,
ubyte  _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

Definition at line 295 of file hitechnic-irlink.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 391 of file hitechnic-irlink.h.


Variable Documentation

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

Motor connections

Definition at line 68 of file hitechnic-irlink.h.