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

driver_cs has been added to tmc5160 #491

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

HonestBrothers
Copy link
Contributor

@HonestBrothers HonestBrothers commented Dec 17, 2024

Previously, CS (current scaler) has been automatically set to 31. The only time CS would only change was to adjust the holding_current. However, some users found certain motor, driver, and voltage combinations to produce less than ideal results on tmc5160 drivers. Noise, VFA's and overheating were a common occurrence, particularly on high amp drivers and high power motors.

According to the excel spreadsheet provided by Trinamic to tune the 5160 tmc drivers, the CS value should be set so that Rsense on the spreadsheet matches the 'sense_resistor' value as defined in printer.cfg. By adjusting the CS value so that these two match, we can define much more adequate hysteresis values. This means that high power motors can now be run at high voltage (>48V) and their current may be run at RMS value without overheating.

GS out of bounds warnings added to 5160.

Target current won't be able to be achieved if GS is > 256. Default set GS to 256 if it was over. New code pushes a warning to the user about the CS value being too low and needing to be higher to achieve the proper current.

TODO: better ihold handling.
@CarVac
Copy link

CarVac commented Jan 6, 2025

What are those .idea files? I think they need to be removed.

Also, the config_changes needs tweaking. CS doesn't necessarily have to be set based on current as calculated by TMC5160_calcs, it can be that value or higher (since globalscaler is still available to reduce the run current.

@HonestBrothers
Copy link
Contributor Author

What are those .idea files? I think they need to be removed.

PyCharm bloat. I'll remove them.

Also, the config_changes needs tweaking. CS doesn't necessarily have to be set based on current as calculated by TMC5160_calcs, it can be that value or higher (since globalscaler is still available to reduce the run current.

Correct, working on an error if it's lower to where the target current can't be reached.

@HonestBrothers
Copy link
Contributor Author

I also made an update to 2130
I implemented math.ceil for cs here:

       cs = (math.ceil(
            int(32.0 * sense_resistor * current * math.sqrt(2.0) / vref)
            - 1
        ))

instead of the default behavior where 0.5 gets added to vref:

            cs = (
                int(32.0 * sense_resistor * current * math.sqrt(2.0) / vref + 0.5)
                - 1
            )

I'm not sure why 0.5 was being added other than rounding. It's not in the datasheets.

@HonestBrothers
Copy link
Contributor Author

@rogerlz

In tmc.py can we change:

        self.config_hold_current = config.getfloat(
            "hold_current", max_current, above=0.0, maxval=max_current
        )

to:

        self.config_hold_current = config.getfloat(
            "hold_current", run_current, above=0.0, maxval=max_current
        )

or would that break things?

@CarVac
Copy link

CarVac commented Jan 6, 2025

Make sure to fix the "xlxs" typo in the GLOBALSCALER_ERROR (line 265 in tmc5160.py)

@agravelot
Copy link

related to Klipper3d/klipper#6644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants