Conversation
59b81b4 to
7e0e7af
Compare
task/thermal/src/control.rs
Outdated
| self.set_pwm(target_pwm)?; | ||
| self.sensor_api.post( | ||
| OUTPUT_PWM_SENSOR, | ||
| target_pwm.0 as f32, | ||
| now_ms, | ||
| ); |
There was a problem hiding this comment.
I kinda wonder if maybe we ought to just make self.set_pwm also post the new duty cycle to the sensors task, so that it's impossible to set the duty cycle without also posting value to the sensors task?
There was a problem hiding this comment.
Done – it's a little awkward (because we need to represent the NoData::DeviceOff case), so I switched the input argument to a Result<PWMDuty, NoData>.
There was a problem hiding this comment.
Hmm, did we have to do it like that? I was imagining that in the DeviceOff state we would just call self.sensor_api.post directly. Rather than making set_pwm the only way we ever post a sensor reading, I was just thinking that any time we set the PWM duty cycle we also post a sensor reading (but this would not be the only place we posted a sensor reading). set_pwm(Err(NoData::DeviceOff)) feels a bit awkward to me.
There was a problem hiding this comment.
I think the Result<..> shenanigans are the simplest way to do it. In our previous world where set_pwm just takes a PwmDuty, when we go uncontrollable, we'd still call set_pwm(PwmDuty(0)) – and would therefore post 0 to the sensors task because we don't know any better.
The Result<..> argument lets us distinguish between "there's an error, so post the error but set the PWM to 0" versus "situation normal, post a pwm of 0 and set it".
There was a problem hiding this comment.
Oh I see, yeah, okay. I don't hate it.
a14b7c2 to
918ce72
Compare
c48f4a1 to
a27d9e8
Compare
918ce72 to
33651a8
Compare
a27d9e8 to
2d6751c
Compare
2b5aa4f to
50a6a4c
Compare
bde98a4 to
ffdf316
Compare
50a6a4c to
130b41d
Compare
ffdf316 to
014d2be
Compare
130b41d to
b5dd092
Compare
014d2be to
fdd03a0
Compare
b5dd092 to
63b3e35
Compare
588cbe9 to
7010013
Compare
63b3e35 to
f6c3cc5
Compare
7010013 to
c64bf6a
Compare
f6c3cc5 to
9f4b4a6
Compare
labbott
left a comment
There was a problem hiding this comment.
just a few minor questions but LGTM
| ringbuf_entry!(Trace::PowerDownFailed(e)); | ||
| } | ||
| self.set_pwm(PWMDuty(0))?; | ||
| self.set_pwm(Err(task_sensor_api::NoData::DeviceOff), now_ms)?; |
There was a problem hiding this comment.
It feels strange to treat DeviceOff as an error. Under what circumstances would we hit PowerDown?
| [[config.sensor.devices]] | ||
| name = "fan_ctrl" | ||
| device = "thermal_loop" | ||
| description = "Thermal loop PWM command" |
There was a problem hiding this comment.
Nit: the command part of this description feels weird. Just drop it?
c64bf6a to
8e2c3a1
Compare
9f4b4a6 to
47218f6
Compare
8e2c3a1 to
234e459
Compare
234e459 to
323f754
Compare
(staged on top of #2428)
This adds a new
fan_ctrlsensor, which is updated by the thermal loop. In combination with oxidecomputer/humility#602, we can log both fan speed (which was already possible) and commanded PWM values withhumility dashboard -o out.csvHere's an example while running
stress-ng:The hysteresis from the fan controller is quite noticeable if we plot PWM vs RPM: