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

PiStormsMotor: This class provides functions for motor control. More...

Public Member Functions

def pos
 Returns the current encoder position of the motor. More...
 
def resetPos
 Resets the encoder position of the specified motor. More...
 
def setSpeed
 Run the motor at a set speed for an unlimited duration. More...
 
def setSpeedSync
 Run the two motors of the said bank in sync with each other. More...
 
def floatSync
 Stop both the motors of said bank at the same time. More...
 
def brakeSync
 Stop both the motors of said bank at the same time. More...
 
def brake
 Stop the motor 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 runSecs
 Run the motor for a specific time in seconds. 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 runDegs
 Run the motor for a specific amount of degrees. More...
 
def SetPerformanceParameters
 Set the motor PID parameters (PiStorms PID parameters are default for NXT/EV3 motors). More...
 
def ReadPerformanceParameters
 

Detailed Description

PiStormsMotor: This class provides functions for motor control.

Remarks
There is no need to initialize this class directly. This is done automatically during the PiStorms init.

Member Function Documentation

def PiStorms.PiStormsMotor.brake (   self)

Stop the motor abruptly with brake.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.brake()
def PiStorms.PiStormsMotor.brakeSync (   self)

Stop both the motors of said bank at the same time.

motors are stopped with a brake. You can call this function on any motor of that bank and it will work on both motors of that bank.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 #stop both motors of BankA synchronized.
5 psm.BAM1.brakeSync()
def PiStorms.PiStormsMotor.float (   self)

Stop the motor smoothly with float.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.float()
def PiStorms.PiStormsMotor.floatSync (   self)

Stop both the motors of said bank at the same time.

motors are stopped smoothly with float You can call this function on any motor of that bank and it will work on both motors of that bank.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 #stop both motors of BankA synchronized.
5 psm.BAM1.floatSync()
def PiStorms.PiStormsMotor.hold (   self)

Stop the motor abruptly and hold the current position.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.hold()
def PiStorms.PiStormsMotor.isBusy (   self)

Check if the motor is running.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 motorState = psm.BAM1.isBusy()
5 if(motorState == False):
6  # do some task
def PiStorms.PiStormsMotor.isOverloaded (   self)

Check if the motor is overloaded.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 overloadState = psm.BAM1.isOverloaded()
5 if(overloadState == True):
6  # do some task
def PiStorms.PiStormsMotor.isStalled (   self)

Check if the motor is stalled.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 stallState = psm.BAM1.isStalled()
5 if(stallState == True):
6  # do some task
def PiStorms.PiStormsMotor.pos (   self)

Returns the current encoder position of the motor.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 position = psm.BAM1.pos()
5 if(position > 720):
6  # do some task
def PiStorms.PiStormsMotor.resetPos (   self)

Resets the encoder position of the specified motor.

Parameters
selfThe object pointer.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.resetPos()
def PiStorms.PiStormsMotor.runDegs (   self,
  degs,
  speed = 100,
  brakeOnCompletion = False,
  holdOnCompletion = False 
)

Run the motor for a specific amount of degrees.

Parameters
selfThe object pointer.
degsThe number of degrees 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).
holdOnCompletionChoose to hold the motor position upon completion with True (hold) or False (release).
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.runDegs(720,100,True,False)
def PiStorms.PiStormsMotor.runSecs (   self,
  secs,
  speed,
  brakeOnCompletion = False 
)

Run the motor for a specific time in seconds.

Parameters
selfThe object pointer.
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).
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.runSecs(5,100,True)
def PiStorms.PiStormsMotor.SetPerformanceParameters (   self,
  Kp_tacho,
  Ki_tacho,
  Kd_tacho,
  Kp_speed,
  Ki_speed,
  Kd_speed,
  passcount,
  tolerance 
)

Set the motor PID parameters (PiStorms PID parameters are default for NXT/EV3 motors).

Only one set of PID parameters can be set per bank and will reset to default upon new power cycle

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 .
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.SetPerformanceParameters(6,0,0,1,0,0,10,5)
def PiStorms.PiStormsMotor.setSpeed (   self,
  speed 
)

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

Parameters
selfThe object pointer.
speedThe speed at which to turn the motor.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 psm.BAM1.setSpeed(100)
def PiStorms.PiStormsMotor.setSpeedSync (   self,
  speed 
)

Run the two motors of the said bank in sync with each other.

at a set speed for an unlimited duration You can call this function on any motor of that bank and it will work on both motors of that bank.

Parameters
selfThe object pointer.
speedThe speed at which to turn the motors
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 #run both motors of BankA in sync:
5 psm.BAM1.setSpeedSync(100)
def PiStorms.PiStormsMotor.waitUntilNotBusy (   self,
  timeout = -1 
)

Wait until the motor is no longer running.

Parameters
selfThe object pointer.
timeoutThe timeout value as a factor of 10ms.
Remarks
To use this function in your program:
1 from PiStorms import PiStorms
2 ...
3 psm = PiStorms()
4 boolMotorState = psm.BAM1.waitUntilNotBusy()
5 if(overloadState == True):
6  # do some task

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