Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SoC temperature sensor #25642

Conversation

GMagician
Copy link
Contributor

@GMagician GMagician commented Apr 5, 2023

This PR resume #23765. I added more SoCs than original PR and fixed some bugs in it.

There is something that needs more coding. Some SoCs of the same family may use different calibration registers and/or different calibration temperatures.

@GMagician
Copy link
Contributor Author

GMagician commented Apr 5, 2023

I tested code with my S6 V2 that sits inside a box with a thermistor that reads temperature.

There is a difference of about 11°C between the sensors (SoC temp is bigger as expected) when just switched on the board. I'm expecting that this difference increase over time

@GMagician
Copy link
Contributor Author

There is no possibility to detect chip inside a family with a so precise degree of correctness. Some chips will not work as expected. In "internal_temp.h" there is a list of chips that may not work or work changing some values (these values are commented)

@thinkyhead thinkyhead force-pushed the STM32-internal-temperature-sensor branch 3 times, most recently from 9308443 to 197c75a Compare April 6, 2023 21:05
@thinkyhead
Copy link
Member

I had to change the logic for TEMP_SENSOR_BOARD in Configuration.h because TEMP_BOARD_PIN is not defined by pins.h until after Configuration_adv.h is already processed.

Along with that I had to alter the define of TEMP_BOARD_PIN in the pins files to make it overridable.

For the ERYONE Ery32 mini I added a warning that the TEMP_SENSOR_BOARD should be set to 13 when using TEMP_BOARD_PIN PC3.

@thinkyhead thinkyhead force-pushed the STM32-internal-temperature-sensor branch from 197c75a to f9e66c5 Compare April 6, 2023 21:12
@GMagician
Copy link
Contributor Author

I added a comment but I just see "pending" review without any possibility to see message content. Not sure anyone else can read it

@thinkyhead
Copy link
Member

I added a comment but I just see "pending" review without any possibility to see message content. Not sure anyone else can read it

Delete it and try again. Add it as a regular comment, not a "review comment."

@GMagician
Copy link
Contributor Author

Yep, but no button to add comment, just review...

@thinkyhead thinkyhead force-pushed the STM32-internal-temperature-sensor branch 2 times, most recently from 79fa3b7 to e0e7b30 Compare April 6, 2023 21:38
@thinkyhead thinkyhead force-pushed the STM32-internal-temperature-sensor branch from e0e7b30 to 2993d18 Compare April 6, 2023 21:43
@thinkyhead
Copy link
Member

Yep, but no button to add comment, just review...

Sometimes it's there and sometimes it's not.

@thisiskeithb
Copy link
Member

Instead of using the MCU temperature as a board sensor, can it be its own thing? like TEMP_SENSOR_MCU?

@GMagician
Copy link
Contributor Author

GMagician commented Apr 7, 2023

Yes it can, but would you display it somewhere or just used as thermal protection?
Because as board temp you see it on hosts

@thisiskeithb
Copy link
Member

thisiskeithb commented Apr 7, 2023

Yes it can, but would you display it somewhere or just used as thermal protection?

Since the MCU temperature is not as accurate as a physical thermistor attached to the PCB, just display. I'd be leery of using it for thermal protection due to inaccuracies.

Because as board temp you see it on hosts

I'm sure hosts will pick up the feature as time goes on.

@GMagician
Copy link
Contributor Author

Since the MCU temperature is not as accurate as a physical thermistor attached to the PCB, just display. I'd be leary of using it for thermal protection due to inaccuracies.

It shouldn't be inaccurate if you consider it as SoC temperature. When you want it to be your "board temperature" then you're always on safe side because SoC is hotter then the board ambient itself (mosfet/stepper drivers excluded of course, but when you use a thermistor, these are not checked as well)
If this sensor has to be turned to "SoC only" then code has to be completely changed, starting from coming a simple enabled/disabled feature.
Please let me know if I have to pursue such path.

@thisiskeithb
Copy link
Member

If this sensor has to be turned to "SoC only" then code has to be completely changed, starting from coming a simple enabled/disabled feature.

I know it’s more work, but it would be more in line with RRF and Klipper to have a separate MCU temperature.

@GMagician GMagician changed the title Use STM32 temperature sensor as board sensor Use SoC temperature sensor Apr 7, 2023
@GMagician
Copy link
Contributor Author

Sometimes it's there and sometimes it's not.

It reappeared once closed review!

