RobotCore
Robot Core Documentation
Classes | Public Member Functions | List of all members
robotCore.SmartMotor Class Reference

Smart motor controller class. More...

Inheritance diagram for robotCore.SmartMotor:
robotCore.MotorBase robotCore.PWMMotor robotCore.VexMotor

Classes

class  MotionProfileData
 
enum  SmartMotorMode
 Specifies the type of control. More...
 
enum  SmartMotorType
 Specifies the type of motor. More...
 

Public Member Functions

 SmartMotor (SmartMotorType type, int pwmPin, int dirPin)
 
 SmartMotor (SmartMotorType type, int pwmPin, int dirPin, int i2cAddr)
 
 SmartMotor (int pin, int min, int zero, int max)
 
 SmartMotor (int pin, int min, int zero, int max, int i2cAddr)
 
void setMaxSpeed (double maxSpeed)
 
void set (double value)
 
void setFeedbackDevice (Encoder encoder)
 
Encoder getFeedbackDevice ()
 
void setControlMode (SmartMotorMode mode)
 
void setFTerm (double f)
 
void setITerm (double i)
 
void setPTerm (double p)
 
void setIZone (double z)
 
void setInverted (boolean invert)
 
void disable ()
 
void enable ()
 

Detailed Description

Smart motor controller class.

Author
John Gaby

This class serves as the base class for the different types of motors It can handle advanced motor control using PID to control of the motor speed.

Constructor & Destructor Documentation

◆ SmartMotor() [1/4]

robotCore.SmartMotor.SmartMotor ( SmartMotorType  type,
int  pwmPin,
int  dirPin 
)

Creates an instance of a PWM duty cycle motor using 1 or 2 pins

Parameters
type- Specifies the type of motor
pwmPin- Specifies the pin for the PWM signal
dirPin- Specifies the pin for the direction control. If this value is zero then only the pwmPin is used and the motor cannot be reversed.

◆ SmartMotor() [2/4]

robotCore.SmartMotor.SmartMotor ( SmartMotorType  type,
int  pwmPin,
int  dirPin,
int  i2cAddr 
)

Creates instance of a PWM duty cycle motor using 1 or 2 pins when the motor is connected to an auxiliary Arduino via i2c

Parameters
type- Specifies the type of motor
pwmPin- Specifies the pin for the PWM signal
dirPin- Specifies the pin for the direction control. If this value is zero then only the pwmPin is used and the motor cannot be reversed.
i2cAddr- Specifies the address of the i2c connected Arduino

◆ SmartMotor() [3/4]

robotCore.SmartMotor.SmartMotor ( int  pin,
int  min,
int  zero,
int  max 
)

Creates an instance of a servo style motor

Parameters
pin- Specifies the pin servo signal
min- Specifes the minimum (full reverse) PWM time in ms
zero- Specifies the zero (stop) PWM time in ms.
max- Specifies the max (full forward) PWM time in ms.

◆ SmartMotor() [4/4]

robotCore.SmartMotor.SmartMotor ( int  pin,
int  min,
int  zero,
int  max,
int  i2cAddr 
)

Creates instance of a servo style motor when the motor is connected to an auxiliary Arduino via i2c

Parameters
pin- Specifies the pin servo signal
min- Specifes the minimum (full reverse) PWM time in ms
zero- Specifies the zero (stop) PWM time in ms.
max- Specifies the max (full forward) PWM time in ms.
i2cAddr- Specifies the address of the i2c connected Arduino

Member Function Documentation

◆ disable()

void robotCore.SmartMotor.disable ( )

Disables the motor.

Reimplemented from robotCore.MotorBase.

◆ enable()

void robotCore.SmartMotor.enable ( )

Enables the motor.

Reimplemented from robotCore.MotorBase.

◆ getFeedbackDevice()

Encoder robotCore.SmartMotor.getFeedbackDevice ( )
Returns
Returns the current feedback device

◆ set()

void robotCore.SmartMotor.set ( double  value)
Parameters
value- Sets either the power or the speed depending on the current mode. If the motor is in power mode, this should be in the range -1 to +1. If the motor is in speed mode, then this should either be the desired speed, or -1 to +1 if the maxSpeed value has been set.

◆ setControlMode()

void robotCore.SmartMotor.setControlMode ( SmartMotorMode  mode)
Parameters
mode- Sets the current control mode.

◆ setFeedbackDevice()

void robotCore.SmartMotor.setFeedbackDevice ( Encoder  encoder)
Parameters
encoder- Specifies the feedback device to be used to control the speed.

◆ setFTerm()

void robotCore.SmartMotor.setFTerm ( double  f)
Parameters
f- Specifies the 'feed forward' term for the PID control.

◆ setInverted()

void robotCore.SmartMotor.setInverted ( boolean  invert)
Parameters
invert- If true then the direction of the motor is reversed

◆ setITerm()

void robotCore.SmartMotor.setITerm ( double  i)
Parameters
i- Specifies the integral term for the PID control.

◆ setIZone()

void robotCore.SmartMotor.setIZone ( double  z)
Parameters
z- Specifies the I Zone term for the PID control. This is the region outside of which, the I term is ignored.

◆ setMaxSpeed()

void robotCore.SmartMotor.setMaxSpeed ( double  maxSpeed)
Parameters
maxSpeed- Specifies the maximum speed of the motor. Setting this value allows control of the speed using the range -1 to +1 similar to when the motor is controlled by power.

◆ setPTerm()

void robotCore.SmartMotor.setPTerm ( double  p)
Parameters
p- Specifies the proportional term for the PID control.

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