A driver for analog battery monitors. More...
|bool||has_current_sense () const|
|Checks if current sense is available. As there isn't hardware to detect this, this simply checks if the current multiplier is non-zero. More...|
|bool||has_voltage_sense () const|
|Checks if voltage sense is available. As there isn't hardware to detect this, this simply checks if the voltage multiplier is non-zero. More...|
|void||init (const BatteryMonitorHardwareStruct &def, AnalogDigitalConverter *adc, float voltage_multiplier=0, float current_multiplier=0)|
|Initialize the battery monitor. More...|
|float||read_current () const|
|Read the current battery current. More...|
|float||read_voltage () const|
|Read the current battery voltage. More...|
|void||set_current_multiplier (double multiplier)|
|Sets the current multiplier for the battery monitor. More...|
|void||set_voltage_multiplier (double multiplier)|
|Sets the voltage multiplier for the battery monitor. More...|
A driver for analog battery monitors.
These battery monitors provide an analog voltage proportional to the battery voltage and/or current. This class handles setting up pins and unit conversions. This class does not initialize the ADC.
|void BatteryMonitor::init||(||const BatteryMonitorHardwareStruct &||def,|
Initialize the battery monitor.
Does not initialize the ADC. The ADC must be initialized before calling.
|def||The hardware definition struct for the battery monitor, mostly pin info|
|adc||The ADC used for the monitor. Must be initialized already|
|voltage_multiplier||The voltage multiplier. Set to 0 for no voltage sense. See set_voltage_multiplier.|
|current_multiplier||The current multiplier. Set to 0 for no current sense. See set_current_multiplier|
Sets the current multiplier for the battery monitor.
Analog battery monitors which support current measurement generate a voltage proportional to the current through them. This voltage is read by the ADC, and then multiplied by the current multiplier to measure the current. I.e BatteryCurrent = ADCVoltage * CurrentMultiplier. This number can be obtained from the spec sheet for the battery monitor. This value is in amps per volt.
Sets the voltage multiplier for the battery monitor.
Because the battery voltage is usually much too high for the ADC to read, analog battery monitors use a voltage divider or similar to reduce the voltage to a reasonable level. The voltage read by the ADC is multiplied by the voltage multiplier to get the actual reading. I.e BatteryVoltage = ADCVoltage * VoltageMultiplier. This number can be obtained from the spec sheet for the battery monitor, or through simple math for DIY monitors. This value is in volts per volt (i.e. unitless).
|multiplier||The new voltage multiplier|