Welcome! Log In Create A New Profile

Advanced

TMC2130 spreadCycle configuration

Posted by butchja 
TMC2130 spreadCycle configuration
July 30, 2017 03:48AM
Hi, I am fiddeling around with my TMC2130 stepper drivers. I use the newly implemented support in marlin for these drivers with SPI interface. Now, I want to use them in spreadcycle mode. But when I do so I always get a chirping sound from the copper. I measured it with approx. 8kHz. This is way in the audible range. Trinamic itself suggests to use a chopper frequency between 20kHz and 50kHz. This is done by modifing the off_time by register. With the internal clock of 12MHz used by these boards a register value of 3 or 4 would by good. My question is, is there a way to modify the programmed value to the stepper drivers in marlin?
Re: TMC2130 spreadCycle configuration
August 04, 2017 03:00PM
For those who need a clue to configure them. Now I have a chopper frequency of 21kHz. Should be not audibly by any human.

HW part:
Apparently my motors and drivers did not match so well. I increased my motors supply voltage by a cheap ebay step up converter from 12V to 26V. To do so I cutted motor supply pin to my ramps and fed it directly from above by wire. I have removed my diode protector boards because they have reference to my ramp's 12V.

Edited 2 time(s). Last edit at 08/05/2017 04:41PM by butchja.
Re: TMC2130 spreadCycle configuration
August 04, 2017 03:02PM
And here is my configuration_adv.h section for TMC2130

Config is with coolstep and reduced hold current.
To use sensorless homing you need to wire a specific diag pin to your endstop inputs.

#define HAVE_TMC2130

