Fraise
2.1
FRAmework for Interfacing Software and Electronics
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Typedefs
Groups
pid.h
1
/*********************************************************************
2
*
3
* pid library for Fraise pic18f device
4
*
5
* -pid regulator with maximum output setting
6
* and anti-windup tracking gain
7
*********************************************************************
8
* Author Date Comment
9
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
* Antoine Rousseau dec 2012 Original.
11
********************************************************************/
12
/*
13
# This program is free software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
17
#
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
22
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26
# MA 02110-1301, USA.
27
*/
28
#ifndef _pid_H_
29
#define _pid_H_
30
31
#include <
fruit.h
>
32
33
/*
34
35
error input : signed 16 bit (int)
36
gains : unsigned 8 bits
37
38
Int = Integration sum clipped to [-1<<26, 1<<26[, then divided by 16 (>>4)
39
Integration sum of error*GainI : signed max 31 bits
40
41
Proportionnal term error*GainP : signed max 24 bits
42
43
GainD is multiplied by 128 (1<<7)
44
Differential term derror*GainD : signed max 30 bits
45
46
47
*/
48
typedef
struct
{
49
unsigned
char
GainP, GainI, GainD;
50
long
int
Int;
// integral sum
51
long
int
Last;
// last error, used to compute differential term
52
long
int
Out;
// output of pid regulator
53
int
MaxOut;
// maximum ouput allowed for pid regulator ; multiplied by 256.
54
}
t_pid
;
55
56
void
pidInit(
t_pid
*Pid);
57
void
pidCompute(
t_pid
*Pid,
int
err);
58
void
pidInput(
t_pid
*Pid);
59
void
pidDeclareEE(
t_pid
*Pid);
60
#define pid_EESIZE 5 // 5 bytes of eeprom
61
62
#endif // _pid_H_
63
fruit.h
t_pid
Definition:
pid.h:48
pid
pid.h
Generated on Mon Jan 18 2016 00:28:53 for Fraise by
1.8.6