grblHAL core
20241107
pid.h
Go to the documentation of this file.
1
/*
2
pid.h - An embedded CNC Controller with rs274/ngc (g-code) support
3
4
PID algorithm for closed loop control
5
6
NOTE: not referenced in the core grbl code
7
8
Part of grblHAL
9
10
Copyright (c) 2020-2023 Terje Io
11
12
Grbl is free software: you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation, either version 3 of the License, or
15
(at your option) any later version.
16
17
Grbl is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
GNU General Public License for more details.
21
22
You should have received a copy of the GNU General Public License
23
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
24
*/
25
26
#ifndef _PID_H_
27
#define _PID_H_
28
29
#include <stdbool.h>
30
31
typedef
struct
{
32
float
p_gain
;
33
float
i_gain
;
34
float
d_gain
;
35
float
p_max_error
;
36
float
i_max_error
;
37
float
d_max_error
;
38
float
deadband
;
39
float
max_error
;
40
}
pid_values_t
;
41
42
typedef
struct
{
43
pid_values_t
cfg
;
44
float
deadband
;
45
float
i_error
;
46
float
d_error
;
47
float
sample_rate_prev
;
48
float
error
;
49
float
max_error
;
50
}
pidf_t
;
51
52
void
pidf_reset
(
pidf_t
*pid);
53
void
pidf_init
(
pidf_t
*pid,
pid_values_t
*config);
54
bool
pidf_config_changed
(
pidf_t
*pid,
pid_values_t
*config);
55
float
pidf
(
pidf_t
*pid,
float
command,
float
actual,
float
sample_rate);
56
57
#endif
pidf_init
void pidf_init(pidf_t *pid, pid_values_t *config)
Definition:
pid.c:34
pidf
float pidf(pidf_t *pid, float command, float actual, float sample_rate)
Definition:
pid.c:53
pidf_config_changed
bool pidf_config_changed(pidf_t *pid, pid_values_t *config)
Definition:
pid.c:40
pidf_reset
void pidf_reset(pidf_t *pid)
Definition:
pid.c:45
pid_values_t
Definition:
pid.h:31
pid_values_t::p_max_error
float p_max_error
Definition:
pid.h:35
pid_values_t::d_gain
float d_gain
Definition:
pid.h:34
pid_values_t::d_max_error
float d_max_error
Definition:
pid.h:37
pid_values_t::deadband
float deadband
Definition:
pid.h:38
pid_values_t::max_error
float max_error
Definition:
pid.h:39
pid_values_t::i_gain
float i_gain
Definition:
pid.h:33
pid_values_t::p_gain
float p_gain
Definition:
pid.h:32
pid_values_t::i_max_error
float i_max_error
Definition:
pid.h:36
pidf_t
Definition:
pid.h:42
pidf_t::cfg
pid_values_t cfg
Definition:
pid.h:43
pidf_t::i_error
float i_error
Definition:
pid.h:45
pidf_t::sample_rate_prev
float sample_rate_prev
Definition:
pid.h:47
pidf_t::error
float error
Definition:
pid.h:48
pidf_t::d_error
float d_error
Definition:
pid.h:46
pidf_t::deadband
float deadband
Definition:
pid.h:44
pidf_t::max_error
float max_error
Definition:
pid.h:49
STM
grblHAL Driver STM32F756
grbl
pid.h
Generated by
1.9.1