Browse Source

Merge remote-tracking branch 'upstream/MK3' into MK3

sync with upstream # Please enter a commit message to explain why this merge is necessary,
PavelSindler 7 years ago
parent
commit
5943e786ee

+ 13 - 8
Firmware/Configuration.h

@@ -181,6 +181,11 @@
 //if PREVENT_DANGEROUS_EXTRUDE is on, you can still disable (uncomment) very long bits of extrusion separately.
 #define PREVENT_LENGTHY_EXTRUDE
 
+#ifdef DEBUG_DISABLE_PREVENT_EXTRUDER
+#undef PREVENT_DANGEROUS_EXTRUDE
+#undef PREVENT_LENGTHY_EXTRUDE
+#endif //DEBUG_DISABLE_PREVENT_EXTRUDER
+
 
 #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
 
@@ -293,6 +298,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
 #define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
 #define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.
 
+#ifdef DEBUG_DISABLE_SWLIMITS
+#define min_software_endstops false
+#define max_software_endstops false
+#endif //DEBUG_DISABLE_SWLIMITS
 
 
 #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
@@ -434,14 +443,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
 // #define EXTRUDER_OFFSET_Y {0.0, 5.00}  // (in mm) for each extruder, offset of the hotend on the Y axis
 
 // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
-//#define DEFAULT_XJERK                 5.0    // (mm/sec)
-//#define DEFAULT_YJERK                 5.0    // (mm/sec)
-//#define DEFAULT_ZJERK                 0.2    // (mm/sec)
-//#define DEFAULT_EJERK                 2.5    // (mm/sec)
-#define DEFAULT_XJERK                 0.5      // (mm/sec)
-#define DEFAULT_YJERK                 0.5      // (mm/sec)
-#define DEFAULT_ZJERK                 0.1      // (mm/sec)
-#define DEFAULT_EJERK                 0.5      // (mm/sec)
+#define DEFAULT_XJERK                15       // (mm/sec)
+#define DEFAULT_YJERK                15       // (mm/sec)
+#define DEFAULT_ZJERK                 0.4     // (mm/sec)
+#define DEFAULT_EJERK                 2.5     // (mm/sec)
 
 //===========================================================================
 //=============================Additional Features===========================

+ 36 - 9
Firmware/Marlin_main.cpp

@@ -1003,6 +1003,9 @@ void factory_reset(char level, bool quiet)
 // are initialized by the main() routine provided by the Arduino framework.
 void setup()
 {
+    lcd_init();
+    lcd_print_at_PGM(0, 1, PSTR("   Original Prusa   "));
+    lcd_print_at_PGM(0, 2, PSTR("    3D  Printers    "));
 	setup_killpin();
 	setup_powerhold();
 	MYSERIAL.begin(BAUDRATE);
@@ -1052,7 +1055,7 @@ void setup()
 	SERIAL_ECHO(freeMemory());
 	SERIAL_ECHORPGM(MSG_PLANNER_BUFFER_BYTES);
 	SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
-	lcd_update_enable(false);
+	//lcd_update_enable(false); // why do we need this?? - andre
 	// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
 	Config_RetrieveSettings();
 	SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack
@@ -1065,14 +1068,17 @@ void setup()
 	tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
 #endif //HAVE_TMC2130_DRIVERS
 
+    
 	st_init();    // Initialize stepper, this enables interrupts!
+    
 	setup_photpin();
+    lcd_print_at_PGM(0, 1, PSTR("   Original Prusa   ")); // we need to do this again for some reason, no time to research
+    lcd_print_at_PGM(0, 2, PSTR("    3D  Printers    ")); 
 	servo_init();
 	// Reset the machine correction matrix.
 	// It does not make sense to load the correction matrix until the machine is homed.
 	world2machine_reset();
-
-	lcd_init();
+    
 	if (!READ(BTN_ENC))
 	{
 		_delay_ms(1000);
@@ -1138,8 +1144,9 @@ void setup()
 	}
 	else
 	{
-		_delay_ms(1000);  // wait 1sec to display the splash screen
+		//_delay_ms(1000);  // wait 1sec to display the splash screen // what's this and why do we need it?? - andre
 	}
+    
 
 
 
@@ -1207,6 +1214,7 @@ void setup()
 		eeprom_write_byte((uint8_t*)EEPROM_UVLO, 0);
 	}
 
+#ifndef DEBUG_DISABLE_STARTMSGS
 	check_babystep(); //checking if Z babystep is in allowed range
 	setup_uvlo_interrupt();
 	
@@ -1225,8 +1233,9 @@ void setup()
 	  lcd_update_enable(true);
   } else if (calibration_status() == CALIBRATION_STATUS_Z_CALIBRATION) {
       // Show the message.
-      lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW);
+	  lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW);
   }
+#endif //DEBUG_DISABLE_STARTMSGS
   for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
   lcd_update_enable(true);
 
@@ -1897,14 +1906,14 @@ void homeaxis(int axis) {
         feedrate = homing_feedrate[axis];
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
 
-//		sg_homing_delay = 0;
+		sg_homing_delay = 0;
         st_synchronize();
         
         current_position[axis] = 0;
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
         destination[axis] = -home_retract_mm(axis) * axis_home_dir;
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
-//		sg_homing_delay = 0;
+		sg_homing_delay = 0;
         st_synchronize();
         
         destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
@@ -1915,7 +1924,7 @@ void homeaxis(int axis) {
 #endif
 		feedrate = homing_feedrate[axis] / 2;
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
-//		sg_homing_delay = 0;
+		sg_homing_delay = 0;
         st_synchronize();
         axis_is_at_home(axis);
         destination[axis] = current_position[axis];
@@ -5568,6 +5577,24 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
 		MYSERIAL.print(" sg_thrs_y=");
 		MYSERIAL.println(sg_thrs_y, DEC);
     }
+    break;
+
+	case 917: // M917 Set TMC2130 pwm_ampl
+    {
+		if (code_seen('X')) tmc2130_set_pwm_ampl(0, code_value());
+		if (code_seen('Y')) tmc2130_set_pwm_ampl(1, code_value());
+        if (code_seen('Z')) tmc2130_set_pwm_ampl(2, code_value());
+        if (code_seen('E')) tmc2130_set_pwm_ampl(3, code_value());
+    }
+    break;
+
+	case 918: // M918 Set TMC2130 pwm_grad
+    {
+		if (code_seen('X')) tmc2130_set_pwm_grad(0, code_value());
+		if (code_seen('Y')) tmc2130_set_pwm_grad(1, code_value());
+        if (code_seen('Z')) tmc2130_set_pwm_grad(2, code_value());
+        if (code_seen('E')) tmc2130_set_pwm_grad(3, code_value());
+    }
     break;
 
     case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
@@ -6956,4 +6983,4 @@ void restore_print_from_eeprom() {
 	strcat(cmd, itostr3(int(fan_speed_rec)));
 	enquecommand(cmd);
 	
-}
+}

+ 3 - 2
Firmware/boards.h

@@ -3,8 +3,9 @@
 
 #define BOARD_UNKNOWN -1
 
-#define BOARD_EINY_0_4a         299 // EINY 0.4a
-#define BOARD_EINY_0_3a         300 // EINY 0.3a
+#define BOARD_EINY_0_3a         300  // EINY 0.3a
+#define BOARD_EINY_0_4a         299  // EINY 0.4a
+
 #define BOARD_RAMBO             301  // Rambo
 #define BOARD_RAMBO_MINI_1_3    302  // Rambo-mini 1.3
 #define BOARD_RAMBO_MINI_1_0    102  // Rambo-mini 1.0

+ 8 - 0
Firmware/pins.h

@@ -332,6 +332,8 @@
 #define X_DIR_PIN           49
 #define X_MIN_PIN           12
 #define X_MAX_PIN           30
+//#define X_MIN_PIN           64 //TMC2130 SG homing
+//#define X_MAX_PIN           64 //TMC2130 SG homing
 #define X_ENABLE_PIN        29
 #define X_MS1_PIN -1
 #define X_MS2_PIN -1
@@ -341,6 +343,8 @@
 #define Y_DIR_PIN           48
 #define Y_MIN_PIN           11
 #define Y_MAX_PIN           24
+//#define Y_MIN_PIN           69 //TMC2130 SG homing
+//#define Y_MAX_PIN           69 //TMC2130 SG homing
 #define Y_ENABLE_PIN        28
 #define Y_MS1_PIN -1
 #define Y_MS2_PIN -1
