succd: check currentmost pirani values for safety lock

This commit is contained in:
zdmx 2024-09-27 23:24:55 +02:00
parent 9db2213fa6
commit 7a64ce91d4

View file

@ -123,15 +123,7 @@ func (d *daemon) processOnce(_ context.Context) error {
d.aboveRough.process(float64(mbar)) d.aboveRough.process(float64(mbar))
d.aboveHigh.process(float64(mbar)) d.aboveHigh.process(float64(mbar))
klog.Infof("rate of change: %f", d.piraniRateOfChange()) if d.piraniWireBreakDetection() {
// max rate of 1.0 in 500 ms because ringbuffer holds 5 values
if d.piraniRateOfChange() > 2.0 {
if !d.failsafe {
d.failsafe = true
klog.Errorf("Pressure changed too fast; entering failsafe mode")
}
} else if mbar < 4e-6 {
// Unrealistic result, Pirani probe probably disconnected. Failsafe mode. // Unrealistic result, Pirani probe probably disconnected. Failsafe mode.
if !d.failsafe { if !d.failsafe {
d.failsafe = true d.failsafe = true
@ -197,23 +189,20 @@ func (d *daemon) processOnce(_ context.Context) error {
return nil return nil
} }
func (d *daemon) piraniRateOfChange() float32 { func (d *daemon) piraniWireBreakDetection() bool {
max := d.adcPiraniVolts[0] if len(d.adcPiraniVolts) < 3 {
min := d.adcPiraniVolts[0] return true
for _, val := range d.adcPiraniVolts {
if val < min {
min = val
}
if val > max {
max = val
}
} }
max_bar := math.Pow(10.0, float64(max)-8.5); volts := float32(0.0)
max_mbar := float32(max_bar * 1000.0) for _, v := range d.adcPiraniVolts[len(d.adcPiraniVolts)-3:] {
min_bar := math.Pow(10.0, float64(min)-8.5); volts += v
min_mbar := float32(min_bar * 1000.0) }
volts /= 3.0
return max_mbar - min_mbar bar := math.Pow(10.0, float64(volts)-8.5)
mbar := float32(bar * 1000.0)
return mbar < 4e-6
} }
// pirani returns the Pirani gauge voltage and pressure. // pirani returns the Pirani gauge voltage and pressure.