PiStorms  4.012
PiStorms Library Reference by mindsensors.com
 All Classes Namespaces Files Functions Variables
mindsensors.MMX Class Reference

MMX: this class provides motor control functions for use with NXTMMX Raspberry Pi i2c baud rate must be 35000 or less to ensure proper functionality of NXTMMX. More...

Inheritance diagram for mindsensors.MMX:

Public Member Functions

def __init__
 Initialize the class with the i2c address of your NXTMMX. More...
 
def command
 Writes a specified command on the command register of the NXTMMX. More...
 
def resPos
 Reset the both motor encoders of the NXTMMX. More...
 
def battVoltage
 Reads the battery voltage. More...
 
def pos
 Reads the encoder position of the specified motor. More...
 
def setSpeed
 Run the motor(s) at a set speed for an unlimited duration. More...
 
def brake
 Stop the motor with abruptly with brake. More...
 
def float
 Stop the motor smoothly with float. More...
 
def hold
 Stop the motor abruptly and hold the current position. More...
 
def isBusy
 Check if the motor is running. More...
 
def waitUntilNotBusy
 Wait until the motor is no longer running. More...
 
def isStalled
 Check if the motor is stalled. More...
 
def isOverloaded
 Check if the motor is overloaded. More...
 
def runSecs
 Run the motor for a specific time in seconds. More...
 
def runDegs
 Run the motor for a specific amount of degrees. More...
 
def runRotations
 Run the motor for a specific amount of rotations. More...
 
def runEncoderPos
 Run the motor for a specific amount of rotations. More...
 
def SetPerformanceParameters
 Writes user specified values to the PID control registers. More...
 
def ReadPerformanceParameters
 Reads the values of the PID control registers. More...
 

Static Public Attributes

tuple MMX_ADDRESS = (0x06)
 Default NXTMMX I2C Address.
 
int MMX_VOLTAGE_MULTIPLIER = 37
 Constant Voltage Multipler.
 
int MMX_Motor_1 = 0x01
 Constant to specify Motor 1.
 
int MMX_Motor_2 = 0x02
 Constant to specify Motor 2.
 
int MMX_Motor_Both = 0x03
 Constant to specify both Motors.
 
int MMX_Next_Action_Float = 0x00
 Constant to specify Float Action.
 
int MMX_Next_Action_Brake = 0x01
 Constant to specify Brake Action.
 
int MMX_Next_Action_BrakeHold = 0x02
 Constant to specify Hold Action.
 
int MMX_Direction_Forward = 0x01
 Constant to specify Forward Motion.
 
int MMX_Direction_Reverse = 0x00
 Constant to specify Reverse Motion.
 
int MMX_Move_Relative = 0x01
 Constant to specify Relative Encoder Position.
 
int MMX_Move_Absolute = 0x00
 Constant to specify Absolute Encoder Position.
 
int MMX_Completion_Wait_For = 0x01
 Constant to Wait for Next Action.
 
int MMX_Completion_Dont_Wait = 0x00
 Constant to NOT Wait for Next Action.
 
int MMX_Speed_Full = 90
 Constant for commonly used Full Speed value.
 
int MMX_Speed_Medium = 60
 Constant for commonly used Moderate Speed value.
 
int MMX_Speed_Slow = 25
 Constant for commonly used Slow Speed value.
 
int MMX_CONTROL_SPEED = 0x01
 Constant to specify Speed bit of Motor Control byte.
 
int MMX_CONTROL_RAMP = 0x02
 Constant to specify Ramp bit of Motor Control byte.
 
int MMX_CONTROL_RELATIVE = 0x04
 Constant to specify Relative bit of Motor Control byte.
 
int MMX_CONTROL_TACHO = 0x08
 Constant to specify Tacho bit of Motor Control byte.
 
int MMX_CONTROL_BRK = 0x10
 Constant to specify Brake bit of Motor Control byte.
 
int MMX_CONTROL_ON = 0x20
 Constant to specify On bit of Motor Control byte.
 
int MMX_CONTROL_TIME = 0x40
 Constant to specify Time bit of Motor Control byte.
 
int MMX_CONTROL_GO = 0x80
 Constant to specify Go bit of Motor Control byte.
 
int MMX_COMMAND = 0x41
 Command Register.
 
