mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Use PH voltage to calc Analog pressure switch threshold (#5115)
The calculated trigger voltages were calculated with a hard coded 5v. This introduces error when the 5V provided to the Analog pressure sensor is not exactly 5v, as the pressure is a ratio of the analog voltage and provided voltage. This should improve https://www.chiefdelphi.com/t/rev-pressure-sensor-enablecompressoranalog-not-reaching-configured-pressure/426868 where the 5v voltage was 4.92 volts, which introduces ~8 PSI of error.
This commit is contained in:
@@ -162,8 +162,10 @@ void PneumaticHub::EnableCompressorAnalog(
|
||||
maxPressure);
|
||||
}
|
||||
int32_t status = 0;
|
||||
units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
|
||||
units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
|
||||
units::volt_t minAnalogVoltage =
|
||||
PSIToVolts(minPressure, Get5VRegulatedVoltage());
|
||||
units::volt_t maxAnalogVoltage =
|
||||
PSIToVolts(maxPressure, Get5VRegulatedVoltage());
|
||||
HAL_SetREVPHClosedLoopControlAnalog(m_handle, minAnalogVoltage.value(),
|
||||
maxAnalogVoltage.value(), &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
@@ -187,8 +189,10 @@ void PneumaticHub::EnableCompressorHybrid(
|
||||
maxPressure);
|
||||
}
|
||||
int32_t status = 0;
|
||||
units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
|
||||
units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
|
||||
units::volt_t minAnalogVoltage =
|
||||
PSIToVolts(minPressure, Get5VRegulatedVoltage());
|
||||
units::volt_t maxAnalogVoltage =
|
||||
PSIToVolts(maxPressure, Get5VRegulatedVoltage());
|
||||
HAL_SetREVPHClosedLoopControlHybrid(m_handle, minAnalogVoltage.value(),
|
||||
maxAnalogVoltage.value(), &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
|
||||
Reference in New Issue
Block a user