Пример #1
0
//static void _exec_spindle_control(uint8_t spindle_mode, float f, float *vector, float *flag)
static void _exec_spindle_control(float *value, float *flag)
{
	uint8_t spindle_mode = (uint8_t)value[0];
	cm_set_spindle_mode(MODEL, spindle_mode);

 #ifdef __AVR
	if (spindle_mode == SPINDLE_CW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			gpio_set_bit_off(SPINDLE_BIT);
			gpio_set_bit_on(SPINDLE_DIR);
		} else {
			gpio_set_bit_on(SPINDLE_BIT);
			gpio_set_bit_off(SPINDLE_DIR);
		}
	} else if (spindle_mode == SPINDLE_CCW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			gpio_set_bit_off(SPINDLE_BIT);
			gpio_set_bit_off(SPINDLE_DIR);
		} else {
			gpio_set_bit_on(SPINDLE_BIT);
			gpio_set_bit_on(SPINDLE_DIR);
		}
	} else {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			gpio_set_bit_on(SPINDLE_BIT);	// failsafe: any error causes stop
		} else {
			gpio_set_bit_off(SPINDLE_BIT);	// failsafe: any error causes stop
		}
	}
#endif // __AVR
#ifdef __ARM
	if (spindle_mode == SPINDLE_CW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			spindle_enable_pin.clear();
			spindle_dir_pin.set();
		} else {
			spindle_enable_pin.set();
			spindle_dir_pin.clear();
		}
	} else if (spindle_mode == SPINDLE_CCW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			spindle_enable_pin.clear();
			spindle_dir_pin.clear();
		} else {
			spindle_enable_pin.set();
			spindle_dir_pin.set();
		}
	} else {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			spindle_enable_pin.set();	// failsafe: any error causes stop
		} else {
			spindle_enable_pin.clear();	// failsafe: any error causes stop
		}
	}
#endif // __ARM

	// PWM spindle control
	pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) );
}
Пример #2
0
static void _exec_spindle_control(uint8_t spindle_mode, float f)
{
	cm_set_spindle_mode(spindle_mode);
 	if (spindle_mode == SPINDLE_CW) {
		gpio_set_bit_on(SPINDLE_BIT);
		gpio_set_bit_off(SPINDLE_DIR);
	} else if (spindle_mode == SPINDLE_CCW) {
		gpio_set_bit_on(SPINDLE_BIT);
		gpio_set_bit_on(SPINDLE_DIR);
	} else {
		gpio_set_bit_off(SPINDLE_BIT);	// failsafe: any error causes stop
	}
    
    // PWM spindle control
    pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) );
}
Пример #3
0
void cm_exec_mist_coolant_control(uint8_t mist_coolant)
{
	gm.mist_coolant = mist_coolant;
	if (mist_coolant == true) {
		gpio_set_bit_on(MIST_COOLANT_BIT);
	} else {
		gpio_set_bit_off(MIST_COOLANT_BIT);
	}
}
Пример #4
0
void cm_exec_flood_coolant_control(uint8_t flood_coolant)
{
	gm.flood_coolant = flood_coolant;
	if (flood_coolant == true) {
		gpio_set_bit_on(FLOOD_COOLANT_BIT);
	} else {
		gpio_set_bit_off(FLOOD_COOLANT_BIT);
		cm_mist_coolant_control(false);		// M9 special function
	}
}
Пример #5
0
static void _exec_pneumatic_z_control(float *value, float *flag)
{
	cm.gm.pneumatic_z = (uint8_t)value[0];
	if (cm.gm.pneumatic_z == true) {
		gpio_set_bit_on(SPINDLE_DIR);	// if
	} else {
		gpio_set_bit_off(SPINDLE_DIR);		// else
	}

}
Пример #6
0
//static void _exec_spindle_control(uint8_t spindle_mode, float f, float *vector, float *flag)
static void _exec_spindle_control(float *value, float *flag)
{
	uint8_t spindle_mode = (uint8_t)value[0];
	cm_set_spindle_mode(MODEL, spindle_mode);

	//if (spindle_mode == SPINDLE_CW) { gpio_set_bit_on(SPINDLE_BIT); gpio_set_bit_off(SPINDLE_DIR); 	} 
	if (spindle_mode == SPINDLE_CCW) { //M8
		gpio_set_bit_on(SPINDLE_BIT);
		//gpio_set_bit_on(SPINDLE_DIR);
	} else {
		gpio_set_bit_off(SPINDLE_BIT);	// failsafe: any error causes stop
	}
	// PWM spindle control
	pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) );
}
Пример #7
0
/*
 * cm_spindle_init()
 */
void cm_spindle_init()
{
	if( pwm.c[PWM_1].frequency < 0 )
		pwm.c[PWM_1].frequency = 0;

    pwm_set_freq(PWM_1, pwm.c[PWM_1].frequency);
    pwm_set_duty(PWM_1, pwm.c[PWM_1].phase_off);
    
	// make sure spindle is turned off at init
	if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
		gpio_set_bit_on(SPINDLE_BIT);	
	} else {
		gpio_set_bit_off(SPINDLE_BIT);	
	}

}