This commit is contained in:
hamza
2024-07-05 12:46:52 +03:00
parent 676b5bb8d1
commit f50643cc84
6 changed files with 146 additions and 39 deletions

View File

@ -41,14 +41,16 @@ void PWM_control_init(TIM_HandleTypeDef* pg, TIM_HandleTypeDef* bat_cool, TIM_Ha
DUTYCYCLE = 40000 * X/100
*/
void PWM_powerground_control(uint8_t percent){
if (percent > 100) //something went wrong
if (percent > 100){ //something went wrong
__HAL_TIM_SET_COMPARE(powerground, TIM_CHANNEL_3, 0);
__HAL_TIM_SET_COMPARE(powerground, TIM_CHANNEL_4, 0);
return;
}
powerground_status = percent;
int ccr = 2000 + ((2000) * (percent/100.0));
int ccr = 2000 + (20 * percent);
__HAL_TIM_SET_COMPARE(powerground, TIM_CHANNEL_3, ccr);
__HAL_TIM_SET_COMPARE(powerground, TIM_CHANNEL_4, ccr);
//TIM15->CCR1 = (TIM15->ARR*POWERGROUND_MAX_DUTY_CYCLE-TIM15->ARR*POWERGROUND_MIN_DUTY_CYCLE) * (percent/100.0) + TIM15->ARR*POWERGROUND_MIN_DUTY_CYCLE;
}
void PWM_set_throttle(){