|
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 |
Holit Data Systems Motor MUX
#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.
bool HDMMotor | ( | tMUXmotor | muxmotor, |
byte | power | ||
) |
Run motor with specified speed.
muxmotor | the motor-MUX motor |
power | power the amount of power to apply to the motor, value between -100 and +100 |
Definition at line 203 of file holitdata-motormux.h.
bool HDMMotorBusy | ( | tMUXmotor | muxmotor ) |
Check if the specified motor is running or not.
muxmotor | the motor-MUX motor |
Definition at line 388 of file holitdata-motormux.h.
long HDMMotorEncoder | ( | tMUXmotor | muxmotor ) |
Fetch the current encoder value for specified motor channel
muxmotor | the motor-MUX motor |
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.
muxmotor | the motor-MUX motor |
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.
link | the MMUX port number |
Definition at line 368 of file holitdata-motormux.h.
void HDMMotorSetBrake | ( | tMUXmotor | muxmotor ) |
Set the stopping method for the specified motor to brake.
muxmotor | the motor-MUX motor |
Definition at line 409 of file holitdata-motormux.h.
void HDMMotorSetEncoderTarget | ( | tMUXmotor | muxmotor, |
long | enctarget | ||
) |
Set encoder target for specified mux motor.
muxmotor | the motor-MUX motor |
enctarget | the encoder target value in degrees. |
Definition at line 307 of file holitdata-motormux.h.
void HDMMotorSetFloat | ( | tMUXmotor | muxmotor ) |
Set the stopping method for the specified motor to float.
muxmotor | the motor-MUX motor |
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
muxmotor | the motor-MUX motor |
ramping | the 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.
muxmotor | the motor-MUX motor |
rottarget | the rotation target value |
Definition at line 280 of file holitdata-motormux.h.
void HDMMotorSetSpeedCtrl | ( | tMUXmotor | muxmotor, |
bool | constspeed | ||
) |
Set the motor speed control for the specified motor.
muxmotor | the motor-MUX motor |
constspeed | whether 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.
muxmotor | the motor-MUX motor |
timetarget | the time target value in seconds. |
Definition at line 294 of file holitdata-motormux.h.
void HDMMUXinit | ( | ) |
Definition at line 116 of file holitdata-motormux.h.
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
link | the MMUX port number |
motorStatus | status of the motors |
tachoA | Tacho count for motor A |
tachoB | Tacho count for motor B |
tachoC | Tacho count for motor 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
link | the MMUX port number |
mode | the mode the MMX should operate in, controlling motors, resetting tachos or settings new address |
channel | the motors the command applies to |
rotparams | the additional parameters that make up the command |
duration | the number of units (can be seconds, rotations or degrees) the command should be run for |
power | the amount of power to be applied to the motor(s) |
steering | used for syncronised movement to control the amount of steering |
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.
muxmotor | the motor-MUX motor |
brake | when set to true: use brake, false: use float |
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.
muxmotor | the motor-MUX motor |
Definition at line 231 of file holitdata-motormux.h.
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.