ETB compensates for battery voltage (#4838)

* compensate battery voltage

* changelog

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2022-12-10 19:55:26 -08:00 committed by GitHub
parent 53828adaa3
commit 872595f302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -28,6 +28,9 @@ Release template (copy/paste this for new release):
## Unreleased
### Added
- Electronic throttle supply voltage compensation, giving more consistent behavior as battery voltage changes #4838
## December 2022 Release - "Day 289"
### Breaking Changes

View File

@ -53,6 +53,11 @@ bool TwoPinDcMotor::set(float duty)
{
m_value = duty;
// For low voltage, voltageRatio will be >1 to boost duty so that motor current stays the same
// At high voltage, the inverse will be true to keep behavior always the same.
float voltageRatio = 14 / Sensor::get(SensorType::BatteryVoltage).value_or(14);
duty *= voltageRatio;
// If not init, don't try to set
if (!m_dir1 || !m_dir2 || !m_enable) {
if (m_disable) {