JMotor
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
JServoCurrentSensor< N > Class Template Reference

implements JServoStallSensing interface. More...

#include <JServoCurrentSensor.h>

Inheritance diagram for JServoCurrentSensor< N >:
Inheritance graph
[legend]
Collaboration diagram for JServoCurrentSensor< N >:
Collaboration graph
[legend]

Public Member Functions

 JServoCurrentSensor (int _measurePin, int _maxRange=1000, int _minRange=0)
 constructor for JServoCurrentSensor
 
float getMeasurement (bool _run=true)
 
int getUnscaledMeasurement ()
 
bool getJustStarted ()
 
int getMinRange ()
 
int getMaxRange ()
 
void setMinRange (int min)
 
void setMaxRange (int max)
 
void setMeasurementPin (byte _newPin)
 
byte getMeasurementPin ()
 
void run ()
 

Protected Attributes

int measurePin
 
bool justStarted
 
int readings [N]
 
byte readIndex
 
long total
 
unsigned long lastMeasurementMillis
 
long measurementRaw
 
int minRange
 
int maxRange
 

Detailed Description

template<uint16_t N>
class JServoCurrentSensor< N >

implements JServoStallSensing interface.

averages N number of readings, use like: JServoCurrentSensor<40> stallSensor = JServoCurrentSensor<40>(pin);

takes and filters current readings to calculate how hard a servo is working add a small amount of resistance to the negative power wire of a servo (a small bundle of wire can create enough resistance) connect the measuring pin to the negative wire close to the servo so the voltage drop across the resistance can be measured.

Constructor & Destructor Documentation

◆ JServoCurrentSensor()

template<uint16_t N>
JServoCurrentSensor< N >::JServoCurrentSensor ( int  _measurePin,
int  _maxRange = 1000,
int  _minRange = 0 
)
inline

constructor for JServoCurrentSensor

Parameters
_measurePinanalog pin reading signal that corresponds to how much current a servo is drawing
_maxRange
_minRange
Return values

Member Function Documentation

◆ getJustStarted()

template<uint16_t N>
bool JServoCurrentSensor< N >::getJustStarted ( )
inline

◆ getMaxRange()

template<uint16_t N>
int JServoCurrentSensor< N >::getMaxRange ( )
inline

◆ getMeasurement()

template<uint16_t N>
float JServoCurrentSensor< N >::getMeasurement ( bool  _run = true)
inlinevirtual

Implements JServoStallSensing.

◆ getMeasurementPin()

template<uint16_t N>
byte JServoCurrentSensor< N >::getMeasurementPin ( )
inline

◆ getMinRange()

template<uint16_t N>
int JServoCurrentSensor< N >::getMinRange ( )
inline

◆ getUnscaledMeasurement()

template<uint16_t N>
int JServoCurrentSensor< N >::getUnscaledMeasurement ( )
inline

◆ run()

template<uint16_t N>
void JServoCurrentSensor< N >::run ( )
inlinevirtual

Implements JServoStallSensing.

◆ setMaxRange()

template<uint16_t N>
void JServoCurrentSensor< N >::setMaxRange ( int  max)
inline

◆ setMeasurementPin()

template<uint16_t N>
void JServoCurrentSensor< N >::setMeasurementPin ( byte  _newPin)
inline

◆ setMinRange()

template<uint16_t N>
void JServoCurrentSensor< N >::setMinRange ( int  min)
inline

Member Data Documentation

◆ justStarted

template<uint16_t N>
bool JServoCurrentSensor< N >::justStarted
protected

◆ lastMeasurementMillis

template<uint16_t N>
unsigned long JServoCurrentSensor< N >::lastMeasurementMillis
protected

◆ maxRange

template<uint16_t N>
int JServoCurrentSensor< N >::maxRange
protected

◆ measurementRaw

template<uint16_t N>
long JServoCurrentSensor< N >::measurementRaw
protected

◆ measurePin

template<uint16_t N>
int JServoCurrentSensor< N >::measurePin
protected

◆ minRange

template<uint16_t N>
int JServoCurrentSensor< N >::minRange
protected

◆ readIndex

template<uint16_t N>
byte JServoCurrentSensor< N >::readIndex
protected

◆ readings

template<uint16_t N>
int JServoCurrentSensor< N >::readings[N]
protected

the readings from the analog input

◆ total

template<uint16_t N>
long JServoCurrentSensor< N >::total
protected

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