33 lines
968 B
C
33 lines
968 B
C
#ifndef INC_PWM_CONTROL_H
|
|
#define INC_PWM_CONTROL_H
|
|
|
|
#include "stm32f3xx_hal.h"
|
|
#include "ADBMS_LL_Driver.h"
|
|
#include "state_machine.h"
|
|
#include <stdint.h>
|
|
#include "main.h"
|
|
|
|
/* The PWM period (1/FPWM) is defined by the following parameters:
|
|
ARR value, the Prescaler value, and the internal clock itself which drives the timer module FCLK.
|
|
F_PWM = (F_CLK)/((ARR + 1) * (PSC + 1))
|
|
|
|
F_CLK = 16 MHz
|
|
|
|
POWERGROUND ESC Signal: pulse every 20 ms, 1 ms = 0%, 2 ms = 100%
|
|
FREQ = 50 Hz -> 16 MHz/50 Hz = 320000 = ((39999 + 1) * (7 + 1))
|
|
DUTY CYCLE = 1/20 -> 0%, DUTY CYCLE = 2/20 -> 100%
|
|
CCR * DUTY_CYCLE
|
|
CCR: 1/20 -> 500, 2/20 -> 1000
|
|
*/
|
|
#define POWERGROUND_FREQ 50
|
|
|
|
//#define BATTERY_COOLING_FREQ 20000
|
|
|
|
void PWM_control_init(TIM_HandleTypeDef* powerground, TIM_HandleTypeDef* battery_cooling);
|
|
|
|
void PWM_powerground_control(uint8_t percent);
|
|
void PWM_battery_cooling_control(uint8_t percent);
|
|
void PWM_set_throttle();
|
|
|
|
#endif /* INC_CHANNEL_CONTROL_H */
|