@@ -438,6 +442,8 @@
 #define X_DIR_PIN           49
 #define X_MIN_PIN           12
 #define X_MAX_PIN           30
+//#define X_MIN_PIN           64 //TMC2130 SG homing
+//#define X_MAX_PIN           64 //TMC2130 SG homing
 #define X_ENABLE_PIN        29
 #define X_MS1_PIN -1
 #define X_MS2_PIN -1
@@ -447,6 +453,8 @@
 #define Y_DIR_PIN           48
 #define Y_MIN_PIN           11
 #define Y_MAX_PIN           24
+//#define Y_MIN_PIN           69 //TMC2130 SG homing
+//#define Y_MAX_PIN           69 //TMC2130 SG homing
 #define Y_ENABLE_PIN        28
 #define Y_MS1_PIN -1
 #define Y_MS2_PIN -1

+ 1 - 1
Firmware/planner.cpp

@@ -978,7 +978,7 @@ Having the real displacement of the head, we can calculate the total movement le
   // Acceleration of the segment, in mm/sec^2
   block->acceleration = block->acceleration_st / steps_per_mm;
 
-#if 1
+#if 0
   // Oversample diagonal movements by a power of 2 up to 8x
   // to achieve more accurate diagonal movements.
   uint8_t bresenham_oversample = 1;

+ 33 - 1
Firmware/stepper.cpp

@@ -585,14 +585,23 @@ ISR(TIMER1_COMPA_vect)
         counter_x += current_block->steps_x;
         if (counter_x > 0) {
           WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
+#ifdef DEBUG_XSTEP_DUP_PIN
+    WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
+#endif //DEBUG_XSTEP_DUP_PIN
           counter_x -= current_block->step_event_count;
           count_position[X_AXIS]+=count_direction[X_AXIS];   
           WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
+#ifdef DEBUG_XSTEP_DUP_PIN
+    WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
+#endif //DEBUG_XSTEP_DUP_PIN
         }
 
         counter_y += current_block->steps_y;
         if (counter_y > 0) {
           WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
+#ifdef DEBUG_YSTEP_DUP_PIN
+    WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
+#endif //DEBUG_YSTEP_DUP_PIN
 		  
 		  #ifdef Y_DUAL_STEPPER_DRIVERS
 			WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
@@ -601,6 +610,9 @@ ISR(TIMER1_COMPA_vect)
           counter_y -= current_block->step_event_count;
           count_position[Y_AXIS]+=count_direction[Y_AXIS];
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
+#ifdef DEBUG_YSTEP_DUP_PIN
+    WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
+#endif //DEBUG_YSTEP_DUP_PIN
 		  
 		  #ifdef Y_DUAL_STEPPER_DRIVERS
 			WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
@@ -812,9 +824,13 @@ void st_init()
 
 
   //Initialize Step Pins
-  #if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
+#if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
     SET_OUTPUT(X_STEP_PIN);
     WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
+#ifdef DEBUG_XSTEP_DUP_PIN
+    SET_OUTPUT(DEBUG_XSTEP_DUP_PIN);
+    WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
+#endif //DEBUG_XSTEP_DUP_PIN
     disable_x();
   #endif
   #if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
@@ -825,6 +841,10 @@ void st_init()
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
     SET_OUTPUT(Y_STEP_PIN);
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
+#ifdef DEBUG_YSTEP_DUP_PIN
+    SET_OUTPUT(DEBUG_YSTEP_DUP_PIN);
+    WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
+#endif //DEBUG_YSTEP_DUP_PIN
     #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
       SET_OUTPUT(Y2_STEP_PIN);
       WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
@@ -983,10 +1003,16 @@ void babystep(const uint8_t axis,const bool direction)
     
     //perform step 
     WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); 
+#ifdef DEBUG_XSTEP_DUP_PIN
+    WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
+#endif //DEBUG_XSTEP_DUP_PIN
     {
     volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
     }
     WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
+#ifdef DEBUG_XSTEP_DUP_PIN
+    WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
+#endif //DEBUG_XSTEP_DUP_PIN
 
     //get old pin state back.
     WRITE(X_DIR_PIN,old_x_dir_pin);
@@ -1002,10 +1028,16 @@ void babystep(const uint8_t axis,const bool direction)
     
     //perform step 
     WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); 
+#ifdef DEBUG_YSTEP_DUP_PIN
+    WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
+#endif //DEBUG_YSTEP_DUP_PIN
     {
     volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
     }
     WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
+#ifdef DEBUG_YSTEP_DUP_PIN
+    WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
+#endif //DEBUG_YSTEP_DUP_PIN
 
     //get old pin state back.
     WRITE(Y_DIR_PIN,old_y_dir_pin);

+ 7 - 1
Firmware/temperature.cpp

