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

measure supply voltage with analogRead and use that to convert voltage to value needed to set driver at to get that voltage More...

#include <JVoltageCompMeasure.h>

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

Public Member Functions

 JVoltageCompMeasure (byte _measurePin, float _DACUnitsPerVolt, unsigned int _measurementIntervalMillis=10)
 constructor
 
float adjust (float voltage, float driverRange)
 do conversion
 
float getSupplyVoltage ()
 

Detailed Description

template<byte N>
class JVoltageCompMeasure< N >

measure supply voltage with analogRead and use that to convert voltage to value needed to set driver at to get that voltage

Note
N (the value in the template) is how many measurements to average together to smooth voltage readings

Constructor & Destructor Documentation

◆ JVoltageCompMeasure()

template<byte N>
JVoltageCompMeasure< N >::JVoltageCompMeasure ( byte  _measurePin,
float  _DACUnitsPerVolt,
unsigned int  _measurementIntervalMillis = 10 
)
inline

constructor

Parameters
_measurePinpin to use to measure battery voltage (you probably want to make a voltage divider with a couple resistors)
_DACUnitsPerVoltthe value read through analogRead is divided by this value to get voltage
_measurementIntervalMilliswait this many milliseconds before taking another reading (default: 10)

Member Function Documentation

◆ adjust()

template<byte N>
float JVoltageCompMeasure< N >::adjust ( float  voltage,
float  driverRange 
)
inlinevirtual

do conversion

Parameters
voltage(float) voltage wanted from motor driver output
driverRange(float) set what value makes the driver output 100% of supply voltage
Return values
(float)value to set driver at

Reimplemented from JVoltageCompensator.

◆ getSupplyVoltage()

template<byte N>
float JVoltageCompMeasure< N >::getSupplyVoltage ( )
inlinevirtual
Return values
(float)returns current supply voltage

Reimplemented from JVoltageCompensator.


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