Commit Graph

82 Commits

Author SHA1 Message Date
069d791802 Rename all Steinhart-Hart references to B-param
The Steinhart-Hart equation was changed in code long ago to the
B-parameter equation. Rename references to it and the interface
accordingly. The `s-h` command is now `b-p`.

The reason the name "B-Parameter" equation was chosen over
"Beta-Parameter" was due to its easier searchability.
2024-10-21 15:44:46 +08:00
bd9ae997ae PwmLimits: Use uom quantities for fields not f64s 2024-10-21 11:13:19 +08:00
eddf05cae7 channels: get_i -> get_i_set 2024-10-21 11:12:16 +08:00
f68ae12c8d TCP command: Rename pwm to output
Current limit pins are driven by PWM inputs to the MAX1968 driver, but
this is an implementation detail, and should not be exposed in the form
of the command interface. Rename "pwm" to "output" in all instances.

See M-Labs/thermostat#62 (comment).
2024-10-21 10:09:24 +08:00
d8ec083dbc Apply clippy suggestions 2024-10-14 13:25:49 +08:00
1962135e79 Apply cargo fmt 2024-10-14 13:25:49 +08:00
798b400aa5 Show and save set value for PWM limits
Show in PwmSummary the set value, before all PWM duty calculations
instead of the machine value after the calculations. Also save the set
value into the flash store instead of the machine value.
2024-10-07 10:41:31 +08:00
5c3b759d0c PwmSummary: Don't show max PWM values
Putting the maximum in PwmSummary has little use - the maximum never
changes throughout the runtime of the firmware and can be replaced by
documentation elsewhere.
2024-10-07 10:41:31 +08:00
6224486662 Show polarity in pwm command 2024-09-30 17:36:50 +08:00
32bd49b258 Add a command to reverse the output polarity
Effectively flips all values related to the directionality of current
through the TEC, including current maximums. The reversed status is
stored in the flash store and will be loaded on reset once saved.

The command is "pwm <ch> polarity <normal/reversed>", where the "normal"
polarity is indicated by the front panel markings.

This is needed for IDC cable connections to the Sinara 5432 DAC
"Zotino", since the TEC pins of the 10-pin connector on the Thermostat
and Zotino have opposite polarities.
2024-09-30 17:36:47 +08:00
ad54842c43 Fix wrong current limit duty cycle calculation
- prev commit assumed setting 3.3V -> 3A current limit which is wrong
- Please refer to the MAX1968 datasheet for the duty cycle
calculation equation
2024-09-25 17:20:29 +08:00
680193b34b Fix incorrect dac calibration algo
- Fix abnormally long calibration time
2024-09-20 21:21:14 +08:00
1041d3ecbb Improve the VREF calibration routine
* Fix wrong calibration of VREF on startup. Caused new v2.2.2 boards to
wrongly calibrate the zero-point to ~2.2 V instead of 1.5 V.

* Fix bootloop on some boards.

* Adjust watchdog interval accordingly.
2024-09-16 18:14:47 +08:00
136c7a0b52 Calculate current_abs_max_tec_i from all channels
Instead of picking channels 0 and 1. Helps to generalise for more than 2
channels.
2024-08-07 16:14:28 +08:00
1007982b48 clamp TEC settings to a valid & design specs range
- Not respecting the design specs can cause hardware to get stuck in unrecoverable state
2024-05-10 15:17:46 +08:00
1fcfe41a63 Add averaging filter on the pin_adc readings
- Adapted from Kirdy Firmware
- Can reduce the i_tec readings noise dispersion
2024-05-02 16:49:55 +08:00
9fce19a418 Revert "Disable feedback current readout on flawed HW Revs"
This reverts commit ae3d8b51d4.
2024-05-02 14:38:40 +08:00
00d5feaa8d Limit i_set within range of MAX1968 chip 2024-04-24 18:05:20 +08:00
09be55e12a Don't load REF pin of MAX1968 chip on HWRevs < 3.0
The REF pin of the MAX1968 on hardware revisions v2.x is missing a
buffer, loading the pin on every CPU ADC read. Avoid reading from it and
leave the pin floating on affected hardware revisions, and return the
nominal 1.5V instead.
2024-04-03 16:32:57 +08:00
76547be90a i_tec -> i_set
i_tec is reserved for the voltage signal coming out of the MAX1968 chip
for now.
2024-02-14 17:27:12 +08:00
8b975e656e Stop i_set from fluctuating in every report
i_set is a user-provided value that shouldn't fluctuate with every VREF
measurement. Storing i_set as channel state is the simplest way to avoid
that.
2024-02-14 17:21:39 +08:00
ae3d8b51d4 Disable feedback current readout on flawed HW Revs
Thermostats v2.2 and below have a noisy and offset feedback current
`tec_i` caused by missing hardware on 2 MAX1968 TEC driver pins:

