2020-04-20 21:16:39 +02:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PID_CONTROLLER_H__
|
|
|
|
#define __PID_CONTROLLER_H__
|
|
|
|
|
|
|
|
struct pid_controller {
|
|
|
|
float k_deriv;
|
|
|
|
float k_int;
|
|
|
|
float k_p;
|
2020-05-25 01:56:54 +02:00
|
|
|
float k_int_t;
|
|
|
|
float k_deriv_t;
|
2020-04-20 21:16:39 +02:00
|
|
|
float output_sat_max;
|
|
|
|
float output_sat_min;
|
|
|
|
float integral_max;
|
2020-05-25 01:56:54 +02:00
|
|
|
float sample_period;
|
2020-04-20 21:16:39 +02:00
|
|
|
volatile float control_output;
|
|
|
|
volatile float last_in;
|
|
|
|
volatile float integral;
|
2020-05-25 01:56:54 +02:00
|
|
|
volatile float derivate;
|
2020-04-20 21:16:39 +02:00
|
|
|
};
|
|
|
|
|
2020-05-25 01:56:54 +02:00
|
|
|
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);
|
2020-04-20 21:16:39 +02:00
|
|
|
|
|
|
|
void pid_zero(struct pid_controller *pid);
|
|
|
|
|
|
|
|
float pid_sample(struct pid_controller *pid, float deviation);
|
|
|
|
|
|
|
|
float pid_get_control_output(const struct pid_controller *pid);
|
|
|
|
|
|
|
|
#endif /* __PID_CONTROLLER_H__ */
|