#if ENABLED(HAVE_TMC2130)

  // CHOOSE YOUR MOTORS HERE, THIS IS MANDATORY
  #define X_IS_TMC2130
  //#define X2_IS_TMC2130
  #define Y_IS_TMC2130
  //#define Y2_IS_TMC2130
  //#define Z_IS_TMC2130
  //#define Z2_IS_TMC2130
  //#define E0_IS_TMC2130
  //#define E1_IS_TMC2130
  //#define E2_IS_TMC2130
  //#define E3_IS_TMC2130
  //#define E4_IS_TMC2130

  /**
   * Stepper driver settings
   */

  #define R_SENSE           0.11  // R_sense resistor for SilentStepStick2130
  #define HOLD_MULTIPLIER    0.5  // Scales down the holding current from run current
  #define INTERPOLATE          1  // Interpolate X/Y/Z_MICROSTEPS to 256

  #define X_CURRENT          636  // rms current in mA. Multiply by 1.41 for peak current.
  #define X_MICROSTEPS        32  // 0..256

  #define Y_CURRENT          636
  #define Y_MICROSTEPS        32

  #define Z_CURRENT         1000
  #define Z_MICROSTEPS        16

  //#define X2_CURRENT      1000
  //#define X2_MICROSTEPS     16

  //#define Y2_CURRENT      1000
  //#define Y2_MICROSTEPS     16

  //#define Z2_CURRENT      1000
  //#define Z2_MICROSTEPS     16

  //#define E0_CURRENT      1000
  //#define E0_MICROSTEPS     16

  //#define E1_CURRENT      1000
  //#define E1_MICROSTEPS     16

  //#define E2_CURRENT      1000
  //#define E2_MICROSTEPS     16

  //#define E3_CURRENT      1000
  //#define E3_MICROSTEPS     16

  //#define E4_CURRENT      1000
  //#define E4_MICROSTEPS     16

  /**
   * Use Trinamic's ultra quiet stepping mode.
   * When disabled, Marlin will use spreadCycle stepping mode.
   */
  //#define STEALTHCHOP

  /**
   * Let Marlin automatically control stepper current.
   * This is still an experimental feature.
   * Increase current every 5s by CURRENT_STEP until stepper temperature prewarn gets triggered,
   * then decrease current by CURRENT_STEP until temperature prewarn is cleared.
   * Adjusting starts from X/Y/Z/E_CURRENT but will not increase over AUTO_ADJUST_MAX
   * Relevant g-codes:
   * M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given.
   * M906 S1 - Start adjusting current
   * M906 S0 - Stop adjusting current
   * M911 - Report stepper driver overtemperature pre-warn condition.
   * M912 - Clear stepper driver overtemperature pre-warn condition flag.
   */
  //#define AUTOMATIC_CURRENT_CONTROL

  #if ENABLED(AUTOMATIC_CURRENT_CONTROL)
    #define CURRENT_STEP          50  // [mA]
    #define AUTO_ADJUST_MAX      636  // [mA], 1300mA_rms = 1840mA_peak
    #define REPORT_CURRENT_CHANGE
  #endif

  /**
   * The driver will switch to spreadCycle when stepper speed is over HYBRID_THRESHOLD.
   * This mode allows for faster movements at the expense of higher noise levels.
   * STEALTHCHOP needs to be enabled.
   * M913 X/Y/Z/E to live tune the setting
   */
  //#define HYBRID_THRESHOLD

  #define X_HYBRID_THRESHOLD     80  // [mm/s]
  #define X2_HYBRID_THRESHOLD    100
  #define Y_HYBRID_THRESHOLD     80
  #define Y2_HYBRID_THRESHOLD    100
  #define Z_HYBRID_THRESHOLD       4
  #define Z2_HYBRID_THRESHOLD      4
  #define E0_HYBRID_THRESHOLD     30
  #define E1_HYBRID_THRESHOLD     30
  #define E2_HYBRID_THRESHOLD     30
  #define E3_HYBRID_THRESHOLD     30
  #define E4_HYBRID_THRESHOLD     30

  /**
   * Use stallGuard2 to sense an obstacle and trigger an endstop.
   * You need to place a wire from the driver's DIAG1 pin to the X/Y endstop pin.
   * If used along with STEALTHCHOP, the movement will be louder when homing. This is normal.
   *
   * X/Y_HOMING_SENSITIVITY is used for tuning the trigger sensitivity.
   * Higher values make the system LESS sensitive.
   * Lower value make the system MORE sensitive.
   * Too low values can lead to false positives, while too high values will collide the axis without triggering.
   * It is advised to set X/Y_HOME_BUMP_MM to 0.
   * M914 X/Y to live tune the setting
   */
  #define SENSORLESS_HOMING

  #if ENABLED(SENSORLESS_HOMING)
    #define X_HOMING_SENSITIVITY  19
    #define Y_HOMING_SENSITIVITY  19
  #endif

  /**
   * You can set your own advanced settings by filling in predefined functions.
   * A list of available functions can be found on the library github page
   * [github.com]
   *
   * Example:
   * #define TMC2130_ADV() { \
   *   stepperX.diag0_temp_prewarn(1); \
   *   stepperX.interpolate(0); \
   * }
   */
   /*#define  TMC2130_ADV() { \
   }*/

  #define  TMC2130_ADV() { \
   stepperX.external_ref(1); \
   stepperY.external_ref(1); \
   stepperX.blank_time(24);\
   stepperY.blank_time(24);\
   stepperX.off_time(2);\
   stepperY.off_time(2);\
   stepperX.hysterisis_start(0);\
   stepperY.hysterisis_start(0);\
   stepperX.hysterisis_low(13); \
   stepperY.hysterisis_low(13); \
   stepperX.run_current(31);\
   stepperY.run_current(31);\
   stepperX.hold_current(12);\
   stepperY.hold_current(12);\
   stepperX.power_down_delay(2); \
   stepperY.power_down_delay(2); \
   stepperX.coolstep_min_speed(300);\ 
   stepperY.coolstep_min_speed(300);\
   stepperX.sg_min(4);\
   stepperY.sg_min(4);\
   stepperX.sg_max(10);\
   stepperY.sg_max(10);\
   stepperX.smart_min_current(1);\
   stepperY.smart_min_current(1);\
   stepperX.sg_step_width(8);\
   stepperY.sg_step_width(8);\
   stepperX.sg_current_decrease(32);\
   stepperY.sg_current_decrease(32);\
  }

Edited 5 time(s). Last edit at 08/06/2017 06:43AM by butchja.
Re: TMC2130 spreadCycle configuration
August 04, 2017 06:13PM
Thanks. Good reference.

Ed
Re: TMC2130 spreadCycle configuration
August 04, 2017 11:47PM
Quote
butchja
I increased my motors supply voltage by a cheap ebay step up converter from 12V to 26V. To do so I cutted motor supply pin to my ramps and fed it directly from above by wire. I have removed my diode protector boards because they have reference to my ramp's 12V.

Yeah... But unless you can supply serious current, that isn't going to accomplish what you want. The whole reason you drive the steppers with higher voltage is to push more wattage (power) to them. If this converter can't drive many amps of current, it is actually going to hurt you.
Re: TMC2130 spreadCycle configuration
August 05, 2017 04:30AM
I understood the function of the drivers as follows. They are switch mode constant current converters. First they switch supply voltage directly to the motor. Since the windings are inductors the current rises slowly. Once the current has reached the configured current the supply voltage will be switched off. As a result the current decreases until a hysteresis value has reached. If reached the drivers switches voltage back on, again. If you increase your supply voltage the rise and fall time (slew rate) will increase, too. As a result your driver has to switch more often to maintain a regulated current window. Your frequency is rising with higher voltage, lower hysteresis and lower "waiting/off" times.

In my case I have motors with 900mA and a voltage at this operating point of 4V. 12V are enough to fry them anyways. 26V would make it faster grinning smiley
Re: TMC2130 spreadCycle configuration
August 05, 2017 03:23PM
Nice to hear people actually using these =)

If you find good configuration parameters, let me know and I'll try them out and push to upstream with the next TMC related PR. I haven't spent much time optimizing the spreadCycle parameters as I'm always using stealthChop.

As you may have found out, editing the stepper_indirection is not actually necessary, as you can override any setting with the TMC2130_ADV.
So if you want to edit the off_time setting, you'd just put stepperX.off_time(3) in the TMC2130_ADV.

I looked at your advanced config and I'd like to point out that you don't need the stepper.interpolate() in there as that is already configured with #define INTERPOLATE.
Also it seems like you're setting the driver to use external Vref. It looks very much intentional but I thought I'd point it out. You also then need to take into account that since your current settings are so low, Marlin will enable the vsense bit and this will affect your current calculations. I'm curious why you would want to run them in analog mode as one of the most appealing aspects of the drivers is that I don't have to fiddle with the potentiometer.

The spreadCycle chopping has a few more steps to it than that. There are actually two slow decays and one fast decay.

CoolStep is not yet utilized. The value is set to the maximum to make sure the stepping speed is never lower (as in higher) than that.
Re: TMC2130 spreadCycle configuration
August 05, 2017 04:32PM
stealthChop is great but has its drawbacks with torque. I am optimistic to get a silent printer with a good configured spreadcycle and I have small crappy motors I want to get the maximum out of them.

I was not sure if TMC2130_ADV() overwrites anything, thanks. With the point of external reference... I simply had too high currents with internal reference and do not ask me why... I switched to external ref to scale it manually down. But I want to learn so I will update my postings as far as I got new results.

Coolstep is not active as I figured out, too. I connected my bench supply to my motors voltage pins. I am playing around with stepperX.coolstep_min_speed(...); but with no result, yet.
Re: TMC2130 spreadCycle configuration
August 05, 2017 04:49PM
Sure thing, spreadCycle is fine and there's nothing wrong with using the pots. I don't know why you wouldn't be able to tune down the currents with the SPI control but I digress.

I'm planning on adding coolStep configuration at some point, but as said, I usually run stealthChop which is not compatible with coolStep.

You might be interested in my personal fork where I push the latest developments on the Trinamic driver, in particular the return of M122 TMC debugging command. It will show you a lot of the driver configuration and status parameters as well as anything from the DRV_STATUS register.
[github.com]
However, it's not pushed online just yet as I still need to sort everything into sensible commits. Check sometime later tomorrow.
Edit: I've now pushed the changes online.

Edited 1 time(s). Last edit at 08/05/2017 06:07PM by GhostPrototype.
Re: TMC2130 spreadCycle configuration
August 06, 2017 04:24AM
I have implemented a first prove of concept configuration. You can find it in my configuration_adv.h post above. I will install your fork on my printer and try your debug command.

Edited 1 time(s). Last edit at 08/06/2017 04:25AM by butchja.
Re: TMC2130 spreadCycle configuration
August 06, 2017 04:40AM
first I was not able to compile. had to change following

serial.cpp
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) MYSERIAL.write(' '); }
to
void serial_spaces(uint8_t count) { while (count--) MYSERIAL.write(' '); }


had to uncomment TMC_ADC();:
stepper.cpp
// TRAMS, TMC2130 and TMC2208 advanced settings
#if HAS_TRINAMIC
//TMC_ADV();
#endif

after successful compiling motors does not move (SPI configuration?)
Re: TMC2130 spreadCycle configuration
August 06, 2017 04:44AM
Hard to say without the error messages. If you uncomment TMC_ADV() then your advanced configuration will not be applied. I would also suggest power cycling the whole machine to clear the registers.
Re: TMC2130 spreadCycle configuration
August 06, 2017 05:28AM
I have tried power cycle

C:\Users\x\AppData\Local\Temp\arduino_build_245800\sketch\serial.cpp: In function 'void serial_spaces(uint8_t)':
serial.cpp:36: error: 'PROPORTIONAL_FONT_RATIO' was not declared in this scope
 void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) MYSERIAL.write(' '); }

                                               ^

C:\Users\x\AppData\Local\Temp\arduino_build_245800\sketch\stepper.cpp: In static member function 'static void Stepper::init()':
stepper.cpp:1021: error: 'TMC_ADV' was not declared in this scope
     TMC_ADV()
             ^
Re: TMC2130 spreadCycle configuration
August 06, 2017 05:43AM
The reason you're getting 'TMC_ADV' was not declared in this scope is because the ADV define was renamed from TMC2130_ADV() to TMC_ADV()
I suspect you replaced the configuration_adv.h file with the one you had and one that is from a previous version. This could explain why you're getting the serial error. However, check that the configuration_adv.h contains the #define PROPORTIONAL_FONT_RATIO line.
Re: TMC2130 spreadCycle configuration
August 06, 2017 11:08AM
I will try that as soon as my current print is done. I am printing a 5h print with coolstep and stop current reduction. Yet, I got not a missing step. I have noticed stealthcopp and the configuration of spreadcycle made no audible difference in my case.
Re: TMC2130 spreadCycle configuration
August 07, 2017 02:55PM
I have migrated my configuration to your fork. All is complied, thanks. Following:
1. Internal reference works now, yey drinking smiley
2. I have activated #define TMC_DEBUG and get nothing back when sending M122 S1, how I use it?
3. Now my motors run on 11kHz and not ~21kHz anymore. I have double checked my configuration_adv.h and figured out a difference in stepper_indirection.cpp with no effect, checked to deactivate TMC_DEBUG, but still the same...

I uploaded my working firmware here, if it helps
[www.dropbox.com]

and your fork with my config
[www.dropbox.com]

Edited 1 time(s). Last edit at 08/07/2017 03:12PM by butchja.
Re: TMC2130 spreadCycle configuration
August 07, 2017 04:27PM
M122 S1 requires enabling "MONITOR_DRIVER_STATUS" in configuration_adv.h

I don't have a scope to measure the frequency, but it's determined by the toff and tbl, yes? Those values seem to hold over to the driver registers.
I'll need to read up on the spreadCycle theory again.

I could also add more data to the M122 output if that is needed.

Edited 1 time(s). Last edit at 08/07/2017 04:28PM by GhostPrototype.
Re: TMC2130 spreadCycle configuration
August 07, 2017 05:31PM
I not alway use my scope. If I do not want to turn it on my mobile phone. You only have to install a FFT app like spectroid and give contact between phone and motor for body-borne sound transfer. Need some sleep. I will check the other stuff you mentioned tomorrow.
Re: TMC2130 spreadCycle configuration
August 08, 2017 06:25AM
FYI: You're using invalid values for hysterisis_low and hysterisis_start. The ranges are -3..12 and 1..8 respectively.
I'm also renaming the former to hysterisis_end, but hysterisis_low remains as an alias. You can use hend(13) if you wish to use the actual bits being pushed to the register.

hysterisis_low (hysterisis_end) is supposed to accept and report the parsed values. So there's an offset of -3.
The same applies for hysterisis_start(), with an offset of +1.

=>A register (hstrt) value of 0 means hysteris_start value of 1.

hstrt(0) == hysterisis_start(1)
hstrt(1) == hysterisis_start(2)
...
hend(0) == hysterisis_end(-3)
hend(3) == hysterisis_end(0)
Re: TMC2130 spreadCycle configuration
August 13, 2017 06:46AM
Sorry for the late response. I have currently to work and so. I have changed to default by uncommenting TMC_ADV() hysteresis_start and _low. Now I have 16kHz instead of 11. Not quiet enough but your suggestion should be completly right. Some user friendly option in configuration_adv.h like "low", "default" and "high" frequency operation would be nice smiling smiley So not every user has to dig into Trianmic's configuration application notes. Since there are stepper motors with a very wide range of inductance there will be no allround configuration, I think. What do you think, is it possible to ask a Trinamic application engineer for some help? I mean official support for TMC2130 is great marketing for them.
Re: TMC2130 spreadCycle configuration
August 13, 2017 10:07AM
I could certainly do that.

I have a contact at Trinamic since they were kind enough to provide me a TRAMS platform (TMC5130) for Marlin development and I could ask him on what would be good three tiered defaults.
I'm not sure how focused they are on the 3Dprinting community as they're mostly an industry manufacturer. The TRAMS board was like a side project for them.
Re: TMC2130 spreadCycle configuration
August 15, 2017 11:44AM
I know trinamic is supporting closed source 3D printer developers. For example, sensorless homing is commonly used there. If you present yourself as a developer of marlin (the biggest firmware for 3D printers?) chances are good to get some support. I am an electronics design engineer and I am thinking about designing a board with SPI interface and connectors for sensorless homing for TMC2130. This cable salad is a shame.

Edited 1 time(s). Last edit at 08/15/2017 11:45AM by butchja.
Re: TMC2130 spreadCycle configuration
August 15, 2017 01:08PM
I'm actually not aware of any 3dprinters that would came with TMC steppers by default (maybe some that would use SmoothieBoard?), let alone any that would use stallGuard based homing. Heck, even the term Sensorless Homing was coined by me as it's not called that by Trinamic itself in their TRAMS firmware.
But as said, I'm already in contact with Trinamic about up to date support for TRAMS and they're aware of the libraries I've created and my involvement with Marlin.
Re: TMC2130 spreadCycle configuration
August 15, 2017 04:49PM
Nice, Trinamic already designed a board fully open source. I mixed it up with "sensorless homing" Trinamic calls it sensorless reference search. [youtu.be]

Edited 1 time(s). Last edit at 08/15/2017 04:50PM by butchja.
Re: TMC2130 spreadCycle configuration
May 03, 2018 07:18AM
Hello,

I have a similar problem. I am also using the TMC2130 in sensorless mode on my X and Y axis. My Z axis is driven by them as well, but i us an extra endstop for this axis. I experienced some shifted layers with these drivers in StealthChop mode and speeds above 45mm/s, but with below that they worked quiet well an were inaudible. But as I'd like to get the most out of my printer and would like to be able to print at higher speeds I wanted to try SpreadCycle mode. When I switch to that mode the steppers emit a very high pitch whining noise. On a friends printer the same drivers are almost as quiet in SpreadCycle as they were with StealthChop. My coreXY printer already runs on 24V with an MKS Gen 1.4.
As a solve I wanted to try the TMC_ADV(){} function suggested in this post. But when i do so and try to build Marlin I get an compile error
'stepperX' does not name a type
I get the same messages for stepperY and stepperZ. I also tried the default example mentioned in the Marlin code:
  / * Example: */
   #define TMC_ADV() { \
     stepperX.diag0_temp_prewarn(1); \ 
     stepperY.interpolate(0); \
   }
The same error appers with this code as well. Do I have to define or include something else to use this stepper-types? And is there some kind of guide line how to configure the drivers the right way, or do I simply try things out?

Thanks for your help
Camaro

Edited 1 time(s). Last edit at 05/03/2018 08:46AM by Camaro.
Re: TMC2130 spreadCycle configuration
May 03, 2018 10:08AM
Hi again,

my mistake. I didn't know that the backslashes at the end of each line are needed. My code missed the backslash behind
TMC_ADV () { \ 
I added them and removed all empty lines. hysteresis_start also needs to be changed to hstrt(..) and hysteresis_low to hend(..). Now compiling works without an error.

As for my second question: How can I find the correct values I need to set that they work more quietly?
I already tried to use the Quick Configuration Guide TUNING STEALTHCHOP AND SPREADCYCLE from the Trinamic documentation, but i dont quiet understand all the parameters and how they influence the driver performance/noise emission.

Edited 1 time(s). Last edit at 05/04/2018 02:29AM by Camaro.
Sorry, only registered users may post in this forum.

Click here to login