NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
NXTMMX Class Reference

This class interfaces with NXTMMX attached to NXShield. More...

#include <NXTMMX.h>

Inheritance diagram for NXTMMX:
NXShieldI2C BaseI2CDevice SoftI2cMaster

Public Member Functions

 NXTMMX (uint8_t i2c_address=0x06)
 
uint8_t getBatteryVoltage ()
 
uint8_t issueCommand (char command)
 
bool setEncoderTarget (uint8_t which_motor, long target)
 
long getEncoderTarget (uint8_t which_motor)
 
bool setSpeed (uint8_t which_motor, int speed)
 
int8_t getSpeed (uint8_t which_motor)
 
bool getTimeToRun (uint8_t which_motor, int seconds)
 
uint8_t getTimeToRun (uint8_t which_motor)
 
bool setCommandRegB (uint8_t which_motor, uint8_t value)
 
uint8_t getCommandRegB (uint8_t which_motor)
 
bool setCommandRegA (uint8_t which_motor, uint8_t value)
 
uint8_t getCommandRegA (uint8_t which_motor)
 
int32_t getEncoderPosition (uint8_t which_motor)
 
uint8_t getMotorStatusByte (uint8_t which_motor)
 
uint8_t getMotorTasksRunningByte (uint8_t which_motor)
 
bool setEncoderPID (uint16_t Kp, uint16_t Ki, uint16_t Kd)
 
bool setSpeedPID (uint16_t Kp, uint16_t Ki, uint16_t Kd)
 
bool setPassCount (uint8_t pass_count)
 
bool setTolerance (uint8_t tolerance)
 
bool reset ()
 
bool startMotorsInSync ()
 
bool resetEncoder (uint8_t which_motor)
 
bool setSpeedTimeAndControl (uint8_t which_motors, int speed, uint8_t duration, uint8_t control)
 
bool setEncoderSpeedTimeAndControl (uint8_t which_motors, long encoder, int speed, uint8_t duration, uint8_t control)
 
bool isTimeDone (uint8_t which_motors)
 
void waitUntilTimeDone (uint8_t which_motors)
 
bool isTachoDone (uint8_t which_motors)
 
void waitUntilTachoDone (uint8_t which_motors)
 
void runUnlimited (uint8_t which_motors, uint8_t direction, int speed)
 
void runSeconds (uint8_t which_motors, uint8_t direction, int speed, uint8_t duration, uint8_t wait_for_completion, uint8_t next_action)
 
void runTachometer (uint8_t which_motors, uint8_t direction, int speed, long tachometer, uint8_t relative, uint8_t wait_for_completion, uint8_t next_action)
 
void runDegrees (uint8_t which_motors, uint8_t direction, int speed, long degrees, uint8_t wait_for_completion, uint8_t next_action)
 
void runRotations (uint8_t which_motors, uint8_t direction, int speed, long rotations, uint8_t wait_for_completion, uint8_t next_action)
 
bool stop (uint8_t which_motors, uint8_t next_action)
 
- Public Member Functions inherited from NXShieldI2C
 NXShieldI2C (uint8_t i2c_address)
 
void init (void *shield, SH_BankPort bp)
 
uint8_t readByte (uint8_t location)
 
uint16_t readInteger (uint8_t location)
 
uint32_t readLong (uint8_t location)
 
uint8_t * readRegisters (uint8_t start_register, uint8_t bytes, uint8_t *buf)
 