int MMX_SETPT_M1 = 0x42
 Motor 1 Encoder Target Register.
 
int MMX_SPEED_M1 = 0x46
 Motor 1 Speed Register.
 
int MMX_TIME_M1 = 0x47
 Motor 1 Time Register.
 
int MMX_CMD_B_M1 = 0x48
 Motor 1 Motor Command B Register.
 
int MMX_CMD_A_M1 = 0x49
 Motor 1 Motor Command A Register.
 
int MMX_SETPT_M2 = 0x4A
 Motor 2 Encoder Target Register.
 
int MMX_SPEED_M2 = 0x4E
 Motor 2 Speed Register.
 
int MMX_TIME_M2 = 0x4F
 Motor 2 Time Register.
 
int MMX_CMD_B_M2 = 0x50
 Motor 1 Motor Command B Register.
 
int MMX_CMD_A_M2 = 0x51
 Motor 1 Motor Command A Register.
 
int MMX_POSITION_M1 = 0x62
 Motor 1 Encoder Position Register. More...
 
int MMX_POSITION_M2 = 0x66
 Motor 2 Encoder Position Register. More...
 
int MMX_STATUS_M1 = 0x72
 Motor 1 Status Register. More...
 
int MMX_STATUS_M2 = 0x73
 Motor 2 Status Register. More...
 
int MMX_TASKS_M1 = 0x76
 Motor 1 Tasks Register. More...
 
int MMX_TASKS_M2 = 0x77
 Motor 2 Tasks Register. More...
 
int MMX_P_Kp = 0x7A
 Position Kp Register.
 
int MMX_P_Ki = 0x7C
 Position Ki Register.
 
int MMX_P_Kd = 0x7E
 Position Kd Register.
 
int MMX_S_Kp = 0x80
 Speed Kp Register.
 
int MMX_S_Ki = 0x82
 Speed Ki Register.
 
int MMX_S_Kd = 0x84
 Speed Kd Register.
 
int MMX_PASSCOUNT = 0x86
 Pass Count Register.
 
int MMX_PASSTOLERANCE = 0x87
 Pass Tolerance Register.
 

Detailed Description

MMX: this class provides motor control functions for use with NXTMMX Raspberry Pi i2c baud rate must be 35000 or less to ensure proper functionality of NXTMMX.

Constructor & Destructor Documentation

def mindsensors.MMX.__init__ (   self,
  mmx_address = MMX_ADDRESS 
)

Initialize the class with the i2c address of your NXTMMX.

Parameters
selfThe object pointer.
mmx_addressAddress of your NXTMMX.

Member Function Documentation

def mindsensors.MMX.battVoltage (   self)

Reads the battery voltage.

Parameters
selfThe object pointer.
def mindsensors.MMX.brake (   self,
  motor_number 
)

Stop the motor with abruptly with brake.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to brake.
def mindsensors.MMX.command (   self,
  cmd 
)

Writes a specified command on the command register of the NXTMMX.

Parameters
selfThe object pointer.
cmdThe command you wish the NXTMMX to execute.
def mindsensors.MMX.float (   self,
  motor_number 
)

Stop the motor smoothly with float.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to float.
def mindsensors.MMX.hold (   self,
  motor_number 
)

Stop the motor abruptly and hold the current position.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to hold.
def mindsensors.MMX.isBusy (   self,
  motor_number 
)

Check if the motor is running.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to check.
def mindsensors.MMX.isOverloaded (   self)

Check if the motor is overloaded.

Parameters
selfThe object pointer.
def mindsensors.MMX.isStalled (   self,
  motor_number 
)

Check if the motor is stalled.

Parameters
motor_numberNumber of the motor(s) you wish to check.
selfThe object pointer.
def mindsensors.MMX.pos (   self,
  motor_number 
)

Reads the encoder position of the specified motor.

Parameters
selfThe object pointer.
motor_numberNumber of the motor you wish to read.
def mindsensors.MMX.ReadPerformanceParameters (   self)

Reads the values of the PID control registers.

Parameters
selfThe object pointer.
def mindsensors.MMX.resPos (   self)

Reset the both motor encoders of the NXTMMX.

Parameters
selfThe object pointer.
def mindsensors.MMX.runDegs (   self,
  motor_number,
  degs,
  speed,
  brakeOnCompletion = False,
  holdOnCompletion = False,
  waitForCompletion = False 
)

