Fix style
This commit is contained in:
parent
0fd738f37e
commit
03e1ccf97e
@ -41,7 +41,7 @@ void oven_pid_init(struct pid_controller *controller_to_copy);
|
|||||||
|
|
||||||
void oven_pid_handle(float target_temp);
|
void oven_pid_handle(float target_temp);
|
||||||
|
|
||||||
void oven_pid_stop();
|
void oven_pid_stop(void);
|
||||||
|
|
||||||
void oven_driver_apply_power_level(void);
|
void oven_driver_apply_power_level(void);
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
|
|
||||||
static struct pid_controller IN_SECTION(.ccm.bss) oven_pid;
|
static struct pid_controller IN_SECTION(.ccm.bss) oven_pid;
|
||||||
static bool oven_pid_running = false;
|
static bool oven_pid_running;
|
||||||
static bool oven_pid_aborted = false;
|
static bool oven_pid_aborted;
|
||||||
static uint8_t IN_SECTION(.ccm.bss) oven_driver_power_level = 0U;
|
static uint8_t IN_SECTION(.ccm.bss) oven_driver_power_level;
|
||||||
|
|
||||||
void oven_driver_init()
|
void oven_driver_init(void)
|
||||||
{
|
{
|
||||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_PORT_RCC_MASK));
|
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_PORT_RCC_MASK));
|
||||||
rcc_manager_enable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_TIM_RCC_MASK));
|
rcc_manager_enable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_TIM_RCC_MASK));
|
||||||
@ -50,6 +50,12 @@ void oven_driver_init()
|
|||||||
OVEN_CONTROLLER_PWM_TIMER->PSC = 42000U - 1U;
|
OVEN_CONTROLLER_PWM_TIMER->PSC = 42000U - 1U;
|
||||||
|
|
||||||
OVEN_CONTROLLER_PWM_TIMER->CR1 = TIM_CR1_CMS | TIM_CR1_CEN;
|
OVEN_CONTROLLER_PWM_TIMER->CR1 = TIM_CR1_CMS | TIM_CR1_CEN;
|
||||||
|
|
||||||
|
/* Explicitly init global variables */
|
||||||
|
oven_pid_aborted = false;
|
||||||
|
oven_pid_running = false;
|
||||||
|
|
||||||
|
oven_driver_set_power(0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void oven_driver_set_power(uint8_t power)
|
void oven_driver_set_power(uint8_t power)
|
||||||
@ -65,7 +71,7 @@ void oven_driver_apply_power_level(void)
|
|||||||
OVEN_CONTROLLER_PWM_TIMER->CCR3 = oven_driver_power_level * 10;
|
OVEN_CONTROLLER_PWM_TIMER->CCR3 = oven_driver_power_level * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
void oven_driver_disable()
|
void oven_driver_disable(void)
|
||||||
{
|
{
|
||||||
OVEN_CONTROLLER_PWM_TIMER->CR1 = 0UL;
|
OVEN_CONTROLLER_PWM_TIMER->CR1 = 0UL;
|
||||||
OVEN_CONTROLLER_PWM_TIMER->CR2 = 0UL;
|
OVEN_CONTROLLER_PWM_TIMER->CR2 = 0UL;
|
||||||
@ -105,9 +111,10 @@ void oven_pid_handle(float target_temp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void oven_pid_stop()
|
void oven_pid_stop(void)
|
||||||
{
|
{
|
||||||
oven_pid_running = false;
|
oven_pid_running = false;
|
||||||
|
oven_driver_set_power(0U);
|
||||||
safety_controller_enable_timing_mon(ERR_TIMING_PID, false);
|
safety_controller_enable_timing_mon(ERR_TIMING_PID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#include <reflow-controller/pid-controller.h>
|
#include <reflow-controller/pid-controller.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void pid_init(struct pid_controller *pid, float k_deriv, float k_int, float k_p, float output_sat_min, float output_sat_max, float integral_max, float sample_period)
|
void pid_init(struct pid_controller *pid, float k_deriv, float k_int, float k_p, float output_sat_min,
|
||||||
|
float output_sat_max, float integral_max, float sample_period)
|
||||||
{
|
{
|
||||||
if (!pid)
|
if (!pid)
|
||||||
return;
|
return;
|
||||||
@ -61,12 +62,11 @@ static void calculate_integral(struct pid_controller *pid, float deviation)
|
|||||||
pid->integral = pid->integral + pid->k_int_t * (deviation + pid->last_in);
|
pid->integral = pid->integral + pid->k_int_t * (deviation + pid->last_in);
|
||||||
|
|
||||||
/* Saturate integral term to spoecified maximum */
|
/* Saturate integral term to spoecified maximum */
|
||||||
if (pid->integral > pid->integral_max) {
|
if (pid->integral > pid->integral_max)
|
||||||
pid->integral = pid->integral_max;
|
pid->integral = pid->integral_max;
|
||||||
} else if (pid->integral < -pid->integral_max){
|
else if (pid->integral < -pid->integral_max)
|
||||||
pid->integral = -pid->integral_max;
|
pid->integral = -pid->integral_max;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float pid_sample(struct pid_controller *pid, float deviation)
|
float pid_sample(struct pid_controller *pid, float deviation)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user