Compare commits

..

249 Commits

Author SHA1 Message Date
atse 3b461d0f8e Put temperature on anyway 2024-03-18 10:40:29 +08:00
atse 2bd0dc60f3 More detailed text for load/save on all channels 2024-03-18 10:40:29 +08:00
atse 398ff33254 Change confusing PID limit terminology 2024-03-18 10:40:29 +08:00
atse 5fc2a12491 Don't plot tec_i (for hwrev v2 and below) 2024-03-18 10:40:29 +08:00
atse 4894c7456a asyncio.TimeoutError not needed 2024-03-18 10:40:29 +08:00
atse d6e3ccb1c8 Move Postfilter Rate setting to Thermostat Config 2024-03-18 10:40:29 +08:00
atse ad1c241f80 Temperatures to 4 dp, not 6 sig. fig 2024-03-18 10:40:29 +08:00
atse d6659cd027 Update nix repos and use repo qasync and pyqtgraph
Now that they are updated, no reason to use our own.
2024-03-18 10:40:29 +08:00
atse 7659fa42e6 String quotes 2024-03-18 10:40:29 +08:00
atse 1d06b6b042 Fix setpoint line label to not display old values
Setpoint line still displays 0 °C sometimes!
2024-03-18 10:40:29 +08:00
atse 5306de35d1 anti-aliasing 2024-03-18 10:40:29 +08:00
atse ecb907fd8f Get rid of the setpoint line out-of-range problem 2024-03-18 10:40:29 +08:00
atse 0deb7a0057 Comment change 2024-03-18 10:40:29 +08:00
atse 104023919e Fix unicode 2024-03-18 10:40:29 +08:00
atse 024f37effb i_set in front of measured current 2024-03-18 10:40:29 +08:00
atse 25cbc16c2d Move t_line setting to method, fixes 0°C bug
The 0 °C fix is an ugly one, ideally we should only update the label
when visibility returns.
2024-03-18 10:40:29 +08:00
atse ccaf1efe04 Adjust exit text 2024-03-18 10:40:29 +08:00
atse 6662450c39 Longer duration tooltip for zero limits warning 2024-03-18 10:40:29 +08:00
atse fbb112b884 Connect on enter press in the connection details 2024-03-18 10:40:29 +08:00
atse a1c1db1f3e Add exit option in connection menu 2024-03-18 10:40:29 +08:00
atse a47f4efc99 Number of channels generalisation 2024-03-18 10:40:29 +08:00
atse 0724a67ca5 variable name change 2024-03-18 10:40:29 +08:00
atse 0641c5329a Comment 2024-03-18 10:40:29 +08:00
atse 5128bcab9d More general activater 2024-03-18 10:40:29 +08:00
atse 1b946a3f2f Control Method simplifcation 2024-03-18 10:40:29 +08:00
atse b7d2fccbef Simplify postfilter stuff 2024-03-18 10:40:29 +08:00
atse f284337f7c Improve name 2024-03-18 10:40:29 +08:00
atse 8a327f3445 Set Limits Warning Fix 2024-03-18 10:40:29 +08:00
atse 988df1a3d5 No need for list now that params are all singular 2024-03-18 10:40:29 +08:00
atse e2d07eafd4 Put PID output min and max into its own section
The critical difference between this and the max_i_pos, max_i_neg pair
is that output_max and output_min can have the same sign, meaning that
it is possible that PID current can be limited to positive values only.
2024-03-18 10:40:29 +08:00
atse 2f133aaf59 Remove siPrefixes for temperature units 2024-03-18 10:40:29 +08:00
atse 2995b6d97a Sync 2024-03-18 10:40:29 +08:00
atse 3cded20e7a Show all current values in mA
Since the max and min is known as (-3A, 3A) on the thermostat TEC ports,
there is no need to use other SI prefix units.
2024-03-18 10:40:29 +08:00
atse 7ba8181752 Limit test current 2024-03-18 10:40:29 +08:00
atse 02ecf2702f Separate min and max current 2024-03-18 10:40:29 +08:00
atse 920caf00f0 Add docstring 2024-03-18 10:40:29 +08:00
atse 8e961ac414 Patch to avoid floating point error of temperature
A more complete system of dealing with floating point imprecision on the
way.
2024-03-18 10:40:29 +08:00
atse ac643a62e0 Add info boxes when loading/saving configs 2024-03-18 10:40:29 +08:00
atse 8d61dce630 Status bar limits warning 2024-03-18 10:40:29 +08:00
atse 2e35db6410 More decimals for current too 2024-03-18 10:40:29 +08:00
atse 2c4367bfa2 Add the rest of the modules 2024-03-18 10:40:29 +08:00
atse 0e83a8daaf Switch to pyproject.toml 2024-03-18 10:40:29 +08:00
atse b46856b285 Remove old GUI and update docs 2024-03-18 10:40:29 +08:00
atse d43ad092c3 Increase icon resolution 2024-03-18 10:40:29 +08:00
atse 4be427e579 Add window icon 2024-03-18 10:40:29 +08:00
atse 93da7a261f Get rid of all translation things for now 2024-03-18 10:40:29 +08:00
atse 074f3b87cd Correct units and stuff 2024-03-18 10:40:29 +08:00
atse e85824b0b0 More decimals for temp 2024-03-18 10:40:29 +08:00
atse e6e445fd1b Only log the autotuned params 2024-03-18 10:40:29 +08:00
atse ca8418dc19 Spinner 2024-03-18 10:40:29 +08:00
atse 143cf165ff Remove bottom settings group tooltip 2024-03-18 10:40:29 +08:00
atse df16e39d6c Correct about thermostat var 2024-03-18 10:40:29 +08:00
atse 5654e03152 Legend names & order 2024-03-18 10:40:29 +08:00
atse a83ce50063 Autotune 2024-03-18 10:40:29 +08:00
atse 0ed89f7d03 Don't set_param that much 2024-03-18 10:40:29 +08:00
atse eec41c67d9 No more _command 2024-03-18 10:40:29 +08:00
atse 6655256230 Shorten channel to ch 2024-03-18 10:40:29 +08:00
atse de6ff6aeaf Postfilter option revamped 2024-03-18 10:40:29 +08:00
atse 1f7f0aa757 No private to slot 2024-03-18 10:40:29 +08:00
atse 7de1fc69e0 Set param mroe 2024-03-18 10:40:29 +08:00
atse b49218acfa Load config 2024-03-18 10:40:29 +08:00
atse 790e340be3 Don't use _command 2024-03-18 10:40:29 +08:00
atse 2a00e6681c Both command and param 2024-03-18 10:40:29 +08:00
atse c00e148719 Change name 2024-03-18 10:40:29 +08:00
atse 0dc585b743 Refactor into class 2024-03-18 10:40:29 +08:00
atse a9961458fe Refactor a bit to update lines only via poll
Model-View-Controller thing, don't edit UI when UI value changed
2024-03-18 10:40:29 +08:00
atse 80a366f64c Try triggering on show 2024-03-18 10:40:29 +08:00
atse 2e6887eedd Beta -> B 2024-03-18 10:40:19 +08:00
atse 37bd854bc4 Depend on temperature only 2024-03-18 10:39:07 +08:00
atse 7b1f6a7287 Legend 2024-03-18 10:39:07 +08:00
atse 4823f5fe09 Improve conditionals 2024-03-18 10:39:07 +08:00
atse fa9297b0f7 Only show either one or another, pid or not 2024-03-18 10:39:07 +08:00
atse 785ef3521b Interface change 2024-03-18 10:39:07 +08:00
atse aaf37d687a Absolute 2024-03-18 10:39:07 +08:00
atse c7277e0abd Switch to using set_param if possible 2024-03-18 10:39:07 +08:00
atse 75491a4595 CommandsParameter useless anyway 2024-03-18 10:39:07 +08:00
atse db078d1f69 Put thermostat parameters constant into mainwindow 2024-03-18 10:39:07 +08:00
atse 72a7831786 Forget about sizePolicy 2024-03-18 10:39:07 +08:00
atse d24e6ace19 Fan layout misspelled 2024-03-18 10:39:07 +08:00
atse 37c9fc342e Use setRange 2024-03-18 10:39:07 +08:00
atse ae98fb333c Remove sizePolicy horizontal/vertical stretch 0
Default anyway
2024-03-18 10:39:07 +08:00
atse 2319f1a6f0 Remove extra horizontal layout 2024-03-18 10:39:07 +08:00
atse 3bccaeab25 No text why set text 2024-03-18 10:39:07 +08:00
atse 272e3a160b setValue 2024-03-18 10:39:07 +08:00
atse 176313f0a3 Remove setObjectName 2024-03-18 10:39:07 +08:00
atse fb43268d73 Read extra load 2024-03-18 10:39:07 +08:00
atse d02e4243f7 Don't use dynamic properties 2024-03-18 10:39:07 +08:00
atse 1099b7a846 Remove 2024-03-18 10:39:07 +08:00
atse 0e894dc450 Move report mode bookkeeping into ClientWatcher 2024-03-18 10:39:07 +08:00
atse 518284c0b6 Fix redundant code report mode 2024-03-18 10:39:07 +08:00
atse b40bf97941 Privatise ClientWatcher member variables 2024-03-18 10:39:07 +08:00
atse 0190cf4a8d Current
Also plot iset
2024-03-18 10:39:07 +08:00
atse fd5a9b3b89 Better tooltip 2024-03-18 10:39:07 +08:00
atse e86b6552b9 Remove stuff that would update on polling anyway 2024-03-18 10:39:07 +08:00
atse 28d9547984 Clear warning 2024-03-18 10:39:07 +08:00
atse de20e8dd54 Add proper set fan curve coroutine method 2024-03-18 10:39:07 +08:00
atse cf9d72f2fd Add proper set_fan and get_fan coroutine methods 2024-03-18 10:39:07 +08:00
atse b2b399bf8e Handle timeout errors 2024-03-18 10:39:07 +08:00
atse 12ca3c1d87 Use start and end session nomenclature
Helps when we also inherit from QObject, which already has connect and
disconnect methods.
2024-03-18 10:39:07 +08:00
atse b06fc11211 Remove is_ prefix 2024-03-18 10:39:07 +08:00
atse 790ce88345 Bail
Disconnects everything, stops all polling
2024-03-18 10:39:07 +08:00
atse 49bf4ebc92 Proper report 2024-03-18 10:39:07 +08:00
atse 77089b3e98 Proper timeout implementation 2024-03-18 10:39:07 +08:00
atse 7ce39b3840 Move global params into window 2024-03-18 10:39:07 +08:00
atse 57ad076beb Fan group to be set based on hw_rev only 2024-03-18 10:39:07 +08:00
atse 02146f7ce0 Add optional channel selection for save/load 2024-03-18 10:39:07 +08:00
atse a784d96f77 List comprehension 2024-03-18 10:39:07 +08:00
atse 376fe484fd Full name of the parameter tree 2024-03-18 10:39:07 +08:00
atse 59cab70e8a Unused import 2024-03-18 10:39:07 +08:00
atse 3030fd3d3a Don't use payload to get channel
Use parent param instead
2024-03-18 10:39:07 +08:00
atse 73f6aaf527 Max current plus-or-minus better informs 2024-03-18 10:39:07 +08:00
atse 0899b583f8 Convinience to turn down fan on connect 2024-03-18 10:39:07 +08:00
atse 34917f8e21 Better send_command 2024-03-18 10:39:07 +08:00
atse 1fc681e214 Match statement 2024-03-18 10:39:07 +08:00
atse 98107f5143 Set status first in _on_connection_changed 2024-03-18 10:39:07 +08:00
atse e051deb507 host 2024-03-18 10:39:07 +08:00
atse d66d07df81 Enable axis linking functionality 2024-03-18 10:39:07 +08:00
atse 79daa75383 Shield pending commands from cancellation 2024-03-18 10:39:07 +08:00
atse 535954abae Implement IPv4 settings dialog 2024-03-18 10:39:07 +08:00
atse 355d0cce2c Add ipv4 config 2024-03-18 10:39:07 +08:00
atse 088e3ab280 Use direct calling in report mode 2024-03-18 10:39:07 +08:00
atse 3ab905f63e Add load and save configs 2024-03-18 10:39:07 +08:00
atse de5295c992 Implement DFU mode 2024-03-18 10:39:07 +08:00
atse 6a902e5f9d Change name of tec_client 2024-03-18 10:39:07 +08:00
atse 17ea0e252a Move fan signal connection into menu setup 2024-03-18 10:39:07 +08:00
atse f2d172d6a1 Split menu setup method per menu 2024-03-18 10:39:07 +08:00
atse c40b9d765c Add about thermostat window 2024-03-18 10:39:07 +08:00
atse df49ca6393 Use graph emoji for plot settings 2024-03-18 10:39:07 +08:00
atse 58f42bcac3 Add tooltip to settings buttons 2024-03-18 10:39:07 +08:00
atse 3e9e16758a Don't enabled thermostat settings before connect 2024-03-18 10:39:07 +08:00
atse d6082d7e62 Give proper names to settings buttons 2024-03-18 10:39:07 +08:00
atse e7b17a0252 No :port 2024-03-18 10:39:07 +08:00
atse c21770b91f Don't translate ip 2024-03-18 10:39:07 +08:00
atse 56b72b7bea Not just ip, can put domain name too, or "host" 2024-03-18 10:39:07 +08:00
atse ff81b447b2 More elegant connection stopping 2024-03-18 10:39:07 +08:00
atse 5651931766 Add timeout to connect call 2024-03-18 10:39:07 +08:00
atse fc389ab4dd Add load and save config menu items 2024-03-18 10:39:07 +08:00
atse 89fdc8ba8a Add about thermostat menu item
Meant to display hardware rev stuff, does nothing right now
2024-03-18 10:39:07 +08:00
atse c11eb45cee Add network settings menu option
Also does nothing for now
2024-03-18 10:39:07 +08:00
atse 68b3042c4f Add DFU mode menu option
Does nothing for now
2024-03-18 10:39:07 +08:00
atse 8c9cefd448 Use _on_connection_changed(False) 2024-03-18 10:39:07 +08:00
atse 7200a8334b Reset button 2024-03-18 10:39:07 +08:00
atse 2fde01ee9c Save the entire hw_rev data
Not just fan_pwm_recommended
2024-03-18 10:39:07 +08:00
atse 8303c52469 Put connection details in connection button menu 2024-03-18 10:39:07 +08:00
atse b263251317 Move host selection into menu too 2024-03-18 10:39:07 +08:00
atse 4c3b41e08b Move fan throttling warning to the right 2024-03-18 10:39:07 +08:00
atse d0519813a9 Split the settings and plotting menus 2024-03-18 10:39:07 +08:00
atse 9ce8ec02e5 Crude relocation of port spinbox from .ui file 2024-03-18 10:39:07 +08:00
atse 1fe589f677 Space out bottom bar properly 2024-03-18 10:39:07 +08:00
atse 193dc940eb Remove leftover lines 2024-03-18 10:39:07 +08:00
atse 0faafc8e81 Crude removal of fan group from .ui file 2024-03-18 10:39:07 +08:00
atse 3433191d33 Add line at PID temp 2024-03-18 10:39:07 +08:00
atse 552b2382e5 Report mode functionality 2024-03-18 10:39:07 +08:00
atse f9ccbfe53a Add crosshair for better read of values 2024-03-18 10:39:07 +08:00
atse 9251677698 Add samples box in menu 2024-03-18 10:39:07 +08:00
atse a2db23f7b9 Add clear graphs context menu item 2024-03-18 10:39:07 +08:00
atse 59e8a1481d Plot temperature and current graphs
- Have units

