Marlin TMC2130 firmware configuration - martikainen87/Home-Automation GitHub Wiki

A guide to my marlin configuration for my 3D printer

Download the latest version of firmware from Marlinfw.org. Right now I'm using the daily bugfix since it has the latest updates for my TMC2130 drivers.

Current downloaddate: 2018-04-30

prerequisites

  • Arduino IDE (I'm running version 1.8.5)
  • TMC Library ( Sketch -> Include Library -> TMC2130Stepper -> Install)
  • U8glib Library ( Sketch -> Include Library -> u8glib -> Install)

There are 3 files which we need to configure to get it to work with MKS Gen v1.4 board.

Configuration.h pins_RAMPS.h Configuration_adv.h

Layout of the MKS gen v1.4 board

These are my tweaks and an explanation to it. I've addedd //Martikainen on all things i've changed to be able to find it when I update to a newer firmware.

Configuration.h

Row 77

#define STRING_CONFIG_H_AUTHOR "(Mattias Martikainen, MKS gen v1.4 tmc2100, e3d v6)" // Who made the changes Martikainen

Row 128

// The following define selects which electronics board you have.
// Please choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
  //#define MOTHERBOARD BOARD_RAMPS_14_EFB
#define MOTHERBOARD BOARD_MKS_GEN_13 //Martikainen
#endif

Row 133

// Optional custom name for your RepStrap or other custom machine
// Displayed in the LCD "Ready" message
#define CUSTOM_MACHINE_NAME "AM8 MKS Gen 1.4" //Martikainen

Row 146

// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Martikainen

Row 305

#define TEMP_SENSOR_0 5 //Martikainen e3d v6 extruder thermistor
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_BED 5 //Martikainen Anet A8 Bed thermistor

Row 344

// When temperature exceeds max temp, your heater will be switched off.
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
// You should use MINTEMP for thermistor short/failure protection.
#define HEATER_0_MAXTEMP 285 //Martikainen e3d v6 temp

Row 391 - 393

PID for the e3d v6 hotend

  // Martikainen e3d v6 at 210 Degree Celsius and 100% Fan
  //(measured after M106 S255 with M303 E0 S210 C8)
  #define  DEFAULT_Kp 24.78
  #define  DEFAULT_Ki 2.04
  #define  DEFAULT_Kd 75.11

Row 409

#define PIDTEMPBED //Martikainen enable PID on bed, fixing Z-banding

Row 429 - 433

  //Martikainen Bed 4mm Glass
  //60C
  #define DEFAULT_bedKp 414.71
  #define DEFAULT_bedKi 53.29
  #define DEFAULT_bedKd 806.87

Row 522 - 529

// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
#define X_MIN_ENDSTOP_INVERTING true  //Martikainen set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING true  //Martikainen set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING true  //Martikainen COM from switch to GND, NO from switch to signal (D18)
#define X_MAX_ENDSTOP_INVERTING true //Martikainen set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING true //Martikainen set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING true //Martikainen set to true to invert the logic of the endstop.
#define Z_MIN_PROBE_ENDSTOP_INVERTING true  //Martikainen set to true to invert the logic of the probe.

Row 532

// Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles.
#define ENDSTOP_INTERRUPTS_FEATURE //Martikainen

Row 561

//#define DEFAULT_AXIS_STEPS_PER_UNIT   { 80, 80, 4000, 500 } Original
#define DEFAULT_AXIS_STEPS_PER_UNIT   { 100, 100.62, 403.06, 217.93 } //Martikainen 435,86 with 16 microsteps

Row 576

//#define DEFAULT_MAX_ACCELERATION      { 3000, 3000, 100, 10000 } Orginal
#define DEFAULT_MAX_ACCELERATION      { 2000, 2000, 100, 10000 } //Martikainen

Row 590

// Martikainen
#define DEFAULT_ACCELERATION          400     // X, Y, Z and E acceleration for printing moves
#define DEFAULT_RETRACT_ACCELERATION  1000    // E acceleration for retracts
#define DEFAULT_TRAVEL_ACCELERATION   1000    // X, Y, Z acceleration for travel (non printing) moves

Row 788 - 791

// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
#define INVERT_X_DIR true  //Martikainen TMC2130 inverts the motors
#define INVERT_Y_DIR true  //martikainen TMC2130 inverts the motors
#define INVERT_Z_DIR false

Row 822 - 832

// The size of the print bed
#define X_BED_SIZE 220 //martikainen
#define Y_BED_SIZE 220 //martikainen

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS -19 //martikainen
#define Y_MIN_POS 0 //Martikainen 
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240 //martikainen

Row 1180 Enable EEPROM save

#define EEPROM_SETTINGS // Enable for M500 and M501 commands Martikainen

Row 1373

#define SDSUPPORT //Martikainen

Row 1526 Enable the reprapdiscount full graphic LCD

// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER //Martikainen

pins_RAMPS.h

Row 70 - 82 Topic Limit Switches

// Limit Switches
//
#define X_MIN_PIN 3
#ifndef X_MAX_PIN
 #define X_MAX_PIN 3
// #define X_MAX_PIN 2 //Martikainen because of LCD with SD card reader
#endif
//#define Y_MIN_PIN 14
#define Y_MIN_PIN 2
#define Y_MAX_PIN 2
//#define Y_MAX_PIN 15 //Martikainen because of LCD with SD card reader
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19

Row 92 - 108 Topic Steppers

// Steppers
//
#define X_STEP_PIN         54
#define X_DIR_PIN          55
#define X_ENABLE_PIN       38
#ifndef X_CS_PIN
  #define X_CS_PIN 14 // Z Y_MIN_PIN Martikainen
  //#define X_CS_PIN         53  Martikainen
#endif

#define Y_STEP_PIN         60
#define Y_DIR_PIN          61
#define Y_ENABLE_PIN       56
#ifndef Y_CS_PIN
  #define Y_CS_PIN 15 // Z Y_MAX_PIN Martikainen
  //#define Y_CS_PIN         49 Martikainen
#endif

Configuration_adv.h

Row 228

I've enabled pin D7 to act as a hotend fan for my e3d v6 hotend, this is a 5v output

#define E0_AUTO_FAN_PIN 7 //Martikainen hotend

Row 243

Enabled pin D9 for my part cooling

#define FANMUX0_PIN 9 //Martikainen parts fan

Row 271

#define ENDSTOPS_ALWAYS_ON_DEFAULT  //Martikainen

Row 312

#define Z_DUAL_STEPPER_DRIVERS //Martikainen

Row 371

#define QUICK_HOME // Martikainen If homing includes X and Y, do a diagonal move initially

Row 743

#define LIN_ADVANCE //Martikainen
#if ENABLED(LIN_ADVANCE)
  #define LIN_ADVANCE_K 0  // Unit: mm compression per 1mm/s extruder speed Martikainen
  //#define LA_DEBUG          // If enabled, this will generate debug information output over USB.
#endif

Row 1017

#define HAVE_TMC2130 //Martikainen
#if ENABLED(HAVE_TMC2130)  // Choose your axes here. This is mandatory!
  #define X_IS_TMC2130 //Martikainen
  //#define X2_IS_TMC2130
  #define Y_IS_TMC2130 //Martikainen
  //#define Y2_IS_TMC2130
  #define Z_IS_TMC2130 //Martikainen
  #define Z2_IS_TMC2130 //Martikainen
  #define E0_IS_TMC2130 //Martikainen
  //#define E1_IS_TMC2130
  //#define E2_IS_TMC2130
  //#define E3_IS_TMC2130
  //#define E4_IS_TMC2130
#endif

Row 1098

  #define E0_CURRENT         800
  #define E0_MICROSTEPS       8 //Martikainen to work with 1.7a nema motor

Row 1110

  #define STEALTHCHOP //Martikainen

Row 1123

  #define MONITOR_DRIVER_STATUS //Martikainen

Row 1163

  #define SENSORLESS_HOMING // TMC2130 only Martikainen

Row 1175

  #define TMC_DEBUG //Martikainen

Row 1187

  #define TMC_Z_CALIBRATION //Martikainen