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

HDS Motor MUX
[Other]

Files

file  holitdata-motormux.h
 

Holit Data Systems Motor MUX driver.


Defines

#define HDMMUX_I2C_ADDR   0x02
#define HDMMUX_CMD_MOTOR   0x01
#define HDMMUX_CMD_ADDRCHNG   0x02
#define HDMMUX_CMD_RST_TACH_A   0x03
#define HDMMUX_CMD_RST_TACH_B   0x04
#define HDMMUX_CMD_RST_TACH_C   0x05
#define HDMMUX_MOTOR_A   0x01
#define HDMMUX_MOTOR_B   0x02
#define HDMMUX_MOTOR_C   0x03
#define HDMMUX_MOTOR_OTHER   0x04
#define HDMMUX_MOTOR_RIGHT   0x02
#define HDMMUX_MOTOR_LEFT   0x00
#define HDMMUX_ROT_FORWARD   (0x01 << 6)
#define HDMMUX_ROT_REVERSE   (0x02 << 6)
#define HDMMUX_ROT_STOP   (0x03 << 6)
#define HDMMUX_ROT_CONSTSPEED   (0x01 << 4)
#define HDMMUX_ROT_RAMPUP   (0x02 << 4)
#define HDMMUX_ROT_RAMPDOWN   (0x03 << 4)
#define HDMMUX_ROT_UNLIMITED   (0x00 << 2)
#define HDMMUX_ROT_DEGREES   (0x01 << 2)
#define HDMMUX_ROT_ROTATIONS   (0x02 << 2)
#define HDMMUX_ROT_SECONDS   (0x03 << 2)
#define HDMMUX_ROT_POWERCONTROL   (0x01 << 1)
#define HDMMUX_ROT_BRAKE   0x01
#define HDMMUX_ROT_FLOAT   0x00

Functions

void HDMMUXinit ()
bool HDMMUXreadStatus (tSensors link, ubyte &motorStatus, long &tachoA, long &tachoB, long &tachoC)
bool HDMMUXsendCommand (tSensors link, ubyte mode, ubyte channel, ubyte rotparams, long duration, byte power, byte steering)
bool HDMMotor (tMUXmotor muxmotor, byte power)
bool HDMotorStop (tMUXmotor muxmotor)
bool HDMotorStop (tMUXmotor muxmotor, bool brake)
void HDMMotorSetRotationTarget (tMUXmotor muxmotor, float rottarget)
void HDMMotorSetTimeTarget (tMUXmotor muxmotor, float timetarget)
void HDMMotorSetEncoderTarget (tMUXmotor muxmotor, long enctarget)
long HDMMotorEncoder (tMUXmotor muxmotor)
bool HDMMotorEncoderReset (tMUXmotor muxmotor)
bool HDMMotorEncoderResetAll (tSensors link)
bool HDMMotorBusy (tMUXmotor muxmotor)
void HDMMotorSetBrake (tMUXmotor muxmotor)
void HDMMotorSetFloat (tMUXmotor muxmotor)
void HDMMotorSetSpeedCtrl (tMUXmotor muxmotor, bool constspeed)
void HDMMotorSetRamping (tMUXmotor muxmotor, ubyte ramping)

Variables

tByteArray HDMMUX_I2CRequest
tByteArray HDMMUX_I2CReply

Detailed Description

Holit Data Systems Motor MUX


Define Documentation

#define HDMMUX_CMD_ADDRCHNG   0x02

Definition at line 58 of file holitdata-motormux.h.

#define HDMMUX_CMD_MOTOR   0x01

Definition at line 57 of file holitdata-motormux.h.

#define HDMMUX_CMD_RST_TACH_A   0x03

Definition at line 59 of file holitdata-motormux.h.

#define HDMMUX_CMD_RST_TACH_B   0x04

Definition at line 60 of file holitdata-motormux.h.

#define HDMMUX_CMD_RST_TACH_C   0x05

Definition at line 61 of file holitdata-motormux.h.

#define HDMMUX_I2C_ADDR   0x02

HDMMUX I2C device address

Definition at line 54 of file holitdata-motormux.h.

#define HDMMUX_MOTOR_A   0x01

Definition at line 64 of file holitdata-motormux.h.

#define HDMMUX_MOTOR_B   0x02

Definition at line 65 of file holitdata-motormux.h.

#define HDMMUX_MOTOR_C   0x03

Definition at line 66 of file holitdata-motormux.h.

#define HDMMUX_MOTOR_LEFT   0x00