@@ -1353,6 +1353,9 @@ void max_temp_error(uint8_t e) {
 }
 
 void min_temp_error(uint8_t e) {
+#ifdef DEBUG_DISABLE_MINTEMP
+	return;
+#endif
   disable_heater();
   if(IsStopped() == false) {
     SERIAL_ERROR_START;
@@ -1383,7 +1386,10 @@ void bed_max_temp_error(void) {
 }
 
 void bed_min_temp_error(void) {
-/*#if HEATER_BED_PIN > -1
+#ifdef DEBUG_DISABLE_MINTEMP
+	return;
+#endif
+#if HEATER_BED_PIN > -1
     WRITE(HEATER_BED_PIN, 0);
 #endif
     if(IsStopped() == false) {

+ 113 - 43
Firmware/tmc2130.cpp

@@ -18,15 +18,26 @@ uint8_t tmc2130_current_h[4] = TMC2130_CURRENTS_H;
 //running currents
 uint8_t tmc2130_current_r[4] = TMC2130_CURRENTS_R;
 //axis stalled flags
-uint8_t tmc2130_axis_stalled[4] = {0, 0, 0, 0};
+uint8_t tmc2130_axis_stalled[2] = {0, 0};
 //last homing stalled
 uint8_t tmc2130_LastHomingStalled = 0;
 
+//pwm_ampl
+uint8_t tmc2130_pwm_ampl[2] = {TMC2130_PWM_AMPL_XY, TMC2130_PWM_AMPL_XY};
+//pwm_grad
+uint8_t tmc2130_pwm_grad[2] = {TMC2130_PWM_GRAD_XY, TMC2130_PWM_GRAD_XY};
+//pwm_auto
+uint8_t tmc2130_pwm_auto[2] = {TMC2130_PWM_AUTO_XY, TMC2130_PWM_AUTO_XY};
+//pwm_freq
+uint8_t tmc2130_pwm_freq[2] = {TMC2130_PWM_FREQ_XY, TMC2130_PWM_FREQ_XY};
+
+
 uint8_t sg_homing_axis = 0xff;
 uint8_t sg_homing_delay = 0;
 uint8_t sg_thrs_x = TMC2130_SG_THRS_X;
 uint8_t sg_thrs_y = TMC2130_SG_THRS_Y;
 
+bool skip_debug_msg = false;
 
 //TMC2130 registers
 #define TMC2130_REG_GCONF      0x00 // 17 bits
@@ -65,14 +76,17 @@ uint8_t sg_thrs_y = TMC2130_SG_THRS_Y;
 uint16_t tmc2130_rd_TSTEP(uint8_t cs);
 uint16_t tmc2130_rd_DRV_STATUS(uint8_t chipselect);
 
-void tmc2130_wr_CHOPCONF(uint8_t cs, bool extrapolate256 = 0, uint16_t microstep_resolution = 16);
-void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t PWMautoScale = TMC2130_PWM_AUTO, uint8_t PWMfreq = TMC2130_PWM_FREQ, uint8_t PWMgrad = TMC2130_PWM_GRAD, uint8_t PWMampl = TMC2130_PWM_AMPL);
+void tmc2130_wr_CHOPCONF(uint8_t cs, uint8_t toff = 3, uint8_t hstrt = 4, uint8_t hend = 1, uint8_t fd3 = 0, uint8_t disfdcc = 0, uint8_t rndtf = 0, uint8_t chm = 0, uint8_t tbl = 2, uint8_t vsense = 0, uint8_t vhighfs = 0, uint8_t vhighchm = 0, uint8_t sync = 0, uint8_t mres = 0b0100, uint8_t intpol = 1, uint8_t dedge = 0, uint8_t diss2g = 0);
+void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t pwm_ampl, uint8_t pwm_grad, uint8_t pwm_freq, uint8_t pwm_auto, uint8_t pwm_symm, uint8_t freewheel);
 void tmc2130_wr_TPWMTHRS(uint8_t cs, uint32_t val32);
 void tmc2130_wr_THIGH(uint8_t cs, uint32_t val32);
 
-uint8_t tmc2130_txrx(uint8_t cs, uint8_t addr, uint32_t wval, uint32_t* rval);
+uint8_t tmc2130_axis_by_cs(uint8_t cs);
+uint8_t tmc2130_mres(uint16_t microstep_resolution);
+
 uint8_t tmc2130_wr(uint8_t cs, uint8_t addr, uint32_t wval);
 uint8_t tmc2130_rd(uint8_t cs, uint8_t addr, uint32_t* rval);
+uint8_t tmc2130_txrx(uint8_t cs, uint8_t addr, uint32_t wval, uint32_t* rval);
 
 
 
@@ -91,30 +105,30 @@ void tmc2130_init()
 	SPI.begin();
 	for (int i = 0; i < 2; i++) // X Y axes
 	{
-		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?0x00000004:0x00000000);
+		uint8_t mres = tmc2130_mres(TMC2130_USTEPS_XY);
+		tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_XY, 0, 0);
 		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[i] & 0x1f) << 8) | (tmc2130_current_h[i] & 0x1f));
 		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_TPOWERDOWN, 0x00000000);
-		tmc2130_wr_PWMCONF(tmc2130_cs[i]); //PWM_CONF //reset default=0x00050480
+		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?0x00000004:0x00000000);
+		tmc2130_wr_PWMCONF(tmc2130_cs[i], tmc2130_pwm_ampl[i], tmc2130_pwm_grad[i], tmc2130_pwm_freq[i], tmc2130_pwm_auto[i], 0, 0);
 		tmc2130_wr_TPWMTHRS(tmc2130_cs[i], TMC2130_TPWMTHRS);
 		//tmc2130_wr_THIGH(tmc2130_cs[i], TMC2130_THIGH);
-		tmc2130_wr_CHOPCONF(tmc2130_cs[i], TMC2130_EXP256_XY, TMC2130_USTEPS_XY);
 	}
 	for (int i = 2; i < 3; i++) // Z axis
 	{
-		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?0x00000004:0x00000000);
+		uint8_t mres = tmc2130_mres(TMC2130_USTEPS_Z);
+		tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_Z, 0, 0);
 		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[i] & 0x1f) << 8) | (tmc2130_current_h[i] & 0x1f));
 		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_TPOWERDOWN, 0x00000000);
-		tmc2130_wr_PWMCONF(tmc2130_cs[i]); //PWM_CONF //reset default=0x00050480
-		tmc2130_wr_TPWMTHRS(tmc2130_cs[i], TMC2130_TPWMTHRS);
-		//tmc2130_wr_THIGH(tmc2130_cs[i], TMC2130_THIGH);
-		tmc2130_wr_CHOPCONF(tmc2130_cs[i], TMC2130_EXP256_Z, TMC2130_USTEPS_Z);
+		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000000);
 	}
 	for (int i = 3; i < 4; i++) // E axis
 	{
-		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000004); //GCONF - bit 2 activate stealthChop
+		uint8_t mres = tmc2130_mres(TMC2130_USTEPS_E);
+		tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_E, 0, 0);
 		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[i] & 0x1f) << 8) | (tmc2130_current_h[i] & 0x1f));
 		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_TPOWERDOWN, 0x00000000);
-		tmc2130_wr_CHOPCONF(tmc2130_cs[i], TMC2130_EXP256_E, TMC2130_USTEPS_E);
+		tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000000);
 	}
 }
 
@@ -127,7 +141,7 @@ bool tmc2130_update_sg()
 		uint16_t tstep = tmc2130_rd_TSTEP(cs);
 		if (tstep < TMC2130_TCOOLTHRS)
 		{
-			if(sg_homing_delay < 10) // wait for a few tens microsteps until stallGuard is used //todo: read out microsteps directly, instead of delay counter
+			if(sg_homing_delay < TMC2130_SG_DELAY) // wait for a few tens microsteps until stallGuard is used //todo: read out microsteps directly, instead of delay counter
 				sg_homing_delay++;
 			else
 			{
@@ -166,6 +180,9 @@ void tmc2130_check_overtemp()
 		for(int i=0;i<4;i++)
 		{
 			uint32_t drv_status = 0;
+
+			skip_debug_msg = true;
+
 			tmc2130_rd(cs[i], TMC2130_REG_DRV_STATUS, &drv_status);
 			//MYSERIAL.print(drv_status);
 			//SERIAL_ECHOPGM(" ");
@@ -219,7 +236,7 @@ void tmc2130_home_exit()
 #endif
 }
 
-extern uint8_t tmc2130_didLastHomingStall()
+uint8_t tmc2130_didLastHomingStall()
 {
 	uint8_t ret = tmc2130_LastHomingStalled;
 	tmc2130_LastHomingStalled = false;
@@ -232,7 +249,7 @@ void tmc2130_set_current_h(uint8_t axis, uint8_t current)
 	MYSERIAL.print((int)axis);
 	MYSERIAL.print(" ");
 	MYSERIAL.println((int)current);
-	if (current > 15) current = 15; //current>15 is unsafe
+//	if (current > 15) current = 15; //current>15 is unsafe
 	tmc2130_current_h[axis] = current;
 	tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f));
 }
@@ -243,7 +260,7 @@ void tmc2130_set_current_r(uint8_t axis, uint8_t current)
 	MYSERIAL.print((int)axis);
 	MYSERIAL.print(" ");
 	MYSERIAL.println((int)current);
-	if (current > 15) current = 15; //current>15 is unsafe
+//	if (current > 15) current = 15; //current>15 is unsafe
 	tmc2130_current_r[axis] = current;
 	tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f));
 }
@@ -270,6 +287,28 @@ void tmc2130_print_currents()
 	MYSERIAL.println((int)tmc2130_current_r[3]);
 }
 
+void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl)
+{
+	MYSERIAL.print("tmc2130_set_pwm_ampl ");
+	MYSERIAL.print((int)axis);
+	MYSERIAL.print(" ");
+	MYSERIAL.println((int)pwm_ampl);
+	tmc2130_pwm_ampl[axis] = pwm_ampl;
+	if (((axis == 0) || (axis == 1)) && (tmc2130_mode == TMC2130_MODE_SILENT))
+		tmc2130_wr_PWMCONF(tmc2130_cs[axis], tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
+}
+
+void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_grad)
+{
+	MYSERIAL.print("tmc2130_set_pwm_grad ");
+	MYSERIAL.print((int)axis);
+	MYSERIAL.print(" ");
+	MYSERIAL.println((int)pwm_grad);
+	tmc2130_pwm_grad[axis] = pwm_grad;
+	if (((axis == 0) || (axis == 1)) && (tmc2130_mode == TMC2130_MODE_SILENT))
+		tmc2130_wr_PWMCONF(tmc2130_cs[axis], tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
+}
+
 uint16_t tmc2130_rd_TSTEP(uint8_t cs)
 {
 	uint32_t val32 = 0;
@@ -285,27 +324,40 @@ uint16_t tmc2130_rd_DRV_STATUS(uint8_t cs)
 	return val32;
 }
 
-void tmc2130_wr_CHOPCONF(uint8_t cs, bool extrapolate256, uint16_t microstep_resolution)
+void tmc2130_wr_CHOPCONF(uint8_t cs, uint8_t toff, uint8_t hstrt, uint8_t hend, uint8_t fd3, uint8_t disfdcc, uint8_t rndtf, uint8_t chm, uint8_t tbl, uint8_t vsense, uint8_t vhighfs, uint8_t vhighchm, uint8_t sync, uint8_t mres, uint8_t intpol, uint8_t dedge, uint8_t diss2g)
 {
-	uint8_t mres=0b0100;
-	if(microstep_resolution == 256) mres = 0b0000;
-	if(microstep_resolution == 128) mres = 0b0001;
-	if(microstep_resolution == 64)  mres = 0b0010;
-	if(microstep_resolution == 32)  mres = 0b0011;
-	if(microstep_resolution == 16)  mres = 0b0100;
-	if(microstep_resolution == 8)   mres = 0b0101;
-	if(microstep_resolution == 4)   mres = 0b0110;
-	if(microstep_resolution == 2)   mres = 0b0111;
-	if(microstep_resolution == 1)   mres = 0b1000;
-	mres |= extrapolate256 << 4; //bit28 intpol
-	//tmc2130_write(cs,0x6C,mres,0x01,0x00,0xD3);
-//	tmc2130_write(cs,0x6C,mres,0x01,0x00,0xC3);
-	tmc2130_wr(cs,TMC2130_REG_CHOPCONF,((uint32_t)mres << 24) | 0x0100C3);
+	uint32_t val = 0;
+	val |= (uint32_t)(toff & 15);
+	val |= (uint32_t)(hstrt & 7) << 4;
+	val |= (uint32_t)(hend & 15) << 7;
+	val |= (uint32_t)(fd3 & 1) << 11;
+	val |= (uint32_t)(disfdcc & 1) << 12;
+	val |= (uint32_t)(rndtf & 1) << 13;
+	val |= (uint32_t)(chm & 1) << 14;
+	val |= (uint32_t)(tbl & 3) << 15;
+	val |= (uint32_t)(vsense & 1) << 17;
+	val |= (uint32_t)(vhighfs & 1) << 18;
+	val |= (uint32_t)(vhighchm & 1) << 19;
+	val |= (uint32_t)(sync & 15) << 20;
+	val |= (uint32_t)(mres & 15) << 24;
+	val |= (uint32_t)(intpol & 1) << 28;
+	val |= (uint32_t)(dedge & 1) << 29;
+	val |= (uint32_t)(diss2g & 1) << 30;
+	tmc2130_wr(cs, TMC2130_REG_CHOPCONF, val);
 }
 
-void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t PWMautoScale, uint8_t PWMfreq, uint8_t PWMgrad, uint8_t PWMampl)
+//void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t PWMautoScale, uint8_t PWMfreq, uint8_t PWMgrad, uint8_t PWMampl)
+void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t pwm_ampl, uint8_t pwm_grad, uint8_t pwm_freq, uint8_t pwm_auto, uint8_t pwm_symm, uint8_t freewheel)
 {
-	tmc2130_wr(cs, TMC2130_REG_PWMCONF, ((uint32_t)(PWMautoScale+PWMfreq) << 16) | ((uint32_t)PWMgrad << 8) | PWMampl); // TMC LJ -> For better readability changed to 0x00 and added PWMautoScale and PWMfreq
+	uint32_t val = 0;
+	val |= (uint32_t)(pwm_ampl & 255);
+	val |= (uint32_t)(pwm_grad & 255) << 8;
+	val |= (uint32_t)(pwm_freq & 3) << 16;
+	val |= (uint32_t)(pwm_auto & 1) << 18;
+	val |= (uint32_t)(pwm_symm & 1) << 19;
+	val |= (uint32_t)(freewheel & 3) << 20;
+	tmc2130_wr(cs, TMC2130_REG_PWMCONF, val);
+//	tmc2130_wr(cs, TMC2130_REG_PWMCONF, ((uint32_t)(PWMautoScale+PWMfreq) << 16) | ((uint32_t)PWMgrad << 8) | PWMampl); // TMC LJ -> For better readability changed to 0x00 and added PWMautoScale and PWMfreq
 }
 
 void tmc2130_wr_TPWMTHRS(uint8_t cs, uint32_t val32)
@@ -331,6 +383,20 @@ uint8_t tmc2130_axis_by_cs(uint8_t cs)
 	return -1;
 }
 
+uint8_t tmc2130_mres(uint16_t microstep_resolution)
+{
+	if (microstep_resolution == 256) return 0b0000;
+	if (microstep_resolution == 128) return 0b0001;
+	if (microstep_resolution == 64)  return 0b0010;
+	if (microstep_resolution == 32)  return 0b0011;
+	if (microstep_resolution == 16)  return 0b0100;
+	if (microstep_resolution == 8)   return 0b0101;
+	if (microstep_resolution == 4)   return 0b0110;
+	if (microstep_resolution == 2)   return 0b0111;
+	if (microstep_resolution == 1)   return 0b1000;
+	return 0;
+}
+
 uint8_t tmc2130_wr(uint8_t cs, uint8_t addr, uint32_t wval)
 {
 	uint8_t stat = tmc2130_txrx(cs, addr | 0x80, wval, 0);
@@ -353,14 +419,18 @@ uint8_t tmc2130_rd(uint8_t cs, uint8_t addr, uint32_t* rval)
 	uint8_t stat = tmc2130_txrx(cs, addr, 0x00000000, &val32);
 	if (rval != 0) *rval = val32;
 #ifdef TMC2130_DEBUG_RD
-	MYSERIAL.print("tmc2130_rd(");
-	MYSERIAL.print((unsigned char)tmc2130_axis_by_cs(cs), DEC);
-	MYSERIAL.print(", 0x");
-	MYSERIAL.print((unsigned char)addr, HEX);
-	MYSERIAL.print(", 0x");
-	MYSERIAL.print((unsigned long)val32, HEX);
-	MYSERIAL.print(")=0x");
-	MYSERIAL.println((unsigned char)stat, HEX);
+	if (!skip_debug_msg)
+	{
+		MYSERIAL.print("tmc2130_rd(");
+		MYSERIAL.print((unsigned char)tmc2130_axis_by_cs(cs), DEC);
+		MYSERIAL.print(", 0x");
+		MYSERIAL.print((unsigned char)addr, HEX);
+		MYSERIAL.print(", 0x");
+		MYSERIAL.print((unsigned long)val32, HEX);
+		MYSERIAL.print(")=0x");
+		MYSERIAL.println((unsigned char)stat, HEX);
+	}
+	skip_debug_msg = false;
 #endif //TMC2130_DEBUG_RD
 	return stat;
 }

+ 8 - 1
Firmware/tmc2130.h

@@ -7,11 +7,13 @@ extern uint8_t tmc2130_mode;
 extern uint8_t tmc2130_current_h[4];
 extern uint8_t tmc2130_current_r[4];
 //flags for axis stall detection
-extern uint8_t tmc2130_axis_stalled[4];
+extern uint8_t tmc2130_axis_stalled[2];
 
 extern uint8_t sg_thrs_x;
 extern uint8_t sg_thrs_y;
 
+extern uint8_t sg_homing_delay;
+
 #define TMC2130_MODE_NORMAL 0
 #define TMC2130_MODE_SILENT 1
 
@@ -35,5 +37,10 @@ extern void tmc2130_set_current_r(uint8_t axis, uint8_t current);
 //print currents (M913)
 extern void tmc2130_print_currents();
 
+//set PWM_AMPL for any axis (M917)
+extern void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl);
+//set PWM_GRAD for any axis (M918)
+extern void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_ampl);
+
 
 #endif //TMC2130_H

+ 7 - 0
Firmware/ultralcd.cpp

@@ -5149,6 +5149,13 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
 
   if (lcd_next_update_millis < millis())
   {
+#ifdef DEBUG_BLINK_ACTIVE
+	static bool active_led = false;
+	active_led = !active_led;
+	pinMode(LED_PIN, OUTPUT);
+	digitalWrite(LED_PIN, active_led?HIGH:LOW);
+#endif //DEBUG_BLINK_ACTIVE
+
 #ifdef ULTIPANEL
 #ifdef REPRAPWORLD_KEYPAD
 	  if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) {

+ 467 - 0
Firmware/variants/1_75mm_MK3-EINY03-E3Dv6full.h

@@ -0,0 +1,467 @@
+#ifndef CONFIGURATION_PRUSA_H
+#define CONFIGURATION_PRUSA_H
+
+/*------------------------------------
+ GENERAL SETTINGS
+ *------------------------------------*/
+
+// Printer revision
+#define FILAMENT_SIZE "1_75mm_MK3"
+#define NOZZLE_TYPE "E3Dv6full"
+
+// Developer flag
+#define DEVELOPER
+
+// Printer name
+#define CUSTOM_MENDEL_NAME "Prusa i3 MK3"
+
+// Electronics
+//#define MOTHERBOARD BOARD_EINY_0_4a
+#define MOTHERBOARD BOARD_EINY_0_3a
+
+
+// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier)
+//#define E3D_PT100_EXTRUDER_WITH_AMP
+//#define E3D_PT100_EXTRUDER_NO_AMP
+//#define E3D_PT100_BED_WITH_AMP
+//#define E3D_PT100_BED_NO_AMP
+
+
+/*------------------------------------
+ AXIS SETTINGS
+ *------------------------------------*/
+
+// Steps per unit {X,Y,Z,E}
+//#define DEFAULT_AXIS_STEPS_PER_UNIT   {100,100,3200/8,140}
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {100,100,3200/8,280}
+
+// Endstop inverting
+const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
+const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
+const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
+
+// Home position
+#define MANUAL_X_HOME_POS 0
+#define MANUAL_Y_HOME_POS -2.2
+#define MANUAL_Z_HOME_POS 0.2
+
+// Travel limits after homing
+#define X_MAX_POS 255
+#define X_MIN_POS 0
+#define Y_MAX_POS 210
+#define Y_MIN_POS -4
+#define Z_MAX_POS 210
+#define Z_MIN_POS 0.15
+
+// Canceled home position
+#define X_CANCEL_POS 50
+#define Y_CANCEL_POS 190
+
+//Pause print position
+#define X_PAUSE_POS 50
+#define Y_PAUSE_POS 190
+#define Z_PAUSE_LIFT 20
+
+#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
+#define HOMING_FEEDRATE {3000, 3000, 800, 0}  // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
+
+//#define DEFAULT_MAX_FEEDRATE          {400, 400, 12, 120}    // (mm/sec)
+#define DEFAULT_MAX_FEEDRATE          {500, 500, 12, 120}    // (mm/sec)
+#define DEFAULT_MAX_ACCELERATION      {2000, 2000, 250, 5000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
+
+#define DEFAULT_ACCELERATION          1500   // X, Y, Z and E max acceleration in mm/s^2 for printing moves
+#define DEFAULT_RETRACT_ACCELERATION  1500   // X, Y, Z and E max acceleration in mm/s^2 for retracts
+
+
+#define MANUAL_FEEDRATE {2700, 2700, 1000, 100}   // set the speeds for manual moves (mm/min)
+//#define MAX_SILENT_FEEDRATE           2700   // 
+
+#define Z_AXIS_ALWAYS_ON 1
+
+//DEBUG
+#if 0
+#define DEBUG_DISABLE_STARTMSGS //no startup messages 
+#define DEBUG_DISABLE_MINTEMP   //mintemp error ignored
+#define DEBUG_DISABLE_SWLIMITS  //sw limits ignored
+#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
+#define DEBUG_XSTEP_DUP_PIN 21   //duplicate x-step output to pin 21 (SCL on P3)
+//#define DEBUG_YSTEP_DUP_PIN 21   //duplicate y-step output to pin 21 (SCL on P3)
+//#define DEBUG_BLINK_ACTIVE
+#endif
+
+/*------------------------------------
+ TMC2130 default settings
+ *------------------------------------*/
+
+#define TMC2130_FCLK 12000000       // fclk = 12MHz
+
+#define TMC2130_USTEPS_XY   16        // microstep resolution for XY axes
+#define TMC2130_USTEPS_Z    16        // microstep resolution for Z axis
+#define TMC2130_USTEPS_E    16        // microstep resolution for E axis
+#define TMC2130_INTPOL_XY   1         // extrapolate 256 for XY axes
+#define TMC2130_INTPOL_Z    1         // extrapolate 256 for Z axis
+#define TMC2130_INTPOL_E    1         // extrapolate 256 for E axis
+
+#define TMC2130_PWM_GRAD_XY 15         // PWMCONF
+#define TMC2130_PWM_AMPL_XY 200       // PWMCONF
+#define TMC2130_PWM_AUTO_XY 1         // PWMCONF
+#define TMC2130_PWM_FREQ_XY 2         // PWMCONF
+
+/* //not used
+#define TMC2130_PWM_GRAD_Z  4         // PWMCONF
+#define TMC2130_PWM_AMPL_Z  200       // PWMCONF
+#define TMC2130_PWM_AUTO_Z  1         // PWMCONF
+#define TMC2130_PWM_FREQ_Z  2         // PWMCONF
+#define TMC2130_PWM_GRAD_E  4         // PWMCONF
+#define TMC2130_PWM_AMPL_E  200       // PWMCONF
+#define TMC2130_PWM_AUTO_E  1         // PWMCONF
+#define TMC2130_PWM_FREQ_E  2         // PWMCONF
+*/
+
+//#define TMC2130_PWM_DIV  683        // PWM frequency divider (1024, 683, 512, 410)
+#define TMC2130_PWM_DIV  512        // PWM frequency divider (1024, 683, 512, 410)
+#define TMC2130_PWM_CLK  (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk)
+
+#define TMC2130_TPWMTHRS 0          // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
+#define TMC2130_THIGH 0             // THIGH - unused
+
+#define TMC2130_TCOOLTHRS 239       // TCOOLTHRS - coolstep treshold
+
+#define TMC2130_SG_HOMING     1     // stallguard homing
+#define TMC2130_SG_HOMING_SW  1     // stallguard "software" homing
+#define TMC2130_SG_THRS_X    30     // stallguard sensitivity for X axis
+#define TMC2130_SG_THRS_Y    30     // stallguard sensitivity for Y axis
+#define TMC2130_SG_DELAY     10     // stallguard delay (temporary solution)
+
+//new settings is possible for vsense = 1
+#define TMC2130_CURRENTS_H {3, 3, 5, 8}  // default holding currents for all axes
+#define TMC2130_CURRENTS_R {13, 13, 20, 20}  // default running currents for all axes
+
+#define TMC2130_DEBUG
+//#define TMC2130_DEBUG_WR
+//#define TMC2130_DEBUG_RD
+
+
+/*------------------------------------
+ EXTRUDER SETTINGS
+ *------------------------------------*/
+
+// Mintemps
+#define HEATER_0_MINTEMP 15
+#define HEATER_1_MINTEMP 5
+#define HEATER_2_MINTEMP 5
+#define BED_MINTEMP 15
+
+// Maxtemps
+#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP)
+#define HEATER_0_MAXTEMP 410
+#else
+#define HEATER_0_MAXTEMP 305
+#endif
+#define HEATER_1_MAXTEMP 305
+#define HEATER_2_MAXTEMP 305
+#define BED_MAXTEMP 150
+
+#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP)
+// Define PID constants for extruder with PT100
+#define  DEFAULT_Kp 21.70
+#define  DEFAULT_Ki 1.60
+#define  DEFAULT_Kd 73.76
+#else
+// Define PID constants for extruder
+//#define  DEFAULT_Kp 40.925
+//#define  DEFAULT_Ki 4.875
+//#define  DEFAULT_Kd 86.085
+#define  DEFAULT_Kp 16.13
+#define  DEFAULT_Ki 1.1625
+#define  DEFAULT_Kd 56.23
+#endif
+
+// Extrude mintemp
+#define EXTRUDE_MINTEMP 130
+
+// Extruder cooling fans
+#define EXTRUDER_0_AUTO_FAN_PIN   8
+#define EXTRUDER_1_AUTO_FAN_PIN   -1
+#define EXTRUDER_2_AUTO_FAN_PIN   -1
+#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
+#define EXTRUDER_AUTO_FAN_SPEED   255  // == full speed
+
+
+
+/*------------------------------------
+ LOAD/UNLOAD FILAMENT SETTINGS
+ *------------------------------------*/
+
+// Load filament commands
+#define LOAD_FILAMENT_0 "M83"
+#define LOAD_FILAMENT_1 "G1 E70 F400"
+#define LOAD_FILAMENT_2 "G1 E40 F100"
+
+// Unload filament commands
+#define UNLOAD_FILAMENT_0 "M83"
+#define UNLOAD_FILAMENT_1 "G1 E-80 F7000"
+
+/*------------------------------------
+ CHANGE FILAMENT SETTINGS
+ *------------------------------------*/
+
+// Filament change configuration
+#define FILAMENTCHANGEENABLE
+#ifdef FILAMENTCHANGEENABLE
+#define FILAMENTCHANGE_XPOS 211
+#define FILAMENTCHANGE_YPOS 0
+#define FILAMENTCHANGE_ZADD 2
+#define FILAMENTCHANGE_FIRSTRETRACT -2
+#define FILAMENTCHANGE_FINALRETRACT -80
+
+#define FILAMENTCHANGE_FIRSTFEED 70
+#define FILAMENTCHANGE_FINALFEED 50
+#define FILAMENTCHANGE_RECFEED 5
+
+#define FILAMENTCHANGE_XYFEED 50
+#define FILAMENTCHANGE_EFEED 20
+#define FILAMENTCHANGE_RFEED 400
+#define FILAMENTCHANGE_EXFEED 2
+#define FILAMENTCHANGE_ZFEED 15
+
+#endif
+
+/*------------------------------------
+ ADDITIONAL FEATURES SETTINGS
+ *------------------------------------*/
+
+// Define Prusa filament runout sensor
+//#define FILAMENT_RUNOUT_SUPPORT
+
+#ifdef FILAMENT_RUNOUT_SUPPORT
+#define FILAMENT_RUNOUT_SENSOR 1
+#endif
+
+// temperature runaway
+//#define TEMP_RUNAWAY_BED_HYSTERESIS 5
+//#define TEMP_RUNAWAY_BED_TIMEOUT 360
+
+#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15
+#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45
+
+/*------------------------------------
+ MOTOR CURRENT SETTINGS
+ *------------------------------------*/
+
+// Motor Current setting for BIG RAMBo
+#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
+#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
+
+// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
+#if MOTHERBOARD == 102 || MOTHERBOARD == 302 || MOTHERBOARD == 300 || MOTHERBOARD == 299
+#define MOTOR_CURRENT_PWM_RANGE 2000
+#define DEFAULT_PWM_MOTOR_CURRENT  {400, 750, 750} // {XY,Z,E}
+#define DEFAULT_PWM_MOTOR_CURRENT_LOUD  {400, 750, 750} // {XY,Z,E}
+#endif
+
+/*------------------------------------
+ BED SETTINGS
+ *------------------------------------*/
+
+// Define Mesh Bed Leveling system to enable it
+#define MESH_BED_LEVELING
+#ifdef MESH_BED_LEVELING
+
+#define MBL_Z_STEP 0.01
+
+// Mesh definitions
+#define MESH_MIN_X 35
+#define MESH_MAX_X 238
+#define MESH_MIN_Y 6
+#define MESH_MAX_Y 202
+
+// Mesh upsample definition
+#define MESH_NUM_X_POINTS 7
+#define MESH_NUM_Y_POINTS 7
+// Mesh measure definition
+#define MESH_MEAS_NUM_X_POINTS 3
+#define MESH_MEAS_NUM_Y_POINTS 3
+
+#define MESH_HOME_Z_CALIB 0.2
+#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc.
+
+#define X_PROBE_OFFSET_FROM_EXTRUDER 23     // Z probe to nozzle X offset: -left  +right
+#define Y_PROBE_OFFSET_FROM_EXTRUDER 9     // Z probe to nozzle Y offset: -front +behind
+#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4  // Z probe to nozzle Z offset: -below (always!)
+#endif
+
+// Bed Temperature Control
+// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
+//
+// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder.
+// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
+// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
+// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
+// If your configuration is significantly different than this and you don't understand the issues involved, you probably
+// shouldn't use bed PID until someone else verifies your hardware works.
+// If this is enabled, find your own PID constants below.
+#define PIDTEMPBED
+//
+//#define BED_LIMIT_SWITCHING
+
+// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
+// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
+// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
+// so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
+#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
+
+// Bed temperature compensation settings
+#define BED_OFFSET 10
+#define BED_OFFSET_START 40
+#define BED_OFFSET_CENTER 50
+
+
+#ifdef PIDTEMPBED
+//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
+//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
+#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP)
+// Define PID constants for extruder with PT100
+#define  DEFAULT_bedKp 21.70
+#define  DEFAULT_bedKi 1.60
+#define  DEFAULT_bedKd 73.76
+#else
+#define  DEFAULT_bedKp 126.13
+#define  DEFAULT_bedKi 4.30
+#define  DEFAULT_bedKd 924.76
+#endif
+
+//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
+//from pidautotune
+//    #define  DEFAULT_bedKp 97.1
+//    #define  DEFAULT_bedKi 1.41
+//    #define  DEFAULT_bedKd 1675.16
+
+// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
+#endif // PIDTEMPBED
+
+
+/*-----------------------------------
+ PREHEAT SETTINGS
+ *------------------------------------*/
+
+#define PLA_PREHEAT_HOTEND_TEMP 215
+#define PLA_PREHEAT_HPB_TEMP 55
+#define PLA_PREHEAT_FAN_SPEED 0
+
+#define ABS_PREHEAT_HOTEND_TEMP 255
+#define ABS_PREHEAT_HPB_TEMP 100
+#define ABS_PREHEAT_FAN_SPEED 0
+
+#define HIPS_PREHEAT_HOTEND_TEMP 220
+#define HIPS_PREHEAT_HPB_TEMP 100
+#define HIPS_PREHEAT_FAN_SPEED 0
+
+#define PP_PREHEAT_HOTEND_TEMP 254
+#define PP_PREHEAT_HPB_TEMP 100
+#define PP_PREHEAT_FAN_SPEED 0
+
+#define PET_PREHEAT_HOTEND_TEMP 240
+#define PET_PREHEAT_HPB_TEMP 90
+#define PET_PREHEAT_FAN_SPEED 0
+
+#define FLEX_PREHEAT_HOTEND_TEMP 230
+#define FLEX_PREHEAT_HPB_TEMP 50
+#define FLEX_PREHEAT_FAN_SPEED 0
+
+/*------------------------------------
+ THERMISTORS SETTINGS
+ *------------------------------------*/
+
+//
+//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
+//
+//// Temperature sensor settings:
+// -2 is thermocouple with MAX6675 (only for sensor 0)
+// -1 is thermocouple with AD595
+// 0 is not used
+// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
+// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
+// 3 is Mendel-parts thermistor (4.7k pullup)
+// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
+// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup)
+// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
+// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
+// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
+// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
+// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
+// 10 is 100k RS thermistor 198-961 (4.7k pullup)
+// 11 is 100k beta 3950 1% thermistor (4.7k pullup)
+// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
+// 13 is 100k Hisens 3950  1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
+// 20 is the PT100 circuit found in the Ultimainboard V2.x
+// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
+//
+//    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
+//                          (but gives greater accuracy and more stable PID)
+// 51 is 100k thermistor - EPCOS (1k pullup)
+// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
+// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup)
+//
+// 1047 is Pt1000 with 4k7 pullup
+// 1010 is Pt1000 with 1k pullup (non standard)
+// 147 is Pt100 with 4k7 pullup
+// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a
+// 247 is Pt100 with 4k7 pullup and PT100 Amplifier
+// 110 is Pt100 with 1k pullup (non standard)
+
+#if defined(E3D_PT100_EXTRUDER_WITH_AMP)
+#define TEMP_SENSOR_0 247
+#elif defined(E3D_PT100_EXTRUDER_NO_AMP)
+#define TEMP_SENSOR_0 148
+#else
+#define TEMP_SENSOR_0 5
+#endif
+#define TEMP_SENSOR_1 0
+#define TEMP_SENSOR_2 0
+#if defined(E3D_PT100_BED_WITH_AMP)
+#define TEMP_SENSOR_BED 247
+#elif defined(E3D_PT100_BED_NO_AMP)
+#define TEMP_SENSOR_BED 148
+#else
+#define TEMP_SENSOR_BED 1
+#endif
+
+#define STACK_GUARD_TEST_VALUE 0xA2A2
+
+#define MAX_BED_TEMP_CALIBRATION 50
+#define MAX_HOTEND_TEMP_CALIBRATION 50
+
+#define MAX_E_STEPS_PER_UNIT 250
+#define MIN_E_STEPS_PER_UNIT 100
+
+#define Z_BABYSTEP_MIN -3999
+#define Z_BABYSTEP_MAX 0
+
+#define PINDA_PREHEAT_X 70
+#define PINDA_PREHEAT_Y -3
+#define PINDA_PREHEAT_Z 1
+#define PINDA_HEAT_T 120 //time in s
+
+#define PINDA_MIN_T 50
+#define PINDA_STEP_T 10
+#define PINDA_MAX_T 100
+
+#define PING_TIME 60 //time in s
+#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
+#define PING_ALLERT_PERIOD 60 //time in s
+
+#define LONG_PRESS_TIME 1000 //time in ms for button long press
+#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release
+
+#define DEFAULT_PID_TEMP 210
+
+#define MIN_PRINT_FAN_SPEED 50
+
+#ifdef SNMM
+#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print
+#else
+#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print
+#endif
+
+#endif //__CONFIGURATION_PRUSA_H

+ 467 - 0
Firmware/variants/1_75mm_MK3-EINY04-E3Dv6full.h

@@ -0,0 +1,467 @@
+#ifndef CONFIGURATION_PRUSA_H
+#define CONFIGURATION_PRUSA_H
+
+/*------------------------------------
+ GENERAL SETTINGS
+ *------------------------------------*/
+
+// Printer revision
+#define FILAMENT_SIZE "1_75mm_MK3"
+#define NOZZLE_TYPE "E3Dv6full"
+
+// Developer flag
+#define DEVELOPER
+
+// Printer name
+#define CUSTOM_MENDEL_NAME "Prusa i3 MK3"
+
+// Electronics
+#define MOTHERBOARD BOARD_EINY_0_4a
+//#define MOTHERBOARD BOARD_EINY_0_3a
+
+
+// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier)
+//#define E3D_PT100_EXTRUDER_WITH_AMP
+//#define E3D_PT100_EXTRUDER_NO_AMP
+//#define E3D_PT100_BED_WITH_AMP
+//#define E3D_PT100_BED_NO_AMP
+
+
+/*------------------------------------
+ AXIS SETTINGS
+ *------------------------------------*/
+
+// Steps per unit {X,Y,Z,E}
+//#define DEFAULT_AXIS_STEPS_PER_UNIT   {100,100,3200/8,140}
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {100,100,3200/8,280}
+
+// Endstop inverting
+const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
+const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
+const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
+
+// Home position
+#define MANUAL_X_HOME_POS 0
+#define MANUAL_Y_HOME_POS -2.2
+#define MANUAL_Z_HOME_POS 0.2
+
+// Travel limits after homing
+#define X_MAX_POS 255
+#define X_MIN_POS 0
+#define Y_MAX_POS 210
+#define Y_MIN_POS -4
+#define Z_MAX_POS 210
+#define Z_MIN_POS 0.15
+
+// Canceled home position
+#define X_CANCEL_POS 50
+#define Y_CANCEL_POS 190
+
+//Pause print position
+#define X_PAUSE_POS 50
+#define Y_PAUSE_POS 190
+#define Z_PAUSE_LIFT 20
+
+#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
+#define HOMING_FEEDRATE {3000, 3000, 800, 0}  // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
+
+//#define DEFAULT_MAX_FEEDRATE          {400, 400, 12, 120}    // (mm/sec)
+#define DEFAULT_MAX_FEEDRATE          {500, 500, 12, 120}    // (mm/sec)
+#define DEFAULT_MAX_ACCELERATION      {2000, 2000, 250, 5000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
+
+#define DEFAULT_ACCELERATION          1500   // X, Y, Z and E max acceleration in mm/s^2 for printing moves
+#define DEFAULT_RETRACT_ACCELERATION  1500   // X, Y, Z and E max acceleration in mm/s^2 for retracts
+
+
+#define MANUAL_FEEDRATE {2700, 2700, 1000, 100}   // set the speeds for manual moves (mm/min)
+//#define MAX_SILENT_FEEDRATE           2700   // 
+
+#define Z_AXIS_ALWAYS_ON 1
+
+//DEBUG
+#if 0
+#define DEBUG_DISABLE_STARTMSGS //no startup messages 
+#define DEBUG_DISABLE_MINTEMP   //mintemp error ignored
+#define DEBUG_DISABLE_SWLIMITS  //sw limits ignored
+#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
+#define DEBUG_XSTEP_DUP_PIN 21   //duplicate x-step output to pin 21 (SCL on P3)
+//#define DEBUG_YSTEP_DUP_PIN 21   //duplicate y-step output to pin 21 (SCL on P3)
+//#define DEBUG_BLINK_ACTIVE
+#endif
+
+/*------------------------------------
+ TMC2130 default settings
+ *------------------------------------*/
+
+#define TMC2130_FCLK 12000000       // fclk = 12MHz
+
+#define TMC2130_USTEPS_XY   16        // microstep resolution for XY axes
+#define TMC2130_USTEPS_Z    16        // microstep resolution for Z axis
+#define TMC2130_USTEPS_E    16        // microstep resolution for E axis
+#define TMC2130_INTPOL_XY   1         // extrapolate 256 for XY axes
+#define TMC2130_INTPOL_Z    1         // extrapolate 256 for Z axis
+#define TMC2130_INTPOL_E    1         // extrapolate 256 for E axis
+
+#define TMC2130_PWM_GRAD_XY 15         // PWMCONF
+#define TMC2130_PWM_AMPL_XY 200       // PWMCONF
+#define TMC2130_PWM_AUTO_XY 1         // PWMCONF
+#define TMC2130_PWM_FREQ_XY 2         // PWMCONF
+
+/* //not used
+#define TMC2130_PWM_GRAD_Z  4         // PWMCONF
+#define TMC2130_PWM_AMPL_Z  200       // PWMCONF
+#define TMC2130_PWM_AUTO_Z  1         // PWMCONF
+#define TMC2130_PWM_FREQ_Z  2         // PWMCONF
+#define TMC2130_PWM_GRAD_E  4         // PWMCONF
+#define TMC2130_PWM_AMPL_E  200       // PWMCONF
+#define TMC2130_PWM_AUTO_E  1         // PWMCONF
+#define TMC2130_PWM_FREQ_E  2         // PWMCONF
+*/
+
+//#define TMC2130_PWM_DIV  683        // PWM frequency divider (1024, 683, 512, 410)
+#define TMC2130_PWM_DIV  512        // PWM frequency divider (1024, 683, 512, 410)
+#define TMC2130_PWM_CLK  (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk)
+
+#define TMC2130_TPWMTHRS 0          // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
+#define TMC2130_THIGH 0             // THIGH - unused
+
+#define TMC2130_TCOOLTHRS 239       // TCOOLTHRS - coolstep treshold
+
+#define TMC2130_SG_HOMING     1     // stallguard homing
+#define TMC2130_SG_HOMING_SW  1     // stallguard "software" homing
+#define TMC2130_SG_THRS_X    30     // stallguard sensitivity for X axis
+#define TMC2130_SG_THRS_Y    30     // stallguard sensitivity for Y axis
+#define TMC2130_SG_DELAY     10     // stallguard delay (temporary solution)
+
+//new settings is possible for vsense = 1
+#define TMC2130_CURRENTS_H {3, 3, 5, 8}  // default holding currents for all axes
+#define TMC2130_CURRENTS_R {13, 13, 20, 20}  // default running currents for all axes
+
+#define TMC2130_DEBUG
+//#define TMC2130_DEBUG_WR
+//#define TMC2130_DEBUG_RD
+
+
+/*------------------------------------
+ EXTRUDER SETTINGS
+ *------------------------------------*/
+
+// Mintemps
+#define HEATER_0_MINTEMP 15
+#define HEATER_1_MINTEMP 5
+#define HEATER_2_MINTEMP 5
+#define BED_MINTEMP 15
+
+// Maxtemps
+#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP)
+#define HEATER_0_MAXTEMP 410
+#else
+#define HEATER_0_MAXTEMP 305
+#endif
+#define HEATER_1_MAXTEMP 305
+#define HEATER_2_MAXTEMP 305
+#define BED_MAXTEMP 150
+
+#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP)
+// Define PID constants for extruder with PT100
+#define  DEFAULT_Kp 21.70
+#define  DEFAULT_Ki 1.60
+#define  DEFAULT_Kd 73.76
+#else
+// Define PID constants for extruder
+//#define  DEFAULT_Kp 40.925
+//#define  DEFAULT_Ki 4.875
+//#define  DEFAULT_Kd 86.085
+#define  DEFAULT_Kp 16.13
+#define  DEFAULT_Ki 1.1625
+#define  DEFAULT_Kd 56.23
+#endif
+
+// Extrude mintemp
+#define EXTRUDE_MINTEMP 130
+
+// Extruder cooling fans
+#define EXTRUDER_0_AUTO_FAN_PIN   8
+#define EXTRUDER_1_AUTO_FAN_PIN   -1
+#define EXTRUDER_2_AUTO_FAN_PIN   -1
+#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
+#define EXTRUDER_AUTO_FAN_SPEED   255  // == full speed
+
+
+
+/*------------------------------------
+ LOAD/UNLOAD FILAMENT SETTINGS
+ *------------------------------------*/
+
+// Load filament commands
+#define LOAD_FILAMENT_0 "M83"
+#define LOAD_FILAMENT_1 "G1 E70 F400"
+#define LOAD_FILAMENT_2 "G1 E40 F100"
+
+// Unload filament commands
+#define UNLOAD_FILAMENT_0 "M83"
+#define UNLOAD_FILAMENT_1 "G1 E-80 F7000"
+
+/*------------------------------------
+ CHANGE FILAMENT SETTINGS
+ *------------------------------------*/
+
+// Filament change configuration
+#define FILAMENTCHANGEENABLE
+#ifdef FILAMENTCHANGEENABLE
+#define FILAMENTCHANGE_XPOS 211
+#define FILAMENTCHANGE_YPOS 0
+#define FILAMENTCHANGE_ZADD 2
+#define FILAMENTCHANGE_FIRSTRETRACT -2
+#define FILAMENTCHANGE_FINALRETRACT -80
+
+#define FILAMENTCHANGE_FIRSTFEED 70
+#define FILAMENTCHANGE_FINALFEED 50
+#define FILAMENTCHANGE_RECFEED 5
+
+#define FILAMENTCHANGE_XYFEED 50
+#define FILAMENTCHANGE_EFEED 20
+#define FILAMENTCHANGE_RFEED 400
+#define FILAMENTCHANGE_EXFEED 2
+#define FILAMENTCHANGE_ZFEED 15
+
+#endif
+
+/*------------------------------------
+ ADDITIONAL FEATURES SETTINGS
+ *------------------------------------*/
+
+// Define Prusa filament runout sensor
+//#define FILAMENT_RUNOUT_SUPPORT
+
+#ifdef FILAMENT_RUNOUT_SUPPORT
+#define FILAMENT_RUNOUT_SENSOR 1
+#endif
+
+// temperature runaway
+//#define TEMP_RUNAWAY_BED_HYSTERESIS 5
+//#define TEMP_RUNAWAY_BED_TIMEOUT 360
+
+#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15
+#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45
+
+/*------------------------------------
+ MOTOR CURRENT SETTINGS
+ *------------------------------------*/
+
+// Motor Current setting for BIG RAMBo
+#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
+#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
+
+// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
+#if MOTHERBOARD == 102 || MOTHERBOARD == 302 || MOTHERBOARD == 300 || MOTHERBOARD == 299
+#define MOTOR_CURRENT_PWM_RANGE 2000
+#define DEFAULT_PWM_MOTOR_CURRENT  {400, 750, 750} // {XY,Z,E}
+#define DEFAULT_PWM_MOTOR_CURRENT_LOUD  {400, 750, 750} // {XY,Z,E}
+#endif
+
+/*------------------------------------
+ BED SETTINGS
+ *------------------------------------*/
+
+// Define Mesh Bed Leveling system to enable it
+#define MESH_BED_LEVELING
+#ifdef MESH_BED_LEVELING
+
+#define MBL_Z_STEP 0.01
+
+// Mesh definitions
+#define MESH_MIN_X 35
+#define MESH_MAX_X 238
+#define MESH_MIN_Y 6
+#define MESH_MAX_Y 202
+
+// Mesh upsample definition
+#define MESH_NUM_X_POINTS 7
+#define MESH_NUM_Y_POINTS 7
+// Mesh measure definition
+#define MESH_MEAS_NUM_X_POINTS 3
+#define MESH_MEAS_NUM_Y_POINTS 3
+
+#define MESH_HOME_Z_CALIB 0.2
+#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc.
+
+#define X_PROBE_OFFSET_FROM_EXTRUDER 23     // Z probe to nozzle X offset: -left  +right
+#define Y_PROBE_OFFSET_FROM_EXTRUDER 9     // Z probe to nozzle Y offset: -front +behind
+#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4  // Z probe to nozzle Z offset: -below (always!)
+#endif
+
+// Bed Temperature Control
+// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
+//
+// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder.
+// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
+// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
+// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
+// If your configuration is significantly different than this and you don't understand the issues involved, you probably
+// shouldn't use bed PID until someone else verifies your hardware works.
+// If this is enabled, find your own PID constants below.
+#define PIDTEMPBED
+//
+//#define BED_LIMIT_SWITCHING
+
+// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
+// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
+// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
+// so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
+#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
+
+// Bed temperature compensation settings
+#define BED_OFFSET 10
+#define BED_OFFSET_START 40
+#define BED_OFFSET_CENTER 50
+
+
+#ifdef PIDTEMPBED
+//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
+//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
+#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP)
+// Define PID constants for extruder with PT100
+#define  DEFAULT_bedKp 21.70
+#define  DEFAULT_bedKi 1.60
+#define  DEFAULT_bedKd 73.76
+#else
+#define  DEFAULT_bedKp 126.13
+#define  DEFAULT_bedKi 4.30
+#define  DEFAULT_bedKd 924.76
+#endif
+
+//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
+//from pidautotune
+//    #define  DEFAULT_bedKp 97.1
+//    #define  DEFAULT_bedKi 1.41
+//    #define  DEFAULT_bedKd 1675.16
+
+// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
+#endif // PIDTEMPBED
+
+
+/*-----------------------------------
+ PREHEAT SETTINGS
+ *------------------------------------*/
+
+#define PLA_PREHEAT_HOTEND_TEMP 215
+#define PLA_PREHEAT_HPB_TEMP 55
+#define PLA_PREHEAT_FAN_SPEED 0
+
+#define ABS_PREHEAT_HOTEND_TEMP 255
+#define ABS_PREHEAT_HPB_TEMP 100
+#define ABS_PREHEAT_FAN_SPEED 0
+
+#define HIPS_PREHEAT_HOTEND_TEMP 220
+#define HIPS_PREHEAT_HPB_TEMP 100
+#define HIPS_PREHEAT_FAN_SPEED 0
+
+#define PP_PREHEAT_HOTEND_TEMP 254
+#define PP_PREHEAT_HPB_TEMP 100
+#define PP_PREHEAT_FAN_SPEED 0
+
+#define PET_PREHEAT_HOTEND_TEMP 240
+#define PET_PREHEAT_HPB_TEMP 90
+#define PET_PREHEAT_FAN_SPEED 0
+
+#define FLEX_PREHEAT_HOTEND_TEMP 230
+#define FLEX_PREHEAT_HPB_TEMP 50
+#define FLEX_PREHEAT_FAN_SPEED 0
+
+/*------------------------------------
+ THERMISTORS SETTINGS
+ *------------------------------------*/
+
+//
+//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
+//
+//// Temperature sensor settings:
+// -2 is thermocouple with MAX6675 (only for sensor 0)
+// -1 is thermocouple with AD595
+// 0 is not used
+// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
+// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
+// 3 is Mendel-parts thermistor (4.7k pullup)
+// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
+// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup)
+// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
+// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
+// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
+// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
+// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
+// 10 is 100k RS thermistor 198-961 (4.7k pullup)
+// 11 is 100k beta 3950 1% thermistor (4.7k pullup)
+// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
+// 13 is 100k Hisens 3950  1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
+// 20 is the PT100 circuit found in the Ultimainboard V2.x
+// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
+//
+//    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
+//                          (but gives greater accuracy and more stable PID)
+// 51 is 100k thermistor - EPCOS (1k pullup)
+// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
+// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup)
+//
+// 1047 is Pt1000 with 4k7 pullup
+// 1010 is Pt1000 with 1k pullup (non standard)
+// 147 is Pt100 with 4k7 pullup
+// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a
+// 247 is Pt100 with 4k7 pullup and PT100 Amplifier
+// 110 is Pt100 with 1k pullup (non standard)
+
+#if defined(E3D_PT100_EXTRUDER_WITH_AMP)
+#define TEMP_SENSOR_0 247
+#elif defined(E3D_PT100_EXTRUDER_NO_AMP)
+#define TEMP_SENSOR_0 148
+#else
+#define TEMP_SENSOR_0 5
+#endif
+#define TEMP_SENSOR_1 0
+#define TEMP_SENSOR_2 0
+#if defined(E3D_PT100_BED_WITH_AMP)
+#define TEMP_SENSOR_BED 247
+#elif defined(E3D_PT100_BED_NO_AMP)
+#define TEMP_SENSOR_BED 148
+#else
+#define TEMP_SENSOR_BED 1
+#endif
+
+#define STACK_GUARD_TEST_VALUE 0xA2A2
+
+#define MAX_BED_TEMP_CALIBRATION 50
+#define MAX_HOTEND_TEMP_CALIBRATION 50
+
+#define MAX_E_STEPS_PER_UNIT 250
+#define MIN_E_STEPS_PER_UNIT 100
+
+#define Z_BABYSTEP_MIN -3999
+#define Z_BABYSTEP_MAX 0
+
+#define PINDA_PREHEAT_X 70
+#define PINDA_PREHEAT_Y -3
+#define PINDA_PREHEAT_Z 1
+#define PINDA_HEAT_T 120 //time in s
+
+#define PINDA_MIN_T 50
+#define PINDA_STEP_T 10
+#define PINDA_MAX_T 100
+
+#define PING_TIME 60 //time in s
+#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
+#define PING_ALLERT_PERIOD 60 //time in s
+
+#define LONG_PRESS_TIME 1000 //time in ms for button long press
+#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release
+
+#define DEFAULT_PID_TEMP 210
+
+#define MIN_PRINT_FAN_SPEED 50
+
+#ifdef SNMM
+#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print
+#else
+#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print
+#endif
+
+#endif //__CONFIGURATION_PRUSA_H