Browse Source

Disable bed PWM while probing bed.

leptun 4 years ago
parent
commit
570b5989f4
2 changed files with 10 additions and 0 deletions
  1. 6 0
      Firmware/heatbed_pwm.cpp
  2. 4 0
      Firmware/mesh_bed_calibration.cpp

+ 6 - 0
Firmware/heatbed_pwm.cpp

@@ -61,6 +61,8 @@ enum class States : uint8_t {
 ///! Inner states of the finite automaton
 static States state = States::ZERO_START;
 
+bool bedPWMDisabled = 0;
+
 ///! Fast PWM counter is used in the RISE and FALL states (62.5kHz)
 static uint8_t slowCounter = 0;
 ///! Slow PWM counter is used in the ZERO and ONE states (62.5kHz/8 or 64)
@@ -93,6 +95,7 @@ ISR(TIMER0_OVF_vect)          // timer compare interrupt service routine
 {
 	switch(state){
 	case States::ZERO_START:
+		if (bedPWMDisabled) break;
 		pwm = soft_pwm_bed << 1;// expecting soft_pwm_bed to be 7bit!
 		if( pwm != 0 ){
 			state = States::ZERO;     // do nothing, let it tick once again after the 30Hz period
@@ -144,6 +147,9 @@ ISR(TIMER0_OVF_vect)          // timer compare interrupt service routine
 			// if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating
 			return;           // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf
 		}
+		if (bedPWMDisabled){
+			return;
+		}
 		// otherwise moving towards FALL
 		// @@TODO it looks like ONE_TO_FALL isn't necessary, there are no artefacts at all
 		state = States::ONE;//_TO_FALL;

+ 4 - 0
Firmware/mesh_bed_calibration.cpp

@@ -23,6 +23,7 @@ float   world2machine_shift[2];
 #define WEIGHT_FIRST_ROW_Y_HIGH (0.3f)
 #define WEIGHT_FIRST_ROW_Y_LOW  (0.0f)
 
+extern bool bedPWMDisabled;
 
 
 // Scaling of the real machine axes against the programmed dimensions in the firmware.
@@ -946,6 +947,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i
         )
 {
 	bool high_deviation_occured = false; 
+    bedPWMDisabled = 1;
 #ifdef TMC2130
 	FORCE_HIGH_POWER_START;
 #endif
@@ -1044,6 +1046,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i
 #ifdef TMC2130
 	FORCE_HIGH_POWER_END;
 #endif
+    bedPWMDisabled = 0;
 	return true;
 
 error:
@@ -1053,6 +1056,7 @@ error:
 #ifdef TMC2130
 	FORCE_HIGH_POWER_END;
 #endif
+    bedPWMDisabled = 0;
 	return false;
 }