Example #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) );
}
Example #2
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) );
}
Example #3
0
File: spindle.c Project: ADTL/TinyG
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) );
}
Example #4
0
static void _exec_spindle_speed(float *value, float *flag)
{
	cm_set_spindle_speed_parameter(MODEL, value[0]);
	pwm_set_duty(PWM_1, cm_get_spindle_pwm(cm.gm.spindle_mode) ); // update spindle speed if we're running
}
Example #5
0
File: spindle.c Project: ADTL/TinyG
static void _exec_spindle_speed(uint8_t i, float speed)
{
	cm_set_spindle_speed_parameter(speed);
	pwm_set_duty(PWM_1, cm_get_spindle_pwm(gm.spindle_mode) ); // update spindle speed if we're running
}