Menu

Trinamic drivers setting

Collet
2024-10-02
2024-10-22
  • Collet

    Collet - 2024-10-02

    Hi Robert, all

    I have some comments about the settings for TMC drivers (at least the TMC2209) described in your user guide document pages 262 to 264, and also to some parameters that can be worth testing (like the interpoaltion flag you added in the last firmware version)
    In the optimizing settings, page 263 there is in the example code for setting a call to :

    mystepper->rms_current( TMC2209CURRENT )
    and few lines after
    mystepper->irun(21); // irun = CS (current scale setting) on the sheet

    this is actually setting two times the current, since rms_current method is calculating and setting the current scale (as well as the vsense if curent scale is too small)

    it is then better/simpler to call rms_current function which doing the current scale calculations and setting for you.
    Be aware that the TMC2209CURRENT is RMS, which is 1.4 smaller than the max curent found in motor datasheets (for a motor with 400mA current the RMS current is slighlty less than 300mA )

    //extract of tmcstepper arduino code:

    void TMCStepper::rms_current(uint16_t mA) {
    uint8_t CS = 32.01.41421mA/1000.0(Rsense+0.02)/0.325 - 1;
    // If Current Scale is too low, turn on high sensitivity R_sense and calculate again
    if (CS < 16) {
    vsense(true);
    CS = 32.0
    1.41421mA/1000.0(Rsense+0.02)/0.180 - 1;
    } else { // If CS >= 16, turn off high_sense_r
    vsense(false);
    }

    if (CS > 31)
    CS = 31;

    irun(CS);
    ihold(CS*holdMultiplier);
    //val_mA = mA;
    }

    Also it can be interesting to "play with" the possibility to set a hold current multiplier, which is allowing to have the coil power on but with reduced power/heating (this is the same rms_current call, with a second member being the hold multiplier .
    And another setting ( either through the define, or in future version through the management server) can be choosing between the two chopper modes (stealthchop or spreadcycle), allowing to choose between noiseless and torque performance and accuracy depending of the needs

    Regards
    Joël

     

    Last edit: Collet 2024-10-02
  • brownrb

    brownrb - 2024-10-03

    Hi Joël
    Thanks for the suggestions, I am always open to anything that improves the code and makes things better.

    As I think I explained a number of times, the tmc code was not written soly by me and involved others, though I did have some input into it, it was more like a joint effort. I could not test the tmc code because I do not have any tmc modules. I seem to remember a lot of discussion in the beta team whould helped-tested the code for tmc.I am extermely greatful to the help given by Paul and team for this work and documentation supporting it. There would have been none had it not been so.

    I takes me longer and longer to write code now, and I know that I am not up to that task looking ahead. Honestly, it will take me several days of re-reading your post for me to grasp it, Not because I am an idiot - but the brain ain't working like it used to.

    If you would like to make the changes to the code I am more prepared to drop that in. I also have a good suggestion by Eric concerning the motor board configs and again, it is hard for me to grasp now.

    Peehaps it might be better to move the firmware back to github. The reason it moved was because I was trying to keep everything together, rather than having bits here and there. Git hub is not a great tool when one combines it with documents, board designs, etc, etc

    regards
    Robert

     

    Last edit: brownrb 2024-10-03
  • Collet

    Collet - 2024-10-03

    Hi Robert,

    I am also very greatful to you and all people working on this master piece (Paul, Eric ,....). I can help, write some "code tuning"and post here or there and contribute a little (but it will be very little, compared to the work already done) or on a github if you open one.
    Nevertheless a big thank you and Hat Off for this and also the others "equipments" (SQM, boards..)

    Regards
    Joël

     
  • Collet

    Collet - 2024-10-03

    Here the code with my proposed modifications, for anyone wanting to test.
    driverboard.cpp and related tmcstepper_defines.h.

    Regards
    Joël

     

    Last edit: Collet 2024-10-03
  • Carlos Izquierdo Vázquez

    Good morning.
    I gave up on the home sensor a long time ago, since it was impossible for me to make it work.
    Would these changes make this easier?
    Would they work with the LILYGO board?
    Thank you!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.