File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
avr/libraries/LottieLemon/src/utility Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -307,3 +307,24 @@ void MotorBoard::reset() {
307307 begin ();
308308 stopCurrentActions ();
309309}
310+
311+ float MotorBoard::getBatteryTerminalVolts () {
312+ // Read battery voltage on multiplexer channel 5.
313+ int adcValue = _multiplexer.analogRead (5 );
314+ float adcVoltage = (5 .0f / 1023 .0f ) * adcValue;
315+ return 2 .0f * adcVoltage; // Compensate for voltage divider.
316+ }
317+
318+ float MotorBoard::getBatteryChargeMilliamps () {
319+ // Read battery charge current on multiplexer channel 6.
320+ int adcValue = _multiplexer.analogRead (6 );
321+ float adcVoltage = (5 .0f / 1023 .0f ) * adcValue;
322+ return adcVoltage / 0 .00075f ; // Compensate sense resistor and gain.
323+ }
324+
325+ float MotorBoard::getBatteryDischargeMilliamps () {
326+ // Read battery discharge current on multiplexer channel 7.
327+ int adcValue = _multiplexer.analogRead (7 );
328+ float adcVoltage = (5 .0f / 1023 .0f ) * adcValue;
329+ return adcVoltage / 0 .00075f ; // Compensate sense resistor and gain.
330+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ namespace LottieLemon {
3535
3636 int IRread (uint8_t num);
3737
38+ float getBatteryTerminalVolts ();
39+ float getBatteryChargeMilliamps ();
40+ float getBatteryDischargeMilliamps ();
41+
3842 void setMode (uint8_t mode);
3943 void pauseMode (bool onOff);
4044
You can’t perform that action at this time.
0 commit comments