Robot Core Documentation
Loading...
Searching...
No Matches
robotCore.SmartMotor Class Reference

Smart motor controller class. More...

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

Classes

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 setDTerm (double d)
 
void setMinPower (double minPower)
 
void setDeadZone (double deadZone)
 

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- Specifies 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- Specifies 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

◆ getFeedbackDevice()

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

◆ set()

void robotCore.SmartMotor.set ( double value)
Parameters
value- Sets either the power, speed or position 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 in encoder units, or -1 to +1 if the maxSpeed value has been set. If the motor is in position mode, the value should be the desired position in encoder units (i.e. NOT degrees)

◆ setControlMode()

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

◆ setDeadZone()

void robotCore.SmartMotor.setDeadZone ( double deadZone)
Parameters
minDeadZone- For positional control specifies the max error to be considered on target. This value should be in encoder units (i.e. NOT degrees)

◆ setDTerm()

void robotCore.SmartMotor.setDTerm ( double d)
Parameters
d- Specifies the derivative term for the PID control.

◆ 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.

◆ setMinPower()

void robotCore.SmartMotor.setMinPower ( double minPower)
Parameters
wrap- When using position control this specifies that the position wraps modulo wrap
minPower- Specifies the minimum power needed to get the motor to run

◆ 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: