PiStorms
4.012
PiStorms Library Reference by mindsensors.com
|
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...
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. | |
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.
def mindsensors.MMX.__init__ | ( | self, | |
mmx_address = MMX_ADDRESS |
|||
) |
Initialize the class with the i2c address of your NXTMMX.
self | The object pointer. |
mmx_address | Address of your NXTMMX. |
def mindsensors.MMX.battVoltage | ( | self | ) |
Reads the battery voltage.
self | The object pointer. |
def mindsensors.MMX.brake | ( | self, | |
motor_number | |||
) |
Stop the motor with abruptly with brake.
self | The object pointer. |
motor_number | Number 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.
self | The object pointer. |
cmd | The command you wish the NXTMMX to execute. |
def mindsensors.MMX.float | ( | self, | |
motor_number | |||
) |
Stop the motor smoothly with float.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to float. |
def mindsensors.MMX.hold | ( | self, | |
motor_number | |||
) |
Stop the motor abruptly and hold the current position.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to hold. |
def mindsensors.MMX.isBusy | ( | self, | |
motor_number | |||
) |
Check if the motor is running.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to check. |
def mindsensors.MMX.isOverloaded | ( | self | ) |
Check if the motor is overloaded.
self | The object pointer. |
def mindsensors.MMX.isStalled | ( | self, | |
motor_number | |||
) |
Check if the motor is stalled.
motor_number | Number of the motor(s) you wish to check. |
self | The object pointer. |
def mindsensors.MMX.pos | ( | self, | |
motor_number | |||
) |
Reads the encoder position of the specified motor.
self | The object pointer. |
motor_number | Number of the motor you wish to read. |
def mindsensors.MMX.ReadPerformanceParameters | ( | self | ) |
Reads the values of the PID control registers.
self | The object pointer. |
def mindsensors.MMX.resPos | ( | self | ) |
Reset the both motor encoders of the NXTMMX.
self | The 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.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to turn. |
degs | The number of degrees to run the motor(s). |
speed | The speed at which to turn the motor(s). |
brakeOnCompletion | Choose to brake or float the motor upon completion with True (brake) or False (float). |
holdOnCompletion | Choose to hold the motor position upon completion with True (hold) or False (release). |
waitForCompletion | Tells 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.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to turn. |
pos | The encoder value to which to run the motor(s). |
speed | The speed at which to turn the motor(s). |
brakeOnCompletion | Choose to brake or float the motor upon completion with True (brake) or False (float). |
holdOnCompletion | Choose to hold the motor position upon completion with True (hold) or False (release). |
waitForCompletion | Tells 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.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to turn. |
rotations | The number of rotations to run the motor(s). |
speed | The speed at which to turn the motor(s). |
brakeOnCompletion | Choose to brake or float the motor upon completion with True (brake) or False (float). |
holdOnCompletion | Choose to hold the motor position upon completion with True (hold) or False (release). |
waitForCompletion | Tells 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.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to turn. |
secs | The number of seconds to run the motor. |
speed | The speed at which to turn the motor. |
brakeOnCompletion | Choose to brake or float the motor upon completion with True (brake) or False (float). |
waitForCompletion | Wait 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.
self | The object pointer. |
Kp_tacho | Proportional-gain of the encoder position of the motor. |
Ki_tacho | Integral-gain of the encoder position of the motor. |
Kd_tacho | Derivative-gain of the encoder position of the motor. |
Kp_speed | Proportional-gain of the speed of the motor. |
Ki_speed | Integral-gain of the speed of the motor. |
Kd_speed | Derivative-gain of the speed of the motor. |
passcount | The number of times the encoder reading should be within tolerance. |
tolerance | The 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.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to turn. |
speed | The 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.
self | The object pointer. |
motor_number | Number of the motor(s) you wish to wait for. |
timeout | The timeout value as a factor of 10ms. |
|
static |
Motor 1 Encoder Position Register.
Will return a long singed integer value
|
static |
Motor 2 Encoder Position Register.
Will return a long singed integer value
|
static |
Motor 1 Status Register.
Will return a byte value
|
static |
Motor 2 Status Register.
Will return a byte value
|
static |
Motor 1 Tasks Register.
Will return a byte value
|
static |
Motor 2 Tasks Register.
Will return a byte value