| EVShield v1.3 EVShield Library Reference by mindsensors.com

Public Member Functions | List of all members
EVs_NXTMMX Class Reference

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

`#include <EVs_NXTMMX.h>`

Inheritance diagram for EVs_NXTMMX:

## Public Member Functions
| EVs_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 EVShieldI2C
| EVShieldI2C (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=(uint8_t) NULL, uint8_t sdaPin=(uint8_t) 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 EVShieldI2C
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 EVShield.

## Constructor & Destructor Documentation

## § EVs_NXTMMX()

EVs_NXTMMX::EVs_NXTMMX | ( | uint8_t | i2c_address = `0x06` | ) |

constructor for NXTMMX

## Member Function Documentation

## § getBatteryVoltage()

uint8_t EVs_NXTMMX::getBatteryVoltage | ( |  | ) |

get the battery voltage for the MMX

## § getEncoderPosition()

int32_t EVs_NXTMMX::getEncoderPosition | ( | uint8_t | which_motor | ) |

get the current encoder position of the motor in degrees

## § getEncoderTarget()

long EVs_NXTMMX::getEncoderTarget | ( | uint8_t | which_motor | ) |

get the target encoder position for the motor

## § getMotorStatusByte()

uint8_t EVs_NXTMMX::getMotorStatusByte | ( | uint8_t | which_motor | ) |

get the current status of the motor

## § getMotorTasksRunningByte()

uint8_t EVs_NXTMMX::getMotorTasksRunningByte | ( | uint8_t | which_motor | ) |

get the tasks that are running on the specific motor

## § getSpeed()

int8_t EVs_NXTMMX::getSpeed | ( | uint8_t | which_motor | ) |

get the speed of the motor

## § getTimeToRun() [1/2]

bool EVs_NXTMMX::getTimeToRun | ( | uint8_t | which_motor,
|  | int | seconds
| ) |  |

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

## § getTimeToRun() [2/2]

uint8_t EVs_NXTMMX::getTimeToRun | ( | uint8_t | which_motor | ) |

get the time in seconds that the motor is running for

## § issueCommand()

uint8_t EVs_NXTMMX::issueCommand | ( | char | command | ) |

issue a command to this bank of the NXTMMX

## § isTachoDone()

bool EVs_NXTMMX::isTachoDone | ( | uint8_t | which_motors | ) |

validate if the motor has reached its set target tachometer position

## § isTimeDone()

bool EVs_NXTMMX::isTimeDone | ( | uint8_t | which_motors | ) |

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

## § reset()

bool EVs_NXTMMX::reset | ( |  | ) |

reset all the set values for the motors

## § resetEncoder()

bool EVs_NXTMMX::resetEncoder | ( | uint8_t | which_motor | ) |

reset the current encoder position to zero for the motor

## § runDegrees()

void EVs_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

## § runRotations()

void EVs_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

## § runSeconds()

void EVs_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

## § runTachometer()

void EVs_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

## § runUnlimited()

void EVs_NXTMMX::runUnlimited | ( | uint8_t | which_motors,
|  | uint8_t | direction,
|  | int | speed
| ) |  |

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

## § setEncoderPID()

bool EVs_NXTMMX::setEncoderPID | ( | uint16_t | Kp,
|  | uint16_t | Ki,
|  | uint16_t | Kd
| ) |  |

set the PID control for the encoders

## § setEncoderSpeedTimeAndControl()

bool EVs_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

## § setEncoderTarget()

bool EVs_NXTMMX::setEncoderTarget | ( | uint8_t | which_motor,
|  | long | target
| ) |  |

set the target encoder position for the motor

## § setPassCount()

bool EVs_NXTMMX::setPassCount | ( | uint8_t | pass_count | ) |

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

## § setSpeed()

bool EVs_NXTMMX::setSpeed | ( | uint8_t | which_motor,
|  | int | speed
| ) |  |

set the speed of the motor

## § setSpeedPID()

bool EVs_NXTMMX::setSpeedPID | ( | uint16_t | Kp,
|  | uint16_t | Ki,
|  | uint16_t | Kd
| ) |  |

set the PID control for the speed of the motors

## § setSpeedTimeAndControl()

bool EVs_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

## § setTolerance()

bool EVs_NXTMMX::setTolerance | ( | uint8_t | tolerance | ) |

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

## § startMotorsInSync()

bool EVs_NXTMMX::startMotorsInSync | ( |  | ) |

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

## § stop()

bool EVs_NXTMMX::stop | ( | uint8_t | which_motors,
|  | uint8_t | next_action
| ) |  |

stop the motor and do an action

## § waitUntilTachoDone()

void EVs_NXTMMX::waitUntilTachoDone | ( | uint8_t | which_motors | ) |

wait until the motor has reached its set target tachometer position

## § waitUntilTimeDone()

void EVs_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:

- C:/Program Files (x86)/Arduino-1.6.12/libraries/EVShield/EVs_NXTMMX.h
- C:/Program Files (x86)/Arduino-1.6.12/libraries/EVShield/EVs_NXTMMX.cpp