示例#1
0
// Perform homing cycle to locate and set machine zero. Only '$H' executes this command.
// NOTE: There should be no motions in the buffer and Grbl must be in an idle state before
// executing the homing cycle. This prevents incorrect buffered plans after homing.
void mc_homing_cycle()
{
  sys.state = STATE_HOMING; // Set system state variable
  limits_disable(); // Disable hard limits pin change register for cycle duration

  // -------------------------------------------------------------------------------------
  // Perform homing routine. NOTE: Special motion case. Only system reset works.

  // Search to engage all axes limit switches at faster homing seek rate.
  limits_go_home(HOMING_CYCLE_0);  // Homing cycle 0
  #ifdef HOMING_CYCLE_1
    limits_go_home(HOMING_CYCLE_1);  // Homing cycle 1
  #endif
  #ifdef HOMING_CYCLE_2
    limits_go_home(HOMING_CYCLE_2);  // Homing cycle 2
  #endif

  protocol_execute_runtime(); // Check for reset and set system abort.
  if (sys.abort) { return; } // Did not complete. Alarm state set by mc_alarm.

  // Homing cycle complete! Setup system for normal operation.
  // -------------------------------------------------------------------------------------

  // Gcode parser position was circumvented by the limits_go_home() routine, so sync position now.
  gc_sync_position();

  // Set idle state after homing completes and before returning to main program.
  sys.state = STATE_IDLE;
  st_go_idle(); // Set idle state after homing completes

  // If hard limits feature enabled, re-enable hard limits pin change register after homing cycle.
  limits_init();
}
示例#2
0
文件: limits.c 项目: IRNAS/grbl_stm32
void limits_init() 
{
//  LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins
//
//  #ifdef DISABLE_LIMIT_PIN_PULL_UP
//    LIMIT_PORT &= ~(LIMIT_MASK); // Normal low operation. Requires external pull-down.
//  #else
//    LIMIT_PORT |= (LIMIT_MASK);  // Enable internal pull-up resistors. Normal high operation.
//  #endif
//
//  if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
//    LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
//    PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
//  } else {
//    limits_disable();
//  }
//
//  #ifdef ENABLE_SOFTWARE_DEBOUNCE
//    MCUSR &= ~(1<<WDRF);
//    WDTCSR |= (1<<WDCE) | (1<<WDE);
//    WDTCSR = (1<<WDP0); // Set time-out at ~32msec.
//  #endif

	set_as_input(LIMX);
	set_as_input(LIMY);
	set_as_input(LIMZ);

	if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
		limits_enable();
	} else {
		limits_disable();
	}

}
示例#3
0
// Perform homing cycle to locate and set machine zero. Only '$H' executes this command.
// NOTE: There should be no motions in the buffer and Grbl must be in an idle state before
// executing the homing cycle. This prevents incorrect buffered plans after homing.
void mc_homing_cycle()
{
  // Check and abort homing cycle, if hard limits are already enabled. Helps prevent problems
  // with machines with limits wired on both ends of travel to one limit pin.
  // TODO: Move the pin-specific LIMIT_PIN call to limits.c as a function.
  #ifdef LIMITS_TWO_SWITCHES_ON_AXES  
    if (limits_get_state()) { 
      mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown.
      bit_true_atomic(sys_rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT));
      return;
    }
  #endif
   
  limits_disable(); // Disable hard limits pin change register for cycle duration
    
  // -------------------------------------------------------------------------------------
  // Perform homing routine. NOTE: Special motion case. Only system reset works.
  
  // Search to engage all axes limit switches at faster homing seek rate.
  limits_go_home(HOMING_CYCLE_0);  // Homing cycle 0
  #ifdef HOMING_CYCLE_1
    limits_go_home(HOMING_CYCLE_1);  // Homing cycle 1
  #endif
  #ifdef HOMING_CYCLE_2
    limits_go_home(HOMING_CYCLE_2);  // Homing cycle 2
  #endif
  #ifdef HOMING_CYCLE_3
    limits_go_home(HOMING_CYCLE_3);  // Homing cycle 3
  #endif
  #ifdef HOMING_CYCLE_4
    limits_go_home(HOMING_CYCLE_4);  // Homing cycle 4
  #endif
  #ifdef HOMING_CYCLE_5
    limits_go_home(HOMING_CYCLE_5);  // Homing cycle 5
  #endif
    
  protocol_execute_realtime(); // Check for reset and set system abort.
  if (sys.abort) { return; } // Did not complete. Alarm state set by mc_alarm.

  // Homing cycle complete! Setup system for normal operation.
  // -------------------------------------------------------------------------------------

  // Gcode parser position was circumvented by the limits_go_home() routine, so sync position now.
  gc_sync_position();

  // If hard limits feature enabled, re-enable hard limits pin change register after homing cycle.
  limits_init();
}
示例#4
0
// Perform homing cycle to locate and set machine zero. Only '$H' executes this command.
// NOTE: There should be no motions in the buffer and Grbl must be in an idle state before
// executing the homing cycle. This prevents incorrect buffered plans after homing.
void mc_homing_cycle(uint8_t cycle_mask)
{
  // Check and abort homing cycle, if hard limits are already enabled. Helps prevent problems
  // with machines with limits wired on both ends of travel to one limit pin.
  // TODO: Move the pin-specific LIMIT_PIN call to limits.c as a function.
  #ifdef LIMITS_TWO_SWITCHES_ON_AXES
    if (limits_get_state()) {
      mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown.
      system_set_exec_alarm(EXEC_ALARM_HARD_LIMIT);
      return;
    }
  #endif

  limits_disable(); // Disable hard limits pin change register for cycle duration

  // -------------------------------------------------------------------------------------
  // Perform homing routine. NOTE: Special motion case. Only system reset works.
  
  #ifdef HOMING_SINGLE_AXIS_COMMANDS
    if (cycle_mask) { limits_go_home(cycle_mask); } // Perform homing cycle based on mask.
    else
  #endif
  {
    // Search to engage all axes limit switches at faster homing seek rate.
    limits_go_home(HOMING_CYCLE_0);  // Homing cycle 0
    #ifdef HOMING_CYCLE_1
      limits_go_home(HOMING_CYCLE_1);  // Homing cycle 1
    #endif
    #ifdef HOMING_CYCLE_2
      limits_go_home(HOMING_CYCLE_2);  // Homing cycle 2
    #endif
  }

  protocol_execute_realtime(); // Check for reset and set system abort.
  if (sys.abort) { return; } // Did not complete. Alarm state set by mc_alarm.

  // Homing cycle complete! Setup system for normal operation.
  // -------------------------------------------------------------------------------------

  // Sync gcode parser and planner positions to homed position.
  gc_sync_position();
  plan_sync_position();

  // If hard limits feature enabled, re-enable hard limits pin change register after homing cycle.
  limits_init();
}
示例#5
0
文件: limits.c 项目: MisterTobi/grbl
void limits_init() 
{
  LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins

  #ifdef DISABLE_LIMIT_PIN_PULL_UP
    LIMIT_PORT &= ~(LIMIT_MASK); // Normal low operation. Requires external pull-down.
  #else
    LIMIT_PORT |= (LIMIT_MASK);  // Enable internal pull-up resistors. Normal high operation.
  #endif

  if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
    LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
    PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
  } else {
    limits_disable(); 
  }
  
  #ifdef ENABLE_SOFTWARE_DEBOUNCE
    MCUSR &= ~(1<<WDRF);
    WDTCSR |= (1<<WDCE) | (1<<WDE);
    WDTCSR = (1<<WDP0); // Set time-out at ~32msec.
  #endif
}
示例#6
0
void limits_init() 
{
	///////////////////##########################
#if MotherBoard==3 && !defined(limit_int_style)  ///*** MB==3
#if defined(X_MIN_PIN) && X_MIN_PIN>-1   //////##############
		SET_INPUT(X_MIN_PIN);
#endif
#if defined(Y_MIN_PIN) && Y_MIN_PIN>-1   //////##############
		SET_INPUT(Y_MIN_PIN);
#endif
#if defined(Z_MIN_PIN) && Z_MIN_PIN>-1   //////##############
		SET_INPUT(Z_MIN_PIN);
#endif
#if defined(X_MAX_PIN) && X_MAX_PIN>-1   //////##############
		SET_INPUT(X_MAX_PIN);
#endif
#if defined(Y_MAX_PIN) && Y_MAX_PIN>-1   //////##############
		SET_INPUT(Y_MAX_PIN);
#endif
#if defined(Z_MAX_PIN) && Z_MAX_PIN>-1   //////##############
		SET_INPUT(Z_MAX_PIN);
#endif
	/*
#if(ENDSTOP_X_MIN_INVERTING)
	
#else
	
#endif*/
		if (bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) 
		{
			PULLUP(X_MIN_PIN,LOW);	 /////***** invert as machine SET LOW
			PULLUP(Y_MIN_PIN,LOW);
			PULLUP(Z_MIN_PIN,LOW);	
			PULLUP(X_MAX_PIN,LOW);	 /////***** invert as machine SET LOW
			PULLUP(Y_MAX_PIN,LOW);
			PULLUP(Z_MAX_PIN,LOW);
		} 
		else 
		{
			PULLUP(X_MIN_PIN,HIGH);   /////***** invert as machine SET HIGH
			PULLUP(Y_MIN_PIN,HIGH);
			PULLUP(Z_MIN_PIN,HIGH);
			PULLUP(X_MAX_PIN,HIGH);   /////***** invert as machine SET HIGH
			PULLUP(Y_MAX_PIN,HIGH);
			PULLUP(Z_MAX_PIN,HIGH);
		}	
		
		if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) { 	
		  LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt   ///****7=0x00000111
		  PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
		} else {
		  limits_disable(); 
		}
		
#else   ///*** MB!=3

  LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins

  if (bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) {
    LIMIT_PORT &= ~(LIMIT_MASK); // Normal low operation. Requires external pull-down.
  } else {
    LIMIT_PORT |= (LIMIT_MASK);  // Enable internal pull-up resistors. Normal high operation.
  }

  if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
    LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
    PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
  } else {
    limits_disable(); 
  }
  
  #ifdef ENABLE_SOFTWARE_DEBOUNCE
    MCUSR &= ~(1<<WDRF);
    WDTCSR |= (1<<WDCE) | (1<<WDE);
    WDTCSR = (1<<WDP0); // Set time-out at ~32msec.
  #endif
  
 #endif  ///*** MB==3
//////###############################
}