void myPwm() { // choose channel for pwm PWM_Channel(E_CHANNEL0); // pwm out enable Init_PWM(); }
void Extruder_Start_Heating(uint16_t _target) { DBG_MSG("Target=%d", _target); PID_Init(&pid, EXTRUDER_PID_KP, EXTRUDER_PID_KI, EXTRUDER_PID_KD, EXTRUDER_PID_INIT_SUM); PWM_Channel(Ex1Heat_Ch, 90, false); currentOutput = 0; bHeating = true; targetTemp = _target; }
void Extruder_SetOutput(int output) { if(output > 100) output = 100; else if(output < 0) output = 0; PWM_Channel(Ex1Heat_Ch, output, true); currentOutput = output; }
/* * 初始化PWM模块,设定脉冲频率(Hz) */ void PWM_Init(int freq) { uint16_t period, prescaler; Timer_16bit_Calc(freq, &period, &prescaler); TIMx_Config(TIM2, period, prescaler); currentPeriod = period; for(int i=1; i<=4; i++) PWM_Channel(i, 50, false); TIMx_Enable(TIM2); // TIM2_SetInterrupt(); }
void Extruder_Stop_Heating() { PWM_Channel(Ex1Heat_Ch, 10, false); currentOutput = 0; bHeating = false; }
void myPwm() { PWM_Channel(E_CHANNEL0); // Select PWM channel. Init_PWM(); // Enable PWM function and set PWM period. }