-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Export tmc2240 driver temperature #6145
Conversation
8ca11d2
to
15a2cc2
Compare
Thx for the ping! I would prefer to use the temperature attribute, when a real temperature exists. Like the tmc2240 and have the warning/error flag separated from the temperature. |
Well, the advantage of having it exported in As such, my vote goes into adding the temperature directly to the |
I agree with both @meteyou and @pedrolamas about having the temperature in the tmc object. What I'm curious about is what should be done with these warning flags? The tmc2130 and tmc2660 have fixed |
@leptun First, I would only include the driver flags and display the status such as "normal/cold", "warning", or "error: overheated". Can you read the otpw value from the registers and convert this threshold value for the configurable thresholds into degrees Celsius? If so, this temperature could also be displayed in the GUI. Of course, this function could be extended to make the threshold configurable via the interface if Klipper allows this. Currently, I don't see the advantage for the user of being able to configure this easily. I think this is more of a "pro" function. It's enough if it can be done via register values in the printer.cfg. |
FYI, the warning flags are already exported in the tmc objects - they are in the "drv_status" field ( https://www.klipper3d.org/Status_Reference.html#tmc-drivers ). The flag to temperature mapping is: The tmc2208/9 also have an "otpw" field, but it's a configurable alias for the t120-t157 fields, so I don't think there is any gain in using that flag on those drivers as it is just as easy to access the unaliased temperature flags. As indicated at the top of this PR, we could map the above flags to the new "temperature" field. It sounds like that is not desirable. We could also make some new field (eg, "coarse_temperature") with the mapping (if that makes it easier for the frontends). -Kevin |
To expand on the "drv_status" field, the following was part of a test I ran yesterday (on the code from this PR): If a tmc2208 driver got warm I'd expect it to report something like: If a tmc2208 went over 143 degrees I'd guess both the "t120" and "t143" fields would be set simultaneously - I'm not sure. Cheers, |
I think you are correct. That's also what I understood from the datasheet. What about tmc2240? The default value of |
Right, the "otpw" flag is also available on tmc2240. Like tmc2208/9 it doesn't provide any value as it's simpler to directly use the raw temperature. If you want my 2 cents, I don't see a value in configuring otpw, as it doesn't provide any new information to Klipper. I'd say better to keep the code simple. Cheers, |
Well, in that case I'll close my PR.
Not entirely true. At least for tmc2209, I read that when an OT event occurs, the driver is disabled until the temperature drops and OTPW is cleared. So otpw adds hysteresis to the overheat event. Not sure if regular users would want to configure this, but it's not completely useless even if you don't read that flag. |
otpw can also be routed to an irq pin on some drivers. In both cases, a configurable "otpw" has no value in the context of Klipper. Cheers, |
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
15a2cc2
to
83308a1
Compare
Thanks for the feedback. I have committed this change. (There is now a "temperature" field available for tmc2240 drivers; no additional logic has been added for the otpw and tXXX fields.) -Kevin |
This is a proposal to report the tmc2240 driver temperature in a new "temperature" field in the "tmc2240 stepper_x" status.
The temperature reporting in the tmc2240 is a nice feature - it would be nice to be able to see this temperature on the common Klipper frontends. So, in some sense it might be better to export this information using an existing "temperature_sensor" report. However, the tmc drivers are a bit unique in that the information is only queried when the driver is "enabled". (When the driver is not enabled, Klipper wont query the information because it is common for users to disable motor power, which disables communication with the driver.) Exporting the information in the "tmc" status section makes this easier, but it would require front-end changes to display the temperature.
@Arksine , @meteyou , @pedrolamas - do you have any thoughts on this?
This PR only updates the tmc2240 (which provides a full temperature report). It would also be possible to export a pseudo-temperature on the other tmc drivers. Other tmc drivers generally report "temperature warning" flags. It would be possible to map those flags to this new "temperature" field. If we did this, most drivers would normally report 0 degrees, until a temperature warning occurred - in which case the reported temperature would report 100 (or 120, 147, etc. depending on the tmc driver).
@leptun , @bigtreetech - fyi.
-Kevin