CoolStep and Stealthchop

The background

I am ready to do some more in depth tuning but I don’t know how the programming works here. I asked about it in the fluid discord and it doesn’t seem to be an easy answer.

While we can not use sensorless homing we do have access to the stallguard functionality. If you turn on debugging for any driver you will see that while in motion you get a force reading of some sort.
SG_Val:255
If you help the motor move that number gets higher.
If you hinder the motion that number gets lower.

So coolstep uses that stallguard number to dynamically turn up the stepper current and turn the current down when it is not needed. This means if it is tuned reasonably well we can use a much higher current to the steppers and not suffer from all the extra heat as it will not be turned up unless it is needed.

So in FluidNC has two main setting for us regarding this.

toff_stealthchop: 5
toff_coolstep: 3

Stealthchop can go from 2-15. In Marlin you set a speed at which the driver changes from stealthchop (quiet less powerful) to spreadcycle ( loud more powerful). We actually probably do not care about this, we don’t go fast enough to need this…I would like to tune it to 120-150mm/s or so, though, just in case.

Coolstep can also be 2-15. This should be some sort of high and low threshold at which the current turns up and down.

The issue

What the heck do those numbers do? I searched fluidnc for those two definitions and I have no idea what they are used for.
The tmc driver specs do not list those.
The Arduino library FluidNC uses also does not seem to list those settings.

So how do we tune this?

Useful links
Fluidwiki - Axes | Wiki.js
2209 datasheet - https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2209_Datasheet_V103.pdf
TMC library - GitHub - teemuatlut/TMCStepper

2 Likes

Your datasheet link didn’t work for me. But I found one here

The TCOOLTHRS is probably what is getting set. It is still named that in the teemuatlut library. But I have to dig into the fluid code to see where it actually goes.

I’m on my phone, so it is a little painful, but it looks like _toff_coolstep is defined in TrinamicBase and then not used in the 2209 version. The 2209 inherits from the TrinamicUartDriver, which inherits from TrinamicBase.

My guess is that it goes nowhere, so changing it does nothing. There is a print that shows the TCOOLTHRS setting. But I bet it just never gets set.

I think you’d really want access to the semin, semax and cool threshold.

Thanks!

I just tested a bunch of stuff, the numbers did not seem to change anything, 2 or 15 seemed the same for both settings.

switch (_mode) {
            case TrinamicMode ::StealthChop:
                log_debug(axisName() << " StealthChop");
                tmc2209->en_spreadCycle(false);
                tmc2209->pwm_autoscale(true);
                break;
            case TrinamicMode ::CoolStep:
                log_debug(axisName() << " Coolstep");
                tmc2209->en_spreadCycle(true);
                tmc2209->pwm_autoscale(false);
                break;
            case TrinamicMode ::StallGuard:  //TODO: check all configurations for stallguard
            {
                auto axisConfig     = config->_axes->_axis[this->axis_index()];
                auto homingFeedRate = (axisConfig->_homing != nullptr) ? axisConfig->_homing->_feedRate : 200;
                log_debug(axisName() << " Stallguard");
                tmc2209->en_spreadCycle(false);
                tmc2209->pwm_autoscale(true);
                tmc2209->TCOOLTHRS(calc_tstep(homingFeedRate, 150.0));
                tmc2209->SGTHRS(_stallguard);
                break;
            }
        }

        // dump the registers. This is helpful for people migrating to the Pro version
        log_verbose("CHOPCONF: " << to_hex(tmc2209->CHOPCONF()));
        log_verbose("COOLCONF: " << to_hex(tmc2209->COOLCONF()));
        log_verbose("TPWMTHRS: " << to_hex(tmc2209->TPWMTHRS()));
        log_verbose("TCOOLTHRS: " << to_hex(tmc2209->TCOOLTHRS()));
        log_verbose("GCONF: " << to_hex(tmc2209->GCONF()));
        log_verbose("PWMCONF: " << to_hex(tmc2209->PWMCONF()));
        log_verbose("IHOLD_IRUN: " << to_hex(tmc2209->IHOLD_IRUN()));

This is interesting. From FluidNC. Stealthchop has pwm autoscale…Coolstep is just spreadcycle (that doesn’t seem right), Stallguard seems like it is coolstep to me. I need to figure out what pwm autoscale is.

That is what I thought. I assumed the toffcoolstep setting adjusted that window wider and wider in 15 steps or something by percentage…If that makes sense. It seems that is not the case.

I am soooo not good at this stuff. Google google search ctrl+F…

I was digging into the toff_stealthchop setting, hoping that I could use it to turn off stealthchop and get more torque. If I remember right, it only affected the pulse shape in some way.
I think there is an issue open on the fluidnc git to add an option turn off stealthchop and enable other modes, but the devs seemed a bit clueless about what the different modes did.

I think they just have their hands full and since they move fine they have other priorities. If we keep poking around and understand some of the issues and can’t figure it out I might know someone.

The stealthchop settings for 3D printing don’t make sense for CNC. When you go fast on the CNC, you are usually traveling. So you really need more torque at the low speeds (and still the highest speeds, but not the middle).

Cool step seems good. But you’d have to add some settings and edit the fluidnc code to set the values on the stepper instance. Then tune it.

1 Like

Digging around seeing if I can make sense of it. Libraries are a bit of a mystery to me. I am starting to see how it passes info back and forth, I think. Always learn’n.

so, um, not to intrude here, but the title… is it supposed to say Stealchop? Lambchop’s evil twin perhaps? :stuck_out_tongue_winking_eye:

4 Likes

Whoops

1 Like