Fix i_set, a user-provided value, to stop varying on VREF measurements #84
Loading…
Reference in New Issue
No description provided.
Delete Branch "atse/thermostat:fix-i_set"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
* Stops center point from fluctuating due to repeated measurements of VREF* Uses a calibrated stable VREF measured on startup instead* Corresponding changes for consistencyThis helps stabilise the value ofi_set
(the TEC current setpoint set and produced inset_i
andget_i
), so that it behaves more like a direct key-value store, as it is a user value and not a measured value.Store the user-provided value i_set separately for later reading, so that i_set does not fluctuate.
@ -377,2 +376,3 @@
pub fn get_tec_i(&mut self, channel: usize) -> ElectricCurrent {
(self.read_itec(channel) - self.read_vref(channel)) / ElectricalResistance::new::<ohm>(0.4)
let vref = self.read_vref(channel);
self.channel_state(channel).vref = vref;
A "get" function shouldn't modify state.
The reports would not have an updated VREF value then. Should we remove VREF reporting? It's an implementation detail anyway.
Sounds like removing VREF reporting is the simplest solution, yes. In any case I don't see why a function called
get_tec_i
should modify an internal value of vref to be reported later.Ok, I've dropped that commit. I've opened a separate pull request for removing VREF reporting (#85) as it is a protocol change.
bdffcd4423
to7043974bb5
Shouldn't VREF be stable? I don't understand this PR.
Well, theoretically it should be at a constant 1.5V, but the actual value, as returned by
read_vref
, fluctuates a bit around it, being off by up to 11mV at times.The calibration routine in
calibrate_dac_value
finds a DAC output that is the closest to an averaged VREF and stores it for later. Since it is only run once on startup, it is constant, and should be used for current setpoint purposes for stability.What I've done is to refactor
get_center
to use that calibrated VREF instead of a VREF measured on-the-fly. Sincei_set
depends on the value ofget_center
, this results in a stablei_set
that behaves like a key-value store.Is that what you would expect from reading the datasheets?
Yes, as the MAX1968 datasheet specifies a threshold of ±15mV from 1.5V. When used in the current setpoint calculation it yields significant noise.
7043974bb5
to9ef1d05a42
The latest force-push adds a member to ChannelState that keeps track of the current setpoint
i_set
directly, avoiding any calculation just to report the user-provided value.Refactor center point and VREF measurement for a more stable i_setto WIP: Refactor center point and VREF measurement for a more stable i_set9ef1d05a42
to7259caee47
It's not a "refactor" if it changes functionality.
WIP: Refactor center point and VREF measurement for a more stable i_setto Fix excessive VREF measurement for a more stable i_setYes, agreed.
The plottable tec_i values should now be avoiding VREF fluctuations. Also to be honest I'm still struggling with tuning the calibrate_dac_value routine as I believe the
vref_meas
could be better calibrated still. There's currently still a positive offset that would mean setting i_set to zero would still output ~30mA on the channel.7259caee47
to76547be90a
Ok, I'm splitting all the VREF calibrating and hardware dependent adjusting stuff out of this PR. This PR is now solely focused on fixing the problem of a wildly fluctuating i_set in reports, when it should be a user-provided value.
Fix excessive VREF measurement for a more stable i_setto Fix i_set, a user-provided value, to stop varying on VREF measurements