Definition at line 70 of file holitdata-motormux.h.

#define HDMMUX_MOTOR_OTHER   0x04

Definition at line 68 of file holitdata-motormux.h.

#define HDMMUX_MOTOR_RIGHT   0x02

Definition at line 69 of file holitdata-motormux.h.

#define HDMMUX_ROT_BRAKE   0x01

Definition at line 88 of file holitdata-motormux.h.

#define HDMMUX_ROT_CONSTSPEED   (0x01 << 4)

Definition at line 77 of file holitdata-motormux.h.

#define HDMMUX_ROT_DEGREES   (0x01 << 2)

Definition at line 82 of file holitdata-motormux.h.

#define HDMMUX_ROT_FLOAT   0x00

Definition at line 89 of file holitdata-motormux.h.

#define HDMMUX_ROT_FORWARD   (0x01 << 6)

Definition at line 73 of file holitdata-motormux.h.

#define HDMMUX_ROT_POWERCONTROL   (0x01 << 1)

Definition at line 86 of file holitdata-motormux.h.

#define HDMMUX_ROT_RAMPDOWN   (0x03 << 4)

Definition at line 79 of file holitdata-motormux.h.

#define HDMMUX_ROT_RAMPUP   (0x02 << 4)

Definition at line 78 of file holitdata-motormux.h.

#define HDMMUX_ROT_REVERSE   (0x02 << 6)

Definition at line 74 of file holitdata-motormux.h.

#define HDMMUX_ROT_ROTATIONS   (0x02 << 2)

Definition at line 83 of file holitdata-motormux.h.

#define HDMMUX_ROT_SECONDS   (0x03 << 2)

Definition at line 84 of file holitdata-motormux.h.

#define HDMMUX_ROT_STOP   (0x03 << 6)

Definition at line 75 of file holitdata-motormux.h.

#define HDMMUX_ROT_UNLIMITED   (0x00 << 2)

Definition at line 81 of file holitdata-motormux.h.


Function Documentation

bool HDMMotor ( tMUXmotor  muxmotor,
byte  power 
)

Run motor with specified speed.

Parameters:
muxmotorthe motor-MUX motor
powerpower the amount of power to apply to the motor, value between -100 and +100
Returns:
true if no error occured, false if it did
Examples:
holitdata-motormux-test1.c, and holitdata-motormux-test2.c.

Definition at line 203 of file holitdata-motormux.h.

bool HDMMotorBusy ( tMUXmotor  muxmotor )

Check if the specified motor is running or not.

Parameters:
muxmotorthe motor-MUX motor
Returns:
true if the motor is still running, false if it's idle
Examples:
holitdata-motormux-test1.c, and holitdata-motormux-test2.c.

Definition at line 388 of file holitdata-motormux.h.

long HDMMotorEncoder ( tMUXmotor  muxmotor )

Fetch the current encoder value for specified motor channel

Parameters:
muxmotorthe motor-MUX motor
Returns:
the current value of the encoder

Definition at line 319 of file holitdata-motormux.h.

bool HDMMotorEncoderReset ( tMUXmotor  muxmotor )

Reset target encoder for specified motor channel, use only at the start of your program. If you are using the standard NXT wheels you will not run into problems with a wrap-around for the first 500kms or so.

Parameters:
muxmotorthe motor-MUX motor
Returns:
true if no error occured, false if it did

Definition at line 346 of file holitdata-motormux.h.

bool HDMMotorEncoderResetAll ( tSensors  link )

Reset all encoders on the specified motor-MUX. Use only at the start of your program. If you are using the standard NXT wheels you will not run into problems with a wrap-around for the first 500kms or so.

Parameters:
linkthe MMUX port number
Returns:
true if no error occured, false if it did
Examples:
holitdata-motormux-test1.c, and holitdata-motormux-test2.c.

Definition at line 368 of file holitdata-motormux.h.

void HDMMotorSetBrake ( tMUXmotor  muxmotor )

Set the stopping method for the specified motor to brake.

Parameters:
muxmotorthe motor-MUX motor
Examples:
holitdata-motormux-test1.c, and holitdata-motormux-test2.c.

Definition at line 409 of file holitdata-motormux.h.

void HDMMotorSetEncoderTarget ( tMUXmotor  muxmotor,
long  enctarget 
)

Set encoder target for specified mux motor.

Parameters:
muxmotorthe motor-MUX motor
enctargetthe encoder target value in degrees.
Returns:
true if no error occured, false if it did
Examples:
holitdata-motormux-test1.c.