- Samples are limited

- pglive is used for better live graphs
-- Also fixes bug with constantly updating normal pyqtgraphs where it
will bug out if right-clicked on and context menu is brought up
--Since pglive requires pyqtgraph == 0.13.3, upgrade pyqtgraph to that
too.
2024-03-18 10:39:07 +08:00
atse dd53135d4c Plus or minus symbol on swing 2024-03-18 10:39:07 +08:00
atse c4c65de8f4 Add save to flash paramtree item 2024-03-18 10:39:07 +08:00
atse dd69bd1d80 Hide paramtree headers 2024-03-18 10:39:07 +08:00
atse 867b99fe61 Add postfilter config 2024-03-18 10:39:07 +08:00
atse aa2005cec8 Add i_set 2024-03-18 10:39:07 +08:00
atse 7d4069497e Add pwm update 2024-03-18 10:39:07 +08:00
atse 61d207aa20 Add thermistor config & sync
Note: The formula is not actually Steinhart-Hart
2024-03-18 10:39:07 +08:00
atse 159939e93d Connect up pid 2024-03-18 10:39:07 +08:00
atse 224365dad2 Connect up report update 2024-03-18 10:39:07 +08:00
atse 43c7f2d7c6 Use proper symbols in units, and add units
PID parameters are not actually dimensionless, and their units can be
deduced from the input unit and the output (actuator) unit.
2024-03-18 10:39:07 +08:00
atse a53d27c183 Fix formatting 2024-03-18 10:39:07 +08:00
atse caf2efb046 Might as well be a pass, doens't exec 2024-03-18 10:39:07 +08:00
atse c2cb04b461 Loop through trees to set them up 2024-03-18 10:39:07 +08:00
atse 97bd5c3539 Remove unused as clause 2024-03-18 10:39:07 +08:00
Egor Savkin 39ea85798f Add paramtree view, without updates
Signed-off-by: Egor Savkin <es@m-labs.hk>

