PWM_control is complete
This commit is contained in:
parent
f6ba786e1b
commit
5404cc9298
@ -18,8 +18,8 @@ CCR * DUTY_CYCLE
|
|||||||
CCR: 1/20 -> 500, 2/20 -> 1000
|
CCR: 1/20 -> 500, 2/20 -> 1000
|
||||||
*/
|
*/
|
||||||
#define POWERGROUND_FREQ 50
|
#define POWERGROUND_FREQ 50
|
||||||
#define POWERGROUND_MAX_DUTY_CYCLE 0.05
|
#define POWERGROUND_MAX_DUTY_CYCLE 0.1
|
||||||
#define POWERGROUND_MIN_DUTY_CYCLE 0.1
|
#define POWERGROUND_MIN_DUTY_CYCLE 0.05
|
||||||
|
|
||||||
//#define BATTERY_COOLING_FREQ 20000
|
//#define BATTERY_COOLING_FREQ 20000
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
uint8_t powerground_status;
|
uint8_t powerground_status;
|
||||||
uint8_t battery_cooling_status;
|
uint8_t battery_cooling_status;
|
||||||
uint8_t powerground_percent;
|
|
||||||
uint8_t battery_cooling_percent;
|
|
||||||
//uint32_t powerground1_CCR, powerground2_CCR, battery_cooling_CCR;
|
//uint32_t powerground1_CCR, powerground2_CCR, battery_cooling_CCR;
|
||||||
|
|
||||||
TIM_HandleTypeDef powerground1, powerground2, battery_cooling;
|
TIM_HandleTypeDef powerground1, powerground2, battery_cooling;
|
||||||
@ -21,9 +19,6 @@ void PWM_control_init(TIM_HandleTypeDef powerground1, TIM_HandleTypeDef powergro
|
|||||||
HAL_TIM_PWM_Start(&powerground1, 1); //TIM15CH1
|
HAL_TIM_PWM_Start(&powerground1, 1); //TIM15CH1
|
||||||
HAL_TIM_PWM_Start(&powerground2, 2); //TIM15CH2
|
HAL_TIM_PWM_Start(&powerground2, 2); //TIM15CH2
|
||||||
HAL_TIM_PWM_Start(&battery_cooling, 3); //TIM1CH3
|
HAL_TIM_PWM_Start(&battery_cooling, 3); //TIM1CH3
|
||||||
|
|
||||||
powerground_percent = 0;
|
|
||||||
battery_cooling_percent = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -33,11 +28,10 @@ void PWM_powerground_control(uint8_t percent){
|
|||||||
if (percent > 100 || percent < 0)
|
if (percent > 100 || percent < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
powerground_percent = percent/100;
|
powerground_status = percent/100;
|
||||||
TIM15->CCR1 = (POWERGROUND_MAX_DUTY_CYCLE-POWERGROUND_MIN_DUTY_CYCLE) * (percent/100) + POWERGROUND_MIN_DUTY_CYCLE;
|
TIM15->CCR1 = (TIM15->ARR*POWERGROUND_MAX_DUTY_CYCLE-TIM15->ARR*POWERGROUND_MIN_DUTY_CYCLE)
|
||||||
|
* (percent/100) + TIM15->ARR*POWERGROUND_MIN_DUTY_CYCLE;
|
||||||
TIM15->CCR2 = TIM15->CCR1; /* *1.01 or *0.99 if the speeds of the fans are different*/
|
TIM15->CCR2 = TIM15->CCR1; /* *1.01 or *0.99 if the speeds of the fans are different*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void PWM_battery_cooling_control(uint8_t percent){
|
void PWM_battery_cooling_control(uint8_t percent){}
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user