[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:
sciencewhiz
2023-02-19 23:13:22 -08:00
committed by GitHub
parent de65a135c3
commit dbbfe1aed2
2 changed files with 12 additions and 8 deletions

View File

@@ -294,8 +294,8 @@ public class PneumaticHub implements PneumaticsBase {
throw new IllegalArgumentException(
"maxPressure must be between 0 and 120 PSI, got " + maxPressure);
}
double minAnalogVoltage = psiToVolts(minPressure, 5);
double maxAnalogVoltage = psiToVolts(maxPressure, 5);
double minAnalogVoltage = psiToVolts(minPressure, get5VRegulatedVoltage());
double maxAnalogVoltage = psiToVolts(maxPressure, get5VRegulatedVoltage());
REVPHJNI.setClosedLoopControlAnalog(m_handle, minAnalogVoltage, maxAnalogVoltage);
}
@@ -339,8 +339,8 @@ public class PneumaticHub implements PneumaticsBase {
throw new IllegalArgumentException(
"maxPressure must be between 0 and 120 PSI, got " + maxPressure);
}
double minAnalogVoltage = psiToVolts(minPressure, 5);
double maxAnalogVoltage = psiToVolts(maxPressure, 5);
double minAnalogVoltage = psiToVolts(minPressure, get5VRegulatedVoltage());
double maxAnalogVoltage = psiToVolts(maxPressure, get5VRegulatedVoltage());
REVPHJNI.setClosedLoopControlHybrid(m_handle, minAnalogVoltage, maxAnalogVoltage);
}