Fix signal blocker argument -atse
2024-03-18 10:39:07 +08:00
atse a824eb5b2b Add explanation of report rate 2024-03-18 10:39:07 +08:00
atse 60a050a3fc Swap order connected first 2024-03-18 10:39:07 +08:00
atse a6c06d27a2 Add tooltip to fan 2024-03-18 10:39:07 +08:00
atse d2ef7487f3 Arrange context menu items to be in order 2024-03-18 10:39:07 +08:00
atse 46046791cf Disable auto fan box if adjusted while auto 2024-03-18 10:39:07 +08:00
atse 69393d0189 Steal fan group and port??? Somehow 2024-03-18 10:39:07 +08:00
atse edd43c5ce3 Max the label 2024-03-18 10:39:07 +08:00
atse 7ce6bba351 Context menu by QToolButton 2024-03-18 10:39:07 +08:00
atse 253eb182d7 Remove redundant return 2024-03-18 10:39:07 +08:00
atse 0982ce0f92 Correct order once the tec_client disconnects to
stop watching the client first
2024-03-18 10:39:07 +08:00
atse 0aea353b7d Only set connecting task to None once 2024-03-18 10:39:07 +08:00
atse 2431b3a912 Update and add docstrings to aioclient 2024-03-18 10:39:07 +08:00
atse 2107c6c009 Conslidate connect & disconnect actions 2024-03-18 10:39:07 +08:00
atse ee0cb74ed5 Change name of button slot 2024-03-18 10:39:07 +08:00
atse d0d22b36f9 Turn on_connection_changed to coroutine
Further compresses the connect
2024-03-18 10:39:07 +08:00
atse 61ed1fa28a Simplify stuff a bit 2024-03-18 10:39:07 +08:00
atse 11730909ba Change statement order up a bit 2024-03-18 10:39:07 +08:00
atse 7c3a112501 Init client_watcher once 2024-03-18 10:39:07 +08:00
atse a91c8cc6ba Init client once
No none-ing
2024-03-18 10:39:07 +08:00
atse 2a8d240986 Put the connecting task in aioclient 2024-03-18 10:39:07 +08:00
atse 4f246780b4 Rearrange bottom bar for new context menu 2024-03-18 10:39:07 +08:00
atse 127fa31d7b Remove is running loop variable
Just use Task.done()
2024-03-18 10:39:07 +08:00
atse 91f9345bf2 Catch a more specific exception 2024-03-18 10:39:07 +08:00
atse f50820167a Add stop connection button
Stuff to add to stop button
2024-03-18 10:39:07 +08:00
atse 4fd355ac7b Set fan slider value minimum to 1, not 0 2024-03-18 10:39:07 +08:00
atse 252f9300b0 Fix Slot decorators and types 2024-03-18 10:39:07 +08:00
atse e7fd44a6fd Handle UI when fan_pwm is 0 2024-03-18 10:39:07 +08:00
atse fb3cf3d279 Fix fan warning wording 2024-03-18 10:39:07 +08:00
atse 56fc2a8a90 Only warn about fan pwm when not at full strength 2024-03-18 10:39:07 +08:00
atse 7cc3ce2890 Replace fan group highlighting with warning icon
Highlighting is too confusing
2024-03-18 10:39:07 +08:00
atse f9817eb9e8 Grammar 2024-03-18 10:39:07 +08:00
atse ad74bf739b Update fan slider value immediately after fan auto 2024-03-18 10:39:07 +08:00
atse 8294e6b289 Use slider signal argument to set fan value 2024-03-18 10:39:07 +08:00
atse e407461034 Set client to none if failed to connect
Fixes connect button behaviour after accidental disconnect
2024-03-18 10:39:07 +08:00
atse 0523a24544 Start running only when task is running 2024-03-18 10:39:07 +08:00
atse 8cf0f2c0be Lock connection details while connecting
Fix connect button behaviour
2024-03-18 10:39:07 +08:00
atse 3b0c630d43 Add unit to report spinbox 2024-03-18 10:39:07 +08:00
atse 4e81510175 Cancel task to stop watch 2024-03-18 10:39:07 +08:00
atse be2fc799df Disconnect client too on close 2024-03-18 10:39:07 +08:00
atse 0b13fe4fc3 Close client_watcher on closeEvent not aboutToQuit
Mirrors
2024-03-18 10:39:07 +08:00
atse d7b9bb8771 Rearrange client_watcher to hold its own task 2024-03-18 10:39:07 +08:00
atse 0cdbb0cc7a Update fan too 2024-03-18 10:39:07 +08:00
atse f4c0d39758 More helpful tooltip 2024-03-18 10:39:07 +08:00
atse 707ab3ae18 Fix hardware revision showing major.major 2024-03-18 10:39:07 +08:00
atse 6fe48f9035 Remove unused 'as' clause 2024-03-18 10:39:07 +08:00
atse 2cc3490941 Get rid of global client 2024-03-18 10:39:07 +08:00
atse 89e03c45a7 Remove client_watcher global 2024-03-18 10:39:07 +08:00
atse 81f8978d94 Gather client_watcher managment into connect 2024-03-18 10:39:07 +08:00
atse d293242f09 Invert logic, connect first 2024-03-18 10:39:07 +08:00
atse 2d71b24d4a Make Ui_MainWindow a superclass of our main window
Gets rid of the global ui.
2024-03-18 10:39:07 +08:00
atse 4cc45e1447 Get rid of app global
QApplication is a singleton, no need for global
2024-03-18 10:39:07 +08:00
atse ff8908700c Change title 2024-03-18 10:39:07 +08:00
atse ec233b0d76 Stop polling drift
Just waiting for the update_s doesn't take into account the time to
execute update_params, and causes time drift.
2024-03-18 10:39:07 +08:00
atse 890308325a Finish moving over to qasync
Also:
-Add aioclient

