JMotor
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
JControlLoopBasic Class Reference

simple control loop for use with JMotorControllerClosed, can turn off motor if nothing has moved for a while More...

#include <JControlLoopBasic.h>

Inheritance diagram for JControlLoopBasic:
Inheritance graph
[legend]
Collaboration diagram for JControlLoopBasic:
Collaboration graph
[legend]

Public Member Functions

 JControlLoopBasic (float kP, unsigned long _timeout=0, bool _noReverseVoltage=false)
 constructor for control loop for use with JMotorControllerClosed
 
float calc (JMotorControllerClosed *controller)
 
void setKP (float _p)
 
float getKP ()
 
void setTimeout (unsigned long _timeout)
 
unsigned long getTimeout ()
 
void resetTime ()
 
- Public Member Functions inherited from JControlLoop
float getError ()
 setpoint-position
 
float getCtrlLoopOut ()
 most recent value calculated by control loop in response to error (but not including feedforward) For example, if the control loop is a proportional loop, this function returns P * error
 
float getResult ()
 most recent value returned by calc() overall output to motor
 

Protected Attributes

float P
 
unsigned long timeout
 
unsigned long lastMovedMillis
 
bool noReverseVoltage
 
- Protected Attributes inherited from JControlLoop
float error
 
float ctrlLoopOut
 
float result
 

Detailed Description

simple control loop for use with JMotorControllerClosed, can turn off motor if nothing has moved for a while

Constructor & Destructor Documentation

◆ JControlLoopBasic()

JControlLoopBasic::JControlLoopBasic ( float  kP,
unsigned long  _timeout = 0,
bool  _noReverseVoltage = false 
)
inline

constructor for control loop for use with JMotorControllerClosed

Parameters
kP(float) proportional to error
_timeout(unsigned long) default: 0, set output to zero if there's been no movement for this many milliseconds. 0=never timeout
_noReverseVoltage(bool) default: false, if true, don't apply voltage in reverse direction to target velocity (recommended only for non-directional encoders)

Member Function Documentation

◆ calc()

float JControlLoopBasic::calc ( JMotorControllerClosed controller)
inlinevirtual

Implements JControlLoop.

◆ getKP()

float JControlLoopBasic::getKP ( )
inline

◆ getTimeout()

unsigned long JControlLoopBasic::getTimeout ( )
inline

◆ resetTime()

void JControlLoopBasic::resetTime ( )
inlinevirtual

Implements JControlLoop.

◆ setKP()

void JControlLoopBasic::setKP ( float  _p)
inline

◆ setTimeout()

void JControlLoopBasic::setTimeout ( unsigned long  _timeout)
inline

Member Data Documentation

◆ lastMovedMillis

unsigned long JControlLoopBasic::lastMovedMillis
protected

◆ noReverseVoltage

bool JControlLoopBasic::noReverseVoltage
protected

◆ P

float JControlLoopBasic::P
protected

◆ timeout

unsigned long JControlLoopBasic::timeout
protected

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