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

How to set current limit? #47

Open
ArhumJain opened this issue Dec 25, 2023 · 6 comments
Open

How to set current limit? #47

ArhumJain opened this issue Dec 25, 2023 · 6 comments

Comments

@ArhumJain
Copy link

ArhumJain commented Dec 25, 2023

This has been mentioned in several other issues but as far as I can tell no solution has been found. Other stepper libraries allow passing in an absolute current limit in milliamps given an Rsense value. The board I'm using has a 110mOhm Rsense value but the README current setting functions all take percentages resulting in a scaled value that scales - what? How do I know what current the driver is limiting to? I don't want to accidentally fry my stepper motor.

Otherwise, how would I know what the driver is setting the current limit to without guessing and checking to see if my motor is heating up? I don't want to undertune it as I'd like to take advantage of my motor's full capacity but also don't want to risk damaging it as I wait to see if the current scaled setting makes the motor reach a certain heating point.

@peterpolidoro
Copy link
Member

Yes this is a good point. I have been wanting to add this feature for a while. The Rsense value may be the only piece of information that the user needs to provide to the library to make the library work with a specific hardware configuration, but I want to make sure that is true for every driver setting before adding this feature. Open loop control, for example, just does PWM of the source voltage, so the current through the motor windings is a function of the source voltage value, the percent on time, the resistance of the motor windings, and the rotational speed of the motor. Closed loop control uses the Rsense resistors to set the output, but the current through the motor windings might only work properly if the calibration sequence has been performed properly. Just adding a simple function to convert percent to current based on the Rsense value may be misleading if it does not set the current properly, leading to burned out motors as well.

@Defozo
Copy link

Defozo commented Mar 10, 2024

My stepper has very little torque on a 100% current setting. What should I do to increase that?

@StefanL38
Copy link

Your documentation is pretty good. Lot's of details with schematics, lot's of example-codes.

So far your library provides only this percentage value.
Can you at least add information with example values for everything.
I mean real numbers for stepper-motor specs
saying stepper-motor coil-resistance: 5 Ohms
max current: 0.8 A
continual voltage: 4V

TMC2209 is set to "what do I know mode" then
using RUN_CURRENT_PERCENT = 100
means: THIS number "NNNN" of mA
or
as you are talking about open-loop control:
is one possible mode of the TMC2209 "open-loop" which means the TMC2209 does NOT use the R_sense-resistors?

Well if this is the case your library is almost useless. Almost any modern application uses higher voltages and current-limiting through R_sense resistors. This is 50% of the features these stepper-drivers offer compared to simple H-bridges

@peterpolidoro
Copy link
Member

The TMC2209 uses the sense resistors in some modes and ignores them in other modes. The run current setting meaning changes slightly depending on the mode. You are free to use whatever modes you want. Calculating the actual motor current depends on multiple settings and the user's exact setup. Read the datasheet.

@astorun
Copy link

astorun commented May 22, 2024

Any update on this implementation? I wonder if we can issue explicit current definition for motors by using sense resistor value.

@peterpolidoro
Copy link
Member

Yes I plan on adding this. It may take a few weeks, though. I am thinking of doing a major reorganization of all of the code in this library and add requested features such as these.

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

No branches or pull requests

5 participants