void Motors::turnOff() { // Turn off motors ioport_set_pin_level(MOTORS_ENABLE_PIN, IOPORT_PIN_LEVEL_HIGH); pwm_set_duty_cycle_percent(&motorXVrefPwm, 0); pwm_set_duty_cycle_percent(&motorYVrefPwm, 0); pwm_set_duty_cycle_percent(&motorZVrefPwm, 0); pwm_set_duty_cycle_percent(&motorEVrefPwm, 0); }
/** * \brief PWM channel 1 interrupt callback function */ static void pwm_callback_1 (void) { /* Increase (and wrap at 100) the duty cycle */ if (duty_cycle_percent_1++ >= 100) { duty_cycle_percent_1 = 0; } /* Set new duty cycle value */ pwm_set_duty_cycle_percent(&pwm_1_cfg, duty_cycle_percent_1); }
/** * \brief Start a PWM channel * * This function enables a channel with a given duty cycle. * * \param *config Pointer to the PWM configuration struct * \param duty_cycle_scale Duty cycle as a value between 0 and 100. */ void pwm_start(struct pwm_config *config, uint8_t duty_cycle_scale) { /* Set given duty cycle */ pwm_set_duty_cycle_percent(config, duty_cycle_scale); /* Set correct TC period */ tc_write_period(config->tc, config->period); /* Enable CC channel for this TC */ tc_enable_cc_channels(config->tc, config->cc_mask); /* Enable TC by setting correct clock prescaler */ tc_write_clock_source(config->tc, config->clk_sel); }
void Motors::move(const Gcode &command) { // Motor X test turnOn(); pwm_set_duty_cycle_percent(&motorXVrefPwm, MOTOR_X_VREF_VOLTAGE * 100 / 3.3); }