-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAOloopControl_autotune.c
151 lines (103 loc) · 3.96 KB
/
AOloopControl_autotune.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* @file AOloopControl_autotune.c
* @brief AO loop control - INTEGRATOR AUTO TUNING
*
* REAL TIME COMPUTING ROUTINES
*
*
* @bug No known bugs.
*
*/
#define _GNU_SOURCE
#include "CommandLineInterface/CLIcore.h"
#include "AOloopControl/AOloopControl.h"
#include "AOloopControl_perfTest/AOloopControl_perfTest.h"
#include "00CORE/00CORE.h"
#include "COREMOD_memory/COREMOD_memory.h"
// defined in AOloopControl.c
extern AOLOOPCONTROL_CONF *AOconf; // configuration - this can be an array
// defined in AOloopControl.c
extern AOloopControl_var aoloopcontrol_var;
/* =============================================================================================== */
/** @name AOloopControl - 8.4. LOOP CONTROL INTERFACE - INTEGRATOR AUTO TUNING */
/* =============================================================================================== */
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_on()
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_LIMITS_ON = 1;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_AUTOTUNE_LIMITS_off()
{
int block;
int NBblock;
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_LIMITS_ON = 0;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
if(aoloopcontrol_var.aoconfID_limitb == -1)
{
char imname[200];
if(sprintf(imname, "aol%ld_limitb", aoloopcontrol_var.LOOPNUMBER) < 1)
printERROR(__FILE__, __func__, __LINE__, "sprintf wrote <1 char");
aoloopcontrol_var.aoconfID_limitb = read_sharedmem_image(imname);
}
NBblock = data.image[aoloopcontrol_var.aoconfID_limitb].md[0].size[0];
// Save Limits
for(block=0; block<NBblock; block++)
{
FILE *fp;
char fname[200];
sprintf(fname, "conf/param_limitb%02d.txt", block);
if((fp=fopen(fname, "w"))==NULL)
printERROR(__FILE__, __func__, __LINE__, "Cannot open file");
else
{
fprintf(fp, "%7.5f\n", data.image[aoloopcontrol_var.aoconfID_limitb].array.F[block]);
}
fclose(fp);
}
return 0;
}
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_delta(float AUTOTUNE_LIMITS_delta)
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_LIMITS_delta = AUTOTUNE_LIMITS_delta;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_perc(float AUTOTUNE_LIMITS_perc)
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_LIMITS_perc = AUTOTUNE_LIMITS_perc;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_set_AUTOTUNE_LIMITS_mcoeff(float AUTOTUNE_LIMITS_mcoeff)
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_LIMITS_mcoeff = AUTOTUNE_LIMITS_mcoeff;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_AUTOTUNE_GAINS_on()
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_GAINS_ON = 1;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_AUTOTUNE_GAINS_off()
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOAutoTune.AUTOTUNE_GAINS_ON = 0;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}