The old client is synchronous and blocking, and the only way to achieve
true asynchronous IO is to create a new client that interfaces with
asyncio.

-Make the GUI `nix run`-able
2024-03-18 10:39:07 +08:00
Egor Savkin b03804c785 Try move from Qthreads to qasync
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-03-18 10:39:07 +08:00
Egor Savkin 0151dc3e47 Create client watcher, that would poll Thermostat for config
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-03-18 10:39:07 +08:00
Egor Savkin fbb2e30f8b Create basic GUI, that would connect and control thermostat's fan
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-03-18 10:39:07 +08:00
Egor Savkin 987d09efbf Update nix repos
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-03-18 10:39:06 +08:00
topquark12 11819bdbea update docs 2024-03-18 10:39:06 +08:00
topquark12 4acd679fb1 add autotune 2024-03-18 10:39:06 +08:00
topquark12 3a74ff5423 WIP: adding autotune 2024-03-18 10:39:06 +08:00
topquark12 a73d83107e fix docs, fix GUI param ranges 2024-03-18 10:38:59 +08:00
topquark12 1be0e418cc fix whitespace error 2024-03-18 10:37:39 +08:00
topquark12 cb3680c593 bi-dir sync, minimum working prototype 2024-03-18 10:37:39 +08:00
topquark12 92b2130684 sync tree param from TEC 2024-03-18 10:37:39 +08:00
topquark12 87cd20799c add sync from TEC 2024-03-18 10:37:39 +08:00
topquark12 e3a6dc4249 add param tree, param tree inactive 2024-03-18 10:37:39 +08:00
topquark12 cdffe95f16 add voltage monitoring 2024-03-18 10:37:39 +08:00
topquark12 6ec9cba10c fix typo 2024-03-18 10:37:39 +08:00
topquark12 316cedab2c refactor with classes 2024-03-18 10:37:39 +08:00
topquark12 04f6fd6920 add graph legends 2024-03-18 10:37:39 +08:00
topquark12 938ac4dfb2 add more graphs in 2x2 grid 2024-03-18 10:37:39 +08:00
topquark12 8e08975b85 plot both channel temperatures 2024-03-18 10:37:39 +08:00
topquark12 80c65000b0 fix pyqtgraph on nixos 2024-03-18 10:37:39 +08:00
topquark12 2f4f22892f add pyqtgraph 2024-03-18 10:37:39 +08:00
atse 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
atse 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
3 changed files with 13 additions and 16 deletions