char * readString (uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
 
bool writeRegisters (uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
 
bool writeByte (uint8_t location, uint8_t data)
 
bool writeInteger (uint8_t location, uint16_t data)
 
bool writeLong (uint8_t location, uint32_t data)
 
char * getFirmwareVersion ()
 
char * getVendorID ()
 
char * getDeviceID ()
 
char * getFeatureSet ()
 
uint8_t getErrorCode ()
 
bool checkAddress ()
 
bool setAddress (uint8_t address)
 
- Public Member Functions inherited from BaseI2CDevice
 BaseI2CDevice (uint8_t i2c_address)
 
void initProtocol ()
 
uint8_t * readRegisters (uint8_t start_register, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0, bool clear_buffer=false)
 
uint8_t readByte (uint8_t location)
 
int16_t readInteger (uint8_t location)
 
uint32_t readLong (uint8_t location)
 
char * readString (uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
 
bool writeRegisters (uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
 
bool writeByte (uint8_t location, uint8_t data)
 
bool writeInteger (uint8_t location, uint16_t data)
 
bool writeLong (uint8_t location, uint32_t data)
 
bool checkAddress ()
 
bool setAddress (uint8_t i2c_address)
 
uint8_t getAddress ()
 
uint8_t getWriteErrorCode ()
 
char * getFirmwareVersion ()
 
char * getVendorID ()
 
char * getDeviceID ()
 
char * getFeatureSet ()
 
- Public Member Functions inherited from SoftI2cMaster
uint8_t start (uint8_t addressRW)
 
void stop (void)
 
uint8_t restart (uint8_t addressRW)
 
uint8_t write (uint8_t b)
 
uint8_t read (uint8_t last)
 
 SoftI2cMaster (uint8_t devAddr)
 
void initProtocol (uint8_t sclPin=NULL, uint8_t sdaPin=NULL)
 
uint8_t * readRegisters (uint8_t startRegister, uint8_t bytes, uint8_t *buf=NULL)
 
bool writeRegistersWithLocation (int bytes, uint8_t *buf)
 
bool writeRegisters (uint8_t location, uint8_t bytes_to_write, uint8_t *buffer=0)
 
bool writeByte (uint8_t location, uint8_t data)
 
bool writeInteger (uint8_t location, uint16_t data)
 
bool writeLong (uint8_t location, uint32_t data)
 
char * readString (uint8_t startRegister, uint8_t bytes, uint8_t *buf=NULL, uint8_t len=0)
 
uint8_t readByte (uint8_t location)
 
int16_t readInteger (uint8_t location)
 
uint32_t readLong (uint8_t location)
 
char * getFirmwareVersion ()
 
char * getVendorID ()
 
char * getDeviceID ()
 
uint8_t getWriteErrorCode ()
 
bool checkAddress ()
 
bool setAddress (uint8_t address)
 

Additional Inherited Members

- Public Attributes inherited from NXShieldI2C
void * mp_shield
 
uint8_t * _i2c_buffer
 
uint8_t m_protocol
 
- Public Attributes inherited from SoftI2cMaster
uint8_t * _so_buffer
 
- Static Public Attributes inherited from BaseI2CDevice
static uint8_t * _buffer = 0
 
static bool b_initialized = false
 
- Protected Member Functions inherited from BaseI2CDevice
void setWriteErrorCode (uint8_t code)
 

Detailed Description

This class interfaces with NXTMMX attached to NXShield.

Constructor & Destructor Documentation

NXTMMX::NXTMMX ( uint8_t  i2c_address = 0x06)

constructor for NXTMMX

Member Function Documentation

uint8_t NXTMMX::getBatteryVoltage ( )

get the battery voltage for the MMX

int32_t NXTMMX::getEncoderPosition ( uint8_t  which_motor)

get the current encoder position of the motor in degrees

long NXTMMX::getEncoderTarget ( uint8_t  which_motor)

get the target encoder position for the motor

uint8_t NXTMMX::getMotorStatusByte ( uint8_t  which_motor)

get the current status of the motor

uint8_t NXTMMX::getMotorTasksRunningByte ( uint8_t  which_motor)

get the tasks that are running on the specific motor

int8_t NXTMMX::getSpeed ( uint8_t  which_motor)

get the speed of the motor

bool NXTMMX::getTimeToRun ( uint8_t  which_motor,
int  seconds 
)

set the time in seconds for which the motor should run for

uint8_t NXTMMX::getTimeToRun ( uint8_t  which_motor)

get the time in seconds that the motor is running for

uint8_t NXTMMX::issueCommand ( char  command)

issue a command to this bank of the NXTMMX

bool NXTMMX::isTachoDone ( uint8_t  which_motors)

validate if the motor has reached its set target tachometer position

bool NXTMMX::isTimeDone ( uint8_t  which_motors)

validate if the motor has finished running for the set time duration

bool NXTMMX::reset ( )

reset all the set values for the motors

bool NXTMMX::resetEncoder ( uint8_t  which_motor)

reset the current encoder position to zero for the motor

void NXTMMX::runDegrees ( uint8_t  which_motors,
uint8_t  direction,
int  speed,
long  degrees,
uint8_t  wait_for_completion,
uint8_t  next_action 
)

run the motor for a set number of degrees and proceed to the next action

void NXTMMX::runRotations ( uint8_t  which_motors,
uint8_t  direction,
int  speed,
long  rotations,
uint8_t  wait_for_completion,
uint8_t  next_action 
)

run the motor for a set number of complete rotations and proceed to the next action

void NXTMMX::runSeconds ( uint8_t  which_motors,
uint8_t  direction,
int  speed,
uint8_t  duration,
uint8_t  wait_for_completion,
uint8_t  next_action 
)

run the motor for a set duration at a set speed and do the next action

void NXTMMX::runTachometer ( uint8_t  which_motors,
uint8_t  direction,
int  speed,
long  tachometer,
uint8_t  relative,
uint8_t  wait_for_completion,
uint8_t  next_action 
)

run until the tachometer target has been reached and do next action

void NXTMMX::runUnlimited ( uint8_t  which_motors,
uint8_t  direction,
int  speed 
)

run the motor endlessly at the desired speed in the desired direction

bool NXTMMX::setEncoderPID ( uint16_t  Kp,
uint16_t  Ki,
uint16_t  Kd 
)

set the PID control for the encoders

bool NXTMMX::setEncoderSpeedTimeAndControl ( uint8_t  which_motors,
long  encoder,
int  speed,
uint8_t  duration,
uint8_t  control 
)

set the ratget encoder position, speed, duration to run, and control for the motor

bool NXTMMX::setEncoderTarget ( uint8_t  which_motor,
long  target 
)

set the target encoder position for the motor

bool NXTMMX::setPassCount ( uint8_t  pass_count)

set how many times the PID controller is allowed to oscillate about the set point

bool NXTMMX::setSpeed ( uint8_t  which_motor,
int  speed 
)

set the speed of the motor

bool NXTMMX::setSpeedPID ( uint16_t  Kp,
uint16_t  Ki,
uint16_t  Kd 
)

set the PID control for the speed of the motors

bool NXTMMX::setSpeedTimeAndControl ( uint8_t  which_motors,
int  speed,
uint8_t  duration,
uint8_t  control 
)

set the speed, duration to run, and control for the motor

bool NXTMMX::setTolerance ( uint8_t  tolerance)

set how far away from the set point the PID controller is allowed to oscillate (amplitude)

bool NXTMMX::startMotorsInSync ( )

start both motors at the same time to follow the set conditions

bool NXTMMX::stop ( uint8_t  which_motors,
uint8_t  next_action 
)

stop the motor and do an action

void NXTMMX::waitUntilTachoDone ( uint8_t  which_motors)

wait until the motor has reached its set target tachometer position

void NXTMMX::waitUntilTimeDone ( uint8_t  which_motors)

wait until the motor has finished running for its set respective time duration


The documentation for this class was generated from the following files: