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

[1.1.x] TMC driver update #8712

Merged
merged 9 commits into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ install:
- git clone https://github.com/teemuatlut/TMC2130Stepper.git
- sudo mv TMC2130Stepper /usr/local/share/arduino/libraries/TMC2130Stepper
#
# Install: TMC2208 Stepper Motor Controller library
- git clone https://github.com/teemuatlut/TMC2208Stepper.git
- sudo mv TMC2208Stepper /usr/local/share/arduino/libraries/TMC2208Stepper
#
# Install: Adafruit Neopixel library
- git clone https://github.com/adafruit/Adafruit_NeoPixel.git
- sudo mv Adafruit_NeoPixel /usr/local/share/arduino/libraries/Adafruit_NeoPixel
Expand Down Expand Up @@ -344,7 +348,14 @@ script:
- use_example_configs SCARA
- opt_enable AUTO_BED_LEVELING_BILINEAR FIX_MOUNTED_PROBE USE_ZMIN_PLUG EEPROM_SETTINGS EEPROM_CHITCHAT ULTIMAKERCONTROLLER
- opt_enable_adv HAVE_TMC2130 X_IS_TMC2130 Y_IS_TMC2130 Z_IS_TMC2130
- opt_enable_adv AUTOMATIC_CURRENT_CONTROL STEALTHCHOP HYBRID_THRESHOLD SENSORLESS_HOMING
- opt_enable_adv MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD TMC_DEBUG SENSORLESS_HOMING
- build_marlin
#
# TMC2208 Config
#
- restore_configs
- opt_enable_adv HAVE_TMC2208 X_IS_TMC2208 Y_IS_TMC2208 Z_IS_TMC2208
- opt_enable_adv MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD TMC_DEBUG
- build_marlin
#
# tvrrug Config need to check board type for sanguino atmega644p
Expand Down
115 changes: 72 additions & 43 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@

#endif

// @section TMC2130
// @section TMC2130, TMC2208

/**
* Enable this for SilentStepStick Trinamic TMC2130 SPI-configurable stepper drivers.
Expand All @@ -990,7 +990,19 @@
*/
//#define HAVE_TMC2130

#if ENABLED(HAVE_TMC2130)
/**
* Enable this for SilentStepStick Trinamic TMC2208 UART-configurable stepper drivers.
* Connect #_SERIAL_TX_PIN to the driver side PDN_UART pin.
* To use the reading capabilities, also connect #_SERIAL_RX_PIN
* to #_SERIAL_TX_PIN with a 1K resistor.
* The drivers can also be used with hardware serial.
*
* You'll also need the TMC2208Stepper Arduino library
* (https://github.com/teemuatlut/TMC2208Stepper).
*/
//#define HAVE_TMC2208

#if ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208)

// CHOOSE YOUR MOTORS HERE, THIS IS MANDATORY
//#define X_IS_TMC2130
Expand All @@ -1005,46 +1017,58 @@
//#define E3_IS_TMC2130
//#define E4_IS_TMC2130

//#define X_IS_TMC2208
//#define X2_IS_TMC2208
//#define Y_IS_TMC2208
//#define Y2_IS_TMC2208
//#define Z_IS_TMC2208
//#define Z2_IS_TMC2208
//#define E0_IS_TMC2208
//#define E1_IS_TMC2208
//#define E2_IS_TMC2208
//#define E3_IS_TMC2208
//#define E4_IS_TMC2208

/**
* 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 INTERPOLATE true // Interpolate X/Y/Z_MICROSTEPS to 256

#define X_CURRENT 1000 // rms current in mA. Multiply by 1.41 for peak current.
#define X_CURRENT 800 // rms current in mA. Multiply by 1.41 for peak current.
#define X_MICROSTEPS 16 // 0..256

#define Y_CURRENT 1000
#define Y_CURRENT 800
#define Y_MICROSTEPS 16

#define Z_CURRENT 1000
#define Z_CURRENT 800
#define Z_MICROSTEPS 16

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

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

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

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

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

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

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

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

/**
* Use Trinamic's ultra quiet stepping mode.
Expand All @@ -1053,24 +1077,22 @@
#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
* Monitor Trinamic TMC2130 and TMC2208 drivers for error conditions,
* like overtemperature and short to ground. TMC2208 requires hardware serial.
* In the case of overtemperature Marlin can decrease the driver current until error condition clears.
* Other detected conditions can be used to stop the current print.
* 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.
* M122 S0/1 - Report driver parameters (Requires TMC_DEBUG)
*/
//#define AUTOMATIC_CURRENT_CONTROL
//#define MONITOR_DRIVER_STATUS

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

/**
Expand All @@ -1085,8 +1107,8 @@
#define X2_HYBRID_THRESHOLD 100
#define Y_HYBRID_THRESHOLD 100
#define Y2_HYBRID_THRESHOLD 100
#define Z_HYBRID_THRESHOLD 4
#define Z2_HYBRID_THRESHOLD 4
#define Z_HYBRID_THRESHOLD 3
#define Z2_HYBRID_THRESHOLD 3
#define E0_HYBRID_THRESHOLD 30
#define E1_HYBRID_THRESHOLD 30
#define E2_HYBRID_THRESHOLD 30
Expand All @@ -1096,7 +1118,7 @@
/**
* 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 and Y homing will always be done in spreadCycle mode.
*
* X/Y_HOMING_SENSITIVITY is used for tuning the trigger sensitivity.
* Higher values make the system LESS sensitive.
Expand All @@ -1105,27 +1127,34 @@
* It is advised to set X/Y_HOME_BUMP_MM to 0.
* M914 X/Y to live tune the setting
*/
//#define SENSORLESS_HOMING
//#define SENSORLESS_HOMING // TMC2130 only

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

/**
* Enable M122 debugging command for TMC stepper drivers.
* M122 S0/1 will enable continous reporting.
*/
//#define TMC_DEBUG

/**
* 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
* https://github.com/teemuatlut/TMC2130Stepper
* https://github.com/teemuatlut/TMC2208Stepper
*
* Example:
* #define TMC2130_ADV() { \
* #define TMC_ADV() { \
* stepperX.diag0_temp_prewarn(1); \
* stepperX.interpolate(0); \
* stepperY.interpolate(0); \
* }
*/
#define TMC2130_ADV() { }
#define TMC_ADV() { }

#endif // HAVE_TMC2130
#endif // TMC2130 || TMC2208

// @section L6470

Expand Down
1 change: 1 addition & 0 deletions Marlin/MarlinConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Version.h"
#include "Configuration.h"
#include "Conditionals_LCD.h"
#include "tmc_macros.h"
#include "Configuration_adv.h"
#include "pins.h"
#ifndef USBCON
Expand Down
Loading