Run the motor for a specific amount of degrees.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to turn.
degsThe number of degrees to run the motor(s).
speedThe speed at which to turn the motor(s).
brakeOnCompletionChoose to brake or float the motor upon completion with True (brake) or False (float).
holdOnCompletionChoose to hold the motor position upon completion with True (hold) or False (release).
waitForCompletionTells the program when to handle the next line of code.
def mindsensors.MMX.runEncoderPos (   self,
  motor_number,
  pos,
  speed,
  brakeOnCompletion = False,
  holdOnCompletion = False,
  waitForCompletion = False 
)

Run the motor for a specific amount of rotations.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to turn.
posThe encoder value to which to run the motor(s).
speedThe speed at which to turn the motor(s).
brakeOnCompletionChoose to brake or float the motor upon completion with True (brake) or False (float).
holdOnCompletionChoose to hold the motor position upon completion with True (hold) or False (release).
waitForCompletionTells the program when to handle the next line of code.
def mindsensors.MMX.runRotations (   self,
  motor_number,
  rotations,
  speed,
  brakeOnCompletion = False,
  holdOnCompletion = False,
  waitForCompletion = False 
)

Run the motor for a specific amount of rotations.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to turn.
rotationsThe number of rotations to run the motor(s).
speedThe speed at which to turn the motor(s).
brakeOnCompletionChoose to brake or float the motor upon completion with True (brake) or False (float).
holdOnCompletionChoose to hold the motor position upon completion with True (hold) or False (release).
waitForCompletionTells the program when to handle the next line of code.
def mindsensors.MMX.runSecs (   self,
  motor_number,
  secs,
  speed,
  brakeOnCompletion = False,
  waitForCompletion = False 
)

Run the motor for a specific time in seconds.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to turn.
secsThe number of seconds to run the motor.
speedThe speed at which to turn the motor.
brakeOnCompletionChoose to brake or float the motor upon completion with True (brake) or False (float).
waitForCompletionWait until the motor is finished running before continuing the program.
def mindsensors.MMX.SetPerformanceParameters (   self,
  Kp_tacho,
  Ki_tacho,
  Kd_tacho,
  Kp_speed,
  Ki_speed,
  Kd_speed,
  passcount,
  tolerance 
)

Writes user specified values to the PID control registers.

Parameters
selfThe object pointer.
Kp_tachoProportional-gain of the encoder position of the motor.
Ki_tachoIntegral-gain of the encoder position of the motor.
Kd_tachoDerivative-gain of the encoder position of the motor.
Kp_speedProportional-gain of the speed of the motor.
Ki_speedIntegral-gain of the speed of the motor.
Kd_speedDerivative-gain of the speed of the motor.
passcountThe number of times the encoder reading should be within tolerance.
toleranceThe tolerance (in ticks) for encoder positioning .
def mindsensors.MMX.setSpeed (   self,
  motor_number,
  speed 
)

Run the motor(s) at a set speed for an unlimited duration.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to turn.
speedThe speed at which you wish to turn the motor(s).
def mindsensors.MMX.waitUntilNotBusy (   self,
  motor_number,
  timeout = -1 
)

Wait until the motor is no longer running.

Parameters
selfThe object pointer.
motor_numberNumber of the motor(s) you wish to wait for.
timeoutThe timeout value as a factor of 10ms.

Member Data Documentation

int mindsensors.MMX.MMX_POSITION_M1 = 0x62
static

Motor 1 Encoder Position Register.

Will return a long singed integer value

int mindsensors.MMX.MMX_POSITION_M2 = 0x66
static

Motor 2 Encoder Position Register.

Will return a long singed integer value

int mindsensors.MMX.MMX_STATUS_M1 = 0x72
static

Motor 1 Status Register.

Will return a byte value

int mindsensors.MMX.MMX_STATUS_M2 = 0x73
static

Motor 2 Status Register.

Will return a byte value

int mindsensors.MMX.MMX_TASKS_M1 = 0x76
static

Motor 1 Tasks Register.

Will return a byte value

int mindsensors.MMX.MMX_TASKS_M2 = 0x77
static

Motor 2 Tasks Register.

Will return a byte value


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