1. A missing RC filter on the ITEC pin that would have isolated CPU
sampling pulses from the signal; and
2. Some missing buffering on the VREF pin that would have avoided
loading the VREF signal, preventing voltage drops from the nominal 1.5V.

Since the resulting signal `tec_i` derived from these two signals can
have an error of around +/- 100mA, and readback may affect the stability
performance of the Thermostat, disable current readback entirely on
affected hardware revisions for now.

See https://github.com/sinara-hw/Thermostat/issues/117 and
https://github.com/sinara-hw/Thermostat/issues/120.

On hardware revisions v3.x and above, this would be fixed.
2024-01-31 12:12:22 +08:00
03b4561142 Refactor current_abs_max_tec_i to use uom 2024-01-30 11:41:52 +08:00
bb4f43fe1c Remove stale reference to channel_state vref 2023-08-22 17:16:25 +08:00
9df0fe406f Remove VREF in reports
Since VREF is an implementation detail, there shouldn't be a need to
include it in reports.

The ChannelState vref is removed along with it as its only use was to
save VREF measurements for later reporting.
2023-08-22 11:40:42 +08:00
b04a61c414 Turn off LED L3 only when all channels have no PID
Change the behaviour of LED L3 to turn off only when all channels have
PID disengaged, as opposed to when any channel disengages PID.

Otherwise, when disengaging PID on a Thermostat that has had both
channels engaged in PID, the LED would turn off, even when PID is still
engaged on the other channel.

This lets the LED better reflect the status of the Thermostat as a
whole, as it would stay on as long as PID is engaged on at least one
channel.
2023-08-07 16:09:54 +08:00
570c0324b3 implement support for fan PWM
Co-authored-by: Egor Savkin <es@m-labs.hk>
Co-committed-by: Egor Savkin <es@m-labs.hk>
2023-03-22 17:15:49 +08:00
26ad2f0119 rewrite PID
Rewrite of PID according to https://hackmd.io/IACbwcOTSt6Adj3_F9bKuw PID implementation.

To migrate:
- TEC+/- pin polarity has to be reversed.
- Some saved settings might be wiped upon flashing of new firmware, back up settings before upgrade
- Min / Max integral parameters no longer exist
- kp, ki, kd will likely need to be retuned

The software has been tested on hardware with good temperature control stability.

Reviewed-on: M-Labs/thermostat#68
Co-authored-by: topquark12 <aw@m-labs.hk>
Co-committed-by: topquark12 <aw@m-labs.hk>
2022-02-24 20:16:47 +08:00
16844a1dc1 dac: fix inconsistent current output behavior due to repeated sampling of noisy vref 2021-01-25 13:51:50 +08:00
9e4d06fdbc clarify comment 2021-01-11 16:24:43 +08:00
193d54a0a6 pid: anti-windup when compliance voltage reached 2021-01-11 14:00:52 +08:00
3067b356c5 channels: add methods to retrieve actual voltage and current of TEC 2021-01-08 16:18:20 +08:00
3ba2cc9ddc channels: voltage measurement refalect actual voltage across TEC 2021-01-08 15:52:35 +08:00
e9e46b29cf pid: integrate time_delta to free gain parameters from sampling period
Fixes Gitea issue #22
2020-12-18 15:40:05 +01:00
b7e6cdbec2 pytec: measure interval 2020-12-16 22:14:21 +01:00
5ddd4d250e channels: swap adc inputs
Fixes Gitea issue #12
2020-12-07 00:22:00 +01:00
6fd5328042 channels: rm debug output 2020-10-01 02:09:43 +02:00
6e0cf26d6a export postfilter + s-h as json 2020-09-30 22:53:21 +02:00
d4901cbab1 channels: add dac_value to Report 2020-09-30 22:53:03 +02:00
62d89a68a1 pwm: export summary as json 2020-09-30 22:10:42 +02:00
11f2ebe961 channels: DRY get_center(), update vref if used 2020-09-30 19:14:15 +02:00
445cde6ae8 channels: add test report_to_json 2020-09-30 18:01:18 +02:00
6951489545 channels: add pid_output to Report 2020-09-30 18:00:16 +02:00
9e5a58cafd main: switch reports to json serialization 2020-09-27 23:58:03 +02:00
61d2cd6ecf channels: init i_set at centerpoint 2020-09-25 22:56:23 +02:00
f3ec96f425 channels: fix doc 2020-09-25 22:55:48 +02:00
a2caac0fe5 channels: power_down TEC when thermistor is not connected to ADC 2020-09-25 00:01:08 +02:00
58e648b5e0 pid::Parameters, CenterPoint: demote f32 fields to save config space 2020-09-24 20:47:02 +02:00
c5c0ce5625 channels: rm debug output 2020-09-24 19:49:11 +02:00
a84242fb1f implement setting i_set centerpoint 2020-09-23 22:30:04 +02:00