Definition at line 307 of file holitdata-motormux.h.

void HDMMotorSetFloat ( tMUXmotor  muxmotor )

Set the stopping method for the specified motor to float.

Parameters:
muxmotorthe motor-MUX motor
Examples:
holitdata-motormux-test1.c.

Definition at line 419 of file holitdata-motormux.h.

void HDMMotorSetRamping ( tMUXmotor  muxmotor,
ubyte  ramping 
)

Set the motor ramping type the specified motor. ramping can be one of

  • HDMMUX_ROT_CONSTSPEED
  • HDMMUX_ROT_RAMPUP
  • HDMMUX_ROT_RAMPDOWN
Parameters:
muxmotorthe motor-MUX motor
rampingthe type of ramping to be used

Definition at line 445 of file holitdata-motormux.h.

void HDMMotorSetRotationTarget ( tMUXmotor  muxmotor,
float  rottarget 
)

Set rotation target for specified mux motor. Rotations can be specified in increments of 0.01. To rotate the motor 10.54 degrees, specify a value of 10.54.

Parameters:
muxmotorthe motor-MUX motor
rottargetthe rotation target value
Returns:
true if no error occured, false if it did
Examples:
holitdata-motormux-test1.c.

Definition at line 280 of file holitdata-motormux.h.

void HDMMotorSetSpeedCtrl ( tMUXmotor  muxmotor,
bool  constspeed 
)

Set the motor speed control for the specified motor.

Parameters:
muxmotorthe motor-MUX motor
constspeedwhether or not to use speed control

Definition at line 430 of file holitdata-motormux.h.

void HDMMotorSetTimeTarget ( tMUXmotor  muxmotor,
float  timetarget 
)

Set time target for specified mux motor. Seconds can be specified in increments of 0.01. To rotate the motor for 10.21 seconds, specify a value of 10.21.

Parameters:
muxmotorthe motor-MUX motor
timetargetthe time target value in seconds.
Returns:
true if no error occured, false if it did
Examples:
holitdata-motormux-test1.c, and holitdata-motormux-test2.c.

Definition at line 294 of file holitdata-motormux.h.

void HDMMUXinit (  )
bool HDMMUXreadStatus ( tSensors  link,
ubyte &  motorStatus,
long &  tachoA,
long &  tachoB,
long &  tachoC 
)

Read the status of the motors and tacho counts of the MMUX

motorStatus is made of 3 bits, 1: motor is running, 0: motor is idle
bit 0: motor A
bit 1: motor B
bit 2: motor C

Parameters:
linkthe MMUX port number
motorStatusstatus of the motors
tachoATacho count for motor A
tachoBTacho count for motor B
tachoCTacho count for motor C
Returns:
true if no error occured, false if it did
Examples:
holitdata-motormux-test1.c, and holitdata-motormux-test2.c.

Definition at line 144 of file holitdata-motormux.h.

bool HDMMUXsendCommand ( tSensors  link,
ubyte  mode,
ubyte  channel,
ubyte  rotparams,
long  duration,
byte  power,
byte  steering 
)

Send a command to the MMUX.

Note: this is an internal function and shouldn't be used directly

Parameters:
linkthe MMUX port number
modethe mode the MMX should operate in, controlling motors, resetting tachos or settings new address
channelthe motors the command applies to
rotparamsthe additional parameters that make up the command
durationthe number of units (can be seconds, rotations or degrees) the command should be run for
powerthe amount of power to be applied to the motor(s)
steeringused for syncronised movement to control the amount of steering
Returns:
true if no error occured, false if it did

Definition at line 177 of file holitdata-motormux.h.

bool HDMotorStop ( tMUXmotor  muxmotor,
bool  brake 
)

Stop the motor. This function overrides the preconfigured braking method.

Parameters:
muxmotorthe motor-MUX motor
brakewhen set to true: use brake, false: use float
Returns:
true if no error occured, false if it did

Definition at line 255 of file holitdata-motormux.h.

bool HDMotorStop ( tMUXmotor  muxmotor )

Stop the motor. Uses the brake method specified with HDMMotorSetBrake or HDMMotorSetFloat. The default is to use braking.

Parameters:
muxmotorthe motor-MUX motor
Returns:
true if no error occured, false if it did

Definition at line 231 of file holitdata-motormux.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 92 of file holitdata-motormux.h.

Array to hold I2C command data

Definition at line 91 of file holitdata-motormux.h.