View File

@ -2,11 +2,13 @@ use smoltcp::time::{Duration, Instant};
use uom::si::{
f64::{
ElectricPotential,
ElectricCurrent,
ElectricalResistance,
ThermodynamicTemperature,
Time,
},
electric_potential::volt,
electric_current::ampere,
electrical_resistance::ohm,
thermodynamic_temperature::degree_celsius,
time::millisecond,
@ -29,6 +31,7 @@ pub struct ChannelState {
/// i_set 0A center point
pub center: CenterPoint,
pub dac_value: ElectricPotential,
pub i_set: ElectricCurrent,
pub pid_engaged: bool,
pub pid: pid::Controller,
pub sh: sh::Parameters,
@ -44,6 +47,7 @@ impl ChannelState {
adc_interval: Duration::from_millis(100),
center: CenterPoint::Vref,
dac_value: ElectricPotential::new::<volt>(0.0),
i_set: ElectricCurrent::new::<ampere>(0.0),
pid_engaged: false,
pid: pid::Controller::new(pid::Parameters::default()),
sh: sh::Parameters::default(),

View File

@ -113,16 +113,8 @@ impl<'a> Channels<'a> {
}
pub fn get_i(&mut self, channel: usize) -> ElectricCurrent {
let center_point = match channel.into() {
0 => self.channel0.vref_meas,
1 => self.channel1.vref_meas,
_ => unreachable!(),
};
// let center_point = self.get_center(channel);
let r_sense = ElectricalResistance::new::<ohm>(R_SENSE);
let voltage = self.get_dac(channel);
let i_tec = (voltage - center_point) / (10.0 * r_sense);
i_tec
let i_set = self.channel_state(channel).i_set;
i_set
}
/// i_set DAC
@ -137,7 +129,7 @@ impl<'a> Channels<'a> {
voltage
}
pub fn set_i(&mut self, channel: usize, i_tec: ElectricCurrent) -> ElectricCurrent {
pub fn set_i(&mut self, channel: usize, i_set: ElectricCurrent) -> ElectricCurrent {
let vref_meas = match channel.into() {
0 => self.channel0.vref_meas,
1 => self.channel1.vref_meas,
@ -145,10 +137,11 @@ impl<'a> Channels<'a> {
};
let center_point = vref_meas;
let r_sense = ElectricalResistance::new::<ohm>(R_SENSE);
let voltage = i_tec * 10.0 * r_sense + center_point;
let voltage = i_set * 10.0 * r_sense + center_point;
let voltage = self.set_dac(channel, voltage);
let i_tec = (voltage - center_point) / (10.0 * r_sense);
i_tec
let i_set = (voltage - center_point) / (10.0 * r_sense);
self.channel_state(channel).i_set = i_set;
i_set
}
pub fn read_dac_feedback(&mut self, channel: usize) -> ElectricPotential {

View File

@ -207,11 +207,11 @@ impl Handler {
}
fn set_center_point(socket: &mut TcpSocket, channels: &mut Channels, channel: usize, center: CenterPoint) -> Result<Handler, Error> {
let i_tec = channels.get_i(channel);
let i_set = channels.get_i(channel);
let state = channels.channel_state(channel);
state.center = center;
if !state.pid_engaged {
channels.set_i(channel, i_tec);
channels.set_i(channel, i_set);
}
send_line(socket, b"{}");
Ok(Handler::Handled)