@GMagician
Copy link
Contributor Author

GMagician commented Apr 7, 2023

Ok I tested code. Host report temperature and thermal protection is working. I can't test controller fan because I don't have it.

About SOC_PIN, maybe it may be defined into each board. This way it can be just enabled by what is now TEMP_SENSOR_SOC (or whatever will take its place) and may be added to boards which have correct STM32 supported SoC.

@thinkyhead thinkyhead force-pushed the STM32-internal-temperature-sensor branch from edb95dd to e18d8d2 Compare April 8, 2023 02:42
@@ -456,6 +456,11 @@
#define TEMP_BED_PIN -1
#endif

// Use ATEMP if TEMP_SOC_PIN is not defined
#if !defined(TEMP_SOC_PIN) && defined(ATEMP)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATEMP is defined in STM32 environment and maybe not in others. Isn't better to define TEMP_SOC_PIN directly in each MB pins definition files? I know it's a big task but it seems logic since this may be seen as an internal pin and doing that you may define it or not depending on SoC used by the board itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't better to define TEMP_SOC_PIN directly in each MB pins definition files?

If the platform provides the MCU's internal pin number as ATEMP then we don't have to define it in individual pins files. Users are encouraged to set custom pins in their configurations rather than edit pins files, so repeating this item in many pins files offers no special benefit for configuration, or indeed even for board documentation. Presumably all boards with certain MCUs will have an ATEMP so it's not a board-related feature, per se.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep but not all SoCs have the registers to properly read internal temperature, and there is no way (I found) to properly discriminate SoC inside its family. Defining it into pins may be a solution. It will be defined only for boards that uses the compatible SoCs and users may be free to change it as they want (as it's done for all other pins). SAMD51 has 2 sensors then another decision should be taken (ok, it's not supported there but it is just a way to show different platforms behaviour)

@thinkyhead thinkyhead force-pushed the bugfix-2.1.x branch 3 times, most recently from de391db to 0f34163 Compare April 12, 2023 05:14
GMagician and others added 3 commits April 13, 2023 18:24
Added define but it's really right way to do it or is it better to use a enabled/disabled option?
thinkyhead added a commit to MarlinFirmware/Configurations that referenced this pull request Apr 25, 2023
@thinkyhead thinkyhead merged commit fdd2a52 into MarlinFirmware:bugfix-2.1.x Apr 25, 2023
thinkyhead added a commit that referenced this pull request Apr 25, 2023
Co-authored-by: Scott Lahteine <[email protected]>
@GMagician GMagician deleted the STM32-internal-temperature-sensor branch April 25, 2023 07:53
thinkyhead pushed a commit that referenced this pull request Apr 26, 2023
danielcastilho pushed a commit to danielcastilho/Marlin_KP3S_Custom that referenced this pull request May 4, 2023
commit cfbd8a2
Author: thinkyhead <[email protected]>
Date:   Thu May 4 00:20:30 2023 +0000

    [cron] Bump distribution date (2023-05-04)

commit 7642bfb
Author: Keith Bennett <[email protected]>
Date:   Wed May 3 14:19:32 2023 -0700

    🐛 Fix TFT Touch Calibration overrides (MarlinFirmware#25579)

    …and other misc. display-related updates

    Co-authored-by: Scott Lahteine <[email protected]>

commit dbed3f1
Author: thinkyhead <[email protected]>
Date:   Wed May 3 00:20:18 2023 +0000

    [cron] Bump distribution date (2023-05-03)

commit e1f6435
Author: Scott Lahteine <[email protected]>
Date:   Tue May 2 17:59:27 2023 -0500

    ✨ Creality STM32F401RE board (e.g., Ender-5 S1) (MarlinFirmware#25773)

commit 21ea9bf
Author: plampix <[email protected]>
Date:   Tue May 2 23:50:07 2023 +0200

    🐛 Fix minimal M115, Cap:PROGRESS:0 (MarlinFirmware#25769)

    Co-authored-by: Scott Lahteine <[email protected]>

commit 137ea43
Author: ellensp <[email protected]>
Date:   Wed May 3 09:15:10 2023 +1200

    ✨ Creality Ender-2 (Melzi) (MarlinFirmware#25754)

commit 9aa69cb
Author: plampix <[email protected]>
Date:   Tue May 2 07:01:44 2023 +0200

    Fix G12 Nozzle Clean (MarlinFirmware#25766)

    Followup to MarlinFirmware#25666

commit 61f0dd2
Author: Scott Lahteine <[email protected]>
Date:   Mon May 1 20:23:41 2023 -0500

    🩹 Fix _CAN_HOME for new endstop flags

commit 207535a
Author: Scott Lahteine <[email protected]>
Date:   Mon May 1 20:33:58 2023 -0500

    🔨 Fix Multi-Language Menu criteria

commit 4812ed5
Author: Scott Lahteine <[email protected]>
Date:   Mon May 1 18:45:42 2023 -0500

    🎨 Misc. code cleanup

commit f89fa4c
Author: thinkyhead <[email protected]>
Date:   Tue May 2 00:24:02 2023 +0000

    [cron] Bump distribution date (2023-05-02)

commit b042567
Author: Scott Lahteine <[email protected]>
Date:   Mon May 1 18:15:31 2023 -0500

    🩹 Fix TFT sanity error

commit 4bed8a8
Author: Scott Mikutsky <[email protected]>
Date:   Mon May 1 02:10:46 2023 -0400

    🐛 Fix STM32 USB disconnect behavior (MarlinFirmware#25762)

commit 006a9e5
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 30 23:10:44 2023 -0500

    🩹 NOZZLE_CLEAN_PATTERN_* Followup

    Followup to MarlinFirmware#25666

commit 55cbe15
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 30 19:14:53 2023 -0500

    🔧 Remove config.ini obsolete options

commit 35dd6a3
Author: thinkyhead <[email protected]>
Date:   Mon May 1 00:22:20 2023 +0000

    [cron] Bump distribution date (2023-05-01)

commit 9773160
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 30 18:24:05 2023 -0500

    🔧 Character display has boot screen

commit f246e0d
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 30 18:12:13 2023 -0500

    🔧 Fix X2/Y2 axis pins check

commit 4937a64
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 30 18:12:21 2023 -0500

    🧑‍💻 Use NUM_AXIS_ARRAY

commit b88ab39
Author: ellensp <[email protected]>
Date:   Mon May 1 09:52:29 2023 +1200

    🐛 Fix Ender-2 Stock LCD on MELZI_CREALITY (MarlinFirmware#25759)

commit 3b50b6a
Author: Davide Rombolà <[email protected]>
Date:   Sun Apr 30 23:36:47 2023 +0200

    🔧 Allow BLTOUCH_HS_EXTRA_CLEARANCE == 0 (MarlinFirmware#25760)

commit ec6bc15
Author: Scott Lahteine <[email protected]>
Date:   Sat Apr 29 20:10:33 2023 -0500

    🐛 Fix FT Motion reversed Z

commit 5aef2c0
Author: thinkyhead <[email protected]>
Date:   Sun Apr 30 00:22:44 2023 +0000

    [cron] Bump distribution date (2023-04-30)

commit 4c033c3
Author: Scott Lahteine <[email protected]>
Date:   Sat Apr 29 12:34:56 2023 -0500

    🧑‍💻 Tweak homing debug

commit f9db5ab
Author: thinkyhead <[email protected]>
Date:   Sat Apr 29 00:20:26 2023 +0000

    [cron] Bump distribution date (2023-04-29)

commit c5a2e41
Author: James Pearson <[email protected]>
Date:   Fri Apr 28 23:30:15 2023 +0100

    🐛 Probe behavior corrections (MarlinFirmware#25631)

    Co-authored-by: Scott Lahteine <[email protected]>
    Co-authored-by: David Fries <[email protected]>

commit 7d95928
Author: Scott Lahteine <[email protected]>
Date:   Fri Apr 28 13:38:59 2023 -0500

    🐛 Fix auto pullup/down settings

    Followup to MarlinFirmware#25748

commit a872232
Author: Scott Lahteine <[email protected]>
Date:   Fri Apr 28 11:03:38 2023 -0500

    🔧 Move MMU section

commit 6323de3
Author: Scott Lahteine <[email protected]>
Date:   Fri Apr 28 11:03:20 2023 -0500

    🔨 Fix LPC faux pins

    Followup to MarlinFirmware#25332

commit 0e2c5b4
Author: thinkyhead <[email protected]>
Date:   Fri Apr 28 00:21:29 2023 +0000

    [cron] Bump distribution date (2023-04-28)

commit 959f730
Author: TheSnowfield <[email protected]>
Date:   Thu Apr 27 20:37:11 2023 +0800

    ✨ AUTO_REPORT_REAL_POSITION option for M154 (MarlinFirmware#25738)

commit 9a7d9e6
Author: Martin Turski <[email protected]>
Date:   Thu Apr 27 14:05:24 2023 +0200

    🧑‍💻 Optimize PlatformIO source filtering (MarlinFirmware#25332)

    Co-authored-by: Scott Lahteine <[email protected]>

commit 774861b
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 20:04:01 2023 -0500

    🔧 Endstops followup

commit 04a25ab
Author: thinkyhead <[email protected]>
Date:   Thu Apr 27 00:22:32 2023 +0000

    [cron] Bump distribution date (2023-04-27)

commit 467ab74
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 14:56:23 2023 -0500

    🧑‍💻 Simplify endstops config (MarlinFirmware#25748)

commit 358a54e
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 14:39:56 2023 -0500

    🔨 Servo Timer 1 with STM32F103RC_fysetc (MarlinFirmware#25741)

commit 79b4555
Author: Giuliano Zaro <[email protected]>
Date:   Wed Apr 26 21:38:39 2023 +0200

    🔧 Thermistor 100 : SoC sensor (MarlinFirmware#25745)

    Followup to MarlinFirmware#25642

commit d364bab
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 14:29:21 2023 -0500

    🧑‍💻 Change HAL_PATH macro for easier HAL relocation (MarlinFirmware#25743)

commit 1771d7a
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 13:51:33 2023 -0500

    ✅ Skip change alerts in CI test

commit 68f7478
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 13:50:45 2023 -0500

    🎨 Misc. fixes, cleanup

commit 08edb62
Author: Scott Lahteine <[email protected]>
Date:   Wed Apr 26 02:57:53 2023 -0500

    🔧 Extra axis endstop defaults

commit a4cc9b6
Author: thinkyhead <[email protected]>
Date:   Wed Apr 26 00:21:12 2023 +0000

    [cron] Bump distribution date (2023-04-26)

commit f5a905a
Author: Giuliano Zaro <[email protected]>
Date:   Tue Apr 25 04:51:44 2023 +0200

    ✨ TEMP_SENSOR_SOC (MarlinFirmware#25642)

    Co-authored-by: Scott Lahteine <[email protected]>

commit d1738e9
Author: Scott Lahteine <[email protected]>
Date:   Mon Apr 24 21:40:08 2023 -0500

    🔧 Fix LCD_SERIAL_PORT config

commit 650e6fc
Author: Anson Liu <[email protected]>
Date:   Mon Apr 24 22:07:12 2023 -0400

    🔨 Prevent SlowSoftWire + Wire name conflict (MarlinFirmware#25707)

commit c034819
Author: thinkyhead <[email protected]>
Date:   Tue Apr 25 00:20:57 2023 +0000

    [cron] Bump distribution date (2023-04-25)

commit 077a620
Author: Scott Lahteine <[email protected]>
Date:   Mon Apr 24 05:24:10 2023 -0500

    📝 Developer note in boards.h

commit 2954bf2
Author: Scott Lahteine <[email protected]>
Date:   Mon Apr 24 00:24:40 2023 -0500

    🌐 Replace '=' with '{' for substitution

commit 743903b
Author: Nick <[email protected]>
Date:   Mon Apr 24 01:50:39 2023 +0100

    🩹 Fix Anycubic PlayTune (MarlinFirmware#25735)

    Followup to MarlinFirmware#25690

    Co-authored-by: Scott Lahteine <[email protected]>

commit 02a14d3
Author: thinkyhead <[email protected]>
Date:   Mon Apr 24 00:21:28 2023 +0000

    [cron] Bump distribution date (2023-04-24)

commit df4f806
Author: plampix <[email protected]>
Date:   Mon Apr 24 01:12:47 2023 +0200

    ✨ NOZZLE_CLEAN_PATTERN_* (MarlinFirmware#25666)

    Co-authored-by: Scott Lahteine <[email protected]>

commit 9902097
Author: ellensp <[email protected]>
Date:   Mon Apr 24 11:11:02 2023 +1200

    🔨 Gather GD32, suppress redundant #error (MarlinFirmware#25665)

    Co-authored-by: Scott Lahteine <[email protected]>

commit 10ed5ab
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 23 03:17:55 2023 -0500

    🚸 Improve PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED (MarlinFirmware#25681)

commit 1669356
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 23 03:00:56 2023 -0500

    🔧 Split followup

commit aaf55a2
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 23 02:07:42 2023 -0500

    🩹 Fix UBL safe measure move with extra axes

    Followup to 7e79fc5

commit 69f8da4
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 23 01:58:01 2023 -0500

    🔧 Split Changes.h from SanityCheck.h (MarlinFirmware#25732)

commit f0f7ec8
Author: Scott Lahteine <[email protected]>
Date:   Sun Apr 23 00:47:44 2023 -0500

    🧑‍💻 Stepper::set_directions() => apply_directions()

commit 921591d
Author: Scott Lahteine <[email protected]>
Date:   Sat Apr 22 23:15:31 2023 -0500

    🧑‍💻 SDIO_SUPPORT => ONBOARD_SDIO

commit 5664c02
Author: Scott Lahteine <[email protected]>
Date:   Sat Apr 22 22:43:09 2023 -0500

    🧑‍💻 Generalize SDSUPPORT as HAS_MEDIA

    In preparation for single- and multi-volume refactoring.

commit ce85b98
Author: Jason Smith <[email protected]>
Date:   Sat Apr 22 20:27:01 2023 -0700

    🩹 Relocate Fan conditionals, sanity-checks (MarlinFirmware#25731)

    Co-authored-by: Scott Lahteine <[email protected]>

commit 95cfc98
Author: thinkyhead <[email protected]>
Date:   Sun Apr 23 00:22:56 2023 +0000

    [cron] Bump distribution date (2023-04-23)

commit 5d8d38a
Author: ellensp <[email protected]>
Date:   Sun Apr 23 08:59:51 2023 +1200

    🩹 Status / Host Prompt followup (MarlinFirmware#25720)

    Followup to MarlinFirmware#25679

    Co-authored-by: Scott Lahteine <[email protected]>

commit 3117339
Author: thinkyhead <[email protected]>
Date:   Sat Apr 22 12:06:22 2023 +0000

    [cron] Bump distribution date (2023-04-22)

commit c8ed795
Author: ellensp <[email protected]>
Date:   Sat Apr 22 21:09:17 2023 +1200

    🔧 Permit extrude without hotend (MarlinFirmware#25709)

    Co-authored-by: Scott Lahteine <[email protected]>

commit 89ccede
Author: Alexey D. Filimonov <[email protected]>
Date:   Sat Apr 22 12:06:19 2023 +0300

    🎨 Clean up TFT Color UI display items (MarlinFirmware#25712)

    Co-authored-by: Scott Lahteine <[email protected]>

commit fba1f83
Author: ellensp <[email protected]>
Date:   Sat Apr 22 21:02:51 2023 +1200

    🩹 Fix Anycubic PlayTune (MarlinFirmware#25728)

    Followup to MarlinFirmware#25690

commit 726de7e
Author: Nomis-97 <[email protected]>
Date:   Sat Apr 22 10:16:19 2023 +0200

    🐛 Fix MKS Gen-L MOSFETs (MarlinFirmware#25717)

commit 4233e48
Author: Scott Lahteine <[email protected]>
Date:   Sat Apr 22 01:56:10 2023 -0500

    🚸 MarlinUI Endstop Test Screen, and more (MarlinFirmware#25667)

commit 98277f2
Author: thinkyhead <[email protected]>
Date:   Fri Apr 21 00:20:12 2023 +0000

    [cron] Bump distribution date (2023-04-21)

commit ded9ffa
Author: Scott Lahteine <[email protected]>
Date:   Thu Apr 20 17:35:20 2023 -0500

    🧑‍💻 Apply INVERT_DIR to SET_STEP_DIR

commit 335ba32
Author: Scott Lahteine <[email protected]>
Date:   Thu Apr 20 17:21:59 2023 -0500

    🩹 Fix Core Kinematics BABYSTEP_XY
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 8, 2023
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 8, 2023
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 17, 2023
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 17, 2023
tspiva pushed a commit to tspiva/Marlin that referenced this pull request May 25, 2023
tspiva pushed a commit to tspiva/Marlin that referenced this pull request May 25, 2023
Andy-Big pushed a commit to Andy-Big/Marlin_FB_Reborn that referenced this pull request Jul 14, 2023
Andy-Big pushed a commit to Andy-Big/Marlin_FB_Reborn that referenced this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants