AdaptiveOpticsControl
AOloopControl_DM.h
Go to the documentation of this file.
1 #ifndef _AOLOOPCONTROL_DM_H
2 #define _AOLOOPCONTROL_DM_H
3 
4 
5 
6 #define DISPCOMB_FILENAME_CONF "/tmp/dmdispcombconf.conf.shm"
7 #define DMTURBCONF_FILENAME "/tmp/dmturb.conf.shm"
8 
9 #define DM_NUMBER_CHANMAX 20 // max number of channel per DM
10 
11 
12 
13 
14 /* =============================================================================================== */
15 /*
16  * DM description and status
17  * contains DM physical characteristics, settings
18  * defines how DM is controlled (input and output)
19  * sets up DM channels, allowing DM control to be split in parallel channels
20  */
21  /* =============================================================================================== */
22 
23 typedef struct
24 {
25  int ON;
26 
27  long xsize; // DM xsize
28  long ysize; // DM ysize
29  long xysize; // total number of actuators
30  long NBchannel; // number of control channels
31 
32  long loopcnt;
33  long updatecnt; // DM update counter
34  int busy; // if set to 1, hold off and wait
35 
36  int voltmode; // 1 if DM drives voltmap
37  long IDvolt;
38  char voltname[200];
39  int voltON; // 1 if applying voltage
40  float MAXVOLT; // maximum voltage on DM
41  int AveMode;
42  float DClevel;
43 
44  int TrigMode; // 0 (std) : any channel update triggers disp update, 1: use specific channel and semaphore
45  int TrigChan; // if TrigMode = 1, use this channel for trigger
46  int TrigSem; // if TrigMode = 1, use this semaphore for trigger
47 
48 
49  long nsecwait; // inner wait loop duration, interrupted if sem[1] of disp posted
50  struct timespec tstart;
51  struct timespec tend;
52  double tdelay;
53  double time_disp2V;
54 
55 
56 
57  long dmdispID[DM_NUMBER_CHANMAX];
58  float dmdispgain[DM_NUMBER_CHANMAX];
59  long dmdispcnt[DM_NUMBER_CHANMAX];
60  long IDdisp;
61 
62  int dm2dm_mode; // 1 if output disp should be remapped to output DM disp
63  // following only applies of dm2dm_mode = 1
64  long xsizeout;
65  long ysizeout;
67  char dm2dm_DMmodes_name[200];
69  char dm2dm_outdisp_name[200];
70 
71  int wfsrefmode; // 1 if wfsref offset should be computed
75  char wfsref_RespMat_name[200];
77  char wfsref_out_name[200];
78 
79  int status;
80  long moninterval; // [us]
81 
83 
84 
85 
86 
87 
88 typedef struct
89 {
90  int on;
91  long cnt;
92 
93  double wspeed; // wind speed [m/s]
94  double ampl; // [um RMS]
95  double LOcoeff; // 0 for full correction of low orders, 1 for no correction
96 
97  long tint; // interval between consecutive DM updates [us]
98 
99 
100  double simtime;
101 
102  struct timespec tstart;
103  struct timespec tend;
104 
106 
107 
108 
109 
110 
111 
113 
114 
115 
116 /* =============================================================================================== */
117 /* =============================================================================================== */
118 /* */
119 /* TOOLBOX */
120 /* */
121 /* =============================================================================================== */
122 /* =============================================================================================== */
123 
124 static struct timespec time_diff(struct timespec start, struct timespec end);
125 
126 static int make_master_turbulence_screen_local(const char *ID_name1, const char *ID_name2, long size, float outerscale, float innerscale);
127 
128 
129 
130 
131 /* =============================================================================================== */
132 /* =============================================================================================== */
133 /* */
134 /* 1. INITIALIZATION, LOAD/CREATE */
135 /* */
136 /* =============================================================================================== */
137 /* =============================================================================================== */
138 
139 static int AOloopControl_DM_createconf();
140 
141 static int AOloopControl_DM_loadconf();
142 
143 static int AOloopControl_DM_unloadconf();
144 
145 
146 
147 
148 
149 /* =============================================================================================== */
150 /* =============================================================================================== */
151 /* */
152 /* 2. RUNTIME COMPUTATION */
153 /* */
154 /* =============================================================================================== */
155 /* =============================================================================================== */
156 
157 int AOloopControl_DM_disp2V(long DMindex);
158 
159 int AOloopControl_DM_CombineChannels(long DMindex, long xsize, long ysize, int NBchannel, int AveMode, int dm2dm_mode, const char *dm2dm_DMmodes, const char *dm2dm_outdisp, int wfsrefmode, const char *wfsref_WFSRespMat, const char *wfsref_out, int voltmode, const char *IDvolt_name, float DClevel, float maxvolt);
160 
161 
162 int AOloopControl_DM_dmdispcomboff(long DMindex);
163 
164 int AOloopControl_DM_dmtrigoff(long DMindex);
165 
166 
167 
168 
169 
170 /* =============================================================================================== */
171 /* =============================================================================================== */
172 /* */
173 /* 3. CONFIGURATION */
174 /* */
175 /* =============================================================================================== */
176 /* =============================================================================================== */
177 
179 
180 int AOloopControl_DM_dmdispcombstatus(long DMindex);
181 
182 int AOloopControl_DM_chan_setgain(long DMindex, int ch, float gain);
183 
184 int AOloopControl_DM_setvoltON(long DMindex);
185 
186 int AOloopControl_DM_setvoltOFF(long DMindex);
187 
188 int AOloopControl_DM_setMAXVOLT(long DMindex, float maxvolt);
189 
190 int AOloopControl_DM_setDClevel(long DMindex, float DClevel);
191 
192 int AOloopControl_DM_setTrigMode(long DMindex, int mode);
193 
194 int AOloopControl_DM_setTrigChan(long DMindex, int chan);
195 
196 int AOloopControl_DM_setTrigSem(long DMindex, int sem);
197 
198 
199 
200 /* =============================================================================================== */
201 /* =============================================================================================== */
202 /* */
203 /* 4. TURBULENCE SIMULATOR */
204 /* */
205 /* =============================================================================================== */
206 /* =============================================================================================== */
207 
208 int_fast8_t AOloopControl_printDMturbconf();
209 
211 
213 
214 int AOloopControl_DM_dmturboff(long DMindex);
215 
216 int AOloopControl_DM_dmturb_wspeed(long DMindex, double wspeed);
217 
218 int AOloopControl_DM_dmturb_ampl(long DMindex, double ampl);
219 
220 int AOloopControl_DM_dmturb_LOcoeff(long DMindex, double LOcoeff);
221 
222 int AOloopControl_DM_dmturb_tint(long DMindex, long tint);
223 
224 int AOloopControl_DM_dmturb_printstatus(long DMindex);
225 
226 int AOloopControl_DM_dmturb(long DMindex, int mode, const char *IDout_name, long NBsamples);
227 
228 
229 
230 /* =============================================================================================== */
231 /* =============================================================================================== */
232 /* */
233 /* 5. MISC TESTS & UTILS */
234 /* */
235 /* =============================================================================================== */
236 /* =============================================================================================== */
237 
238 long AOloopControl_mkDM_TT_circle(char *IDoutname, long DMindex, long NBpts, float ampl);
239 
240 long AOloopControl_DM_mkAstroGrid_seq(char *IDoutname, long DMindex, int XYmode, int bin, long NBcycle);
241 
242 
243 #endif
244 
int on
Definition: AOloopControl_DM.h:90
long cnt
Definition: AOloopControl_DM.h:91
static int AOloopControl_DM_unloadconf()
long NBchannel
Definition: AOloopControl_DM.h:30
int AOloopControl_DM_dmturb_wspeed(long DMindex, double wspeed)
Definition: AOloopControl_DM.c:1904
double LOcoeff
Definition: AOloopControl_DM.h:95
static int AOloopControl_DM_loadconf()
int_fast8_t AOloopControl_printDMturbconf()
Definition: AOloopControl_DM.c:1736
int AOloopControl_DM_dmturb(long DMindex, int mode, const char *IDout_name, long NBsamples)
Definition: AOloopControl_DM.c:1994
int AOloopControl_DM_dmdispcombstatus(long DMindex)
Definition: AOloopControl_DM.c:1515
long xsizeout
Definition: AOloopControl_DM.h:64
int wfsrefmode
Definition: AOloopControl_DM.h:71
int dm2dm_mode
Definition: AOloopControl_DM.h:62
int AOloopControl_DM_dmdispcomboff(long DMindex)
Definition: AOloopControl_DM.c:1451
int AOloopControl_printDMconf()
Definition: AOloopControl_DM.c:1482
long xysize
Definition: AOloopControl_DM.h:29
int ON
Definition: AOloopControl_DM.h:25
int AOloopControl_DMturb_createconf()
Definition: AOloopControl_DM.c:1761
long AOloopControl_DM_mkAstroGrid_seq(char *IDoutname, long DMindex, int XYmode, int bin, long NBcycle)
Definition: AOloopControl_DM.c:2409
int AOloopControl_DM_dmturb_LOcoeff(long DMindex, double LOcoeff)
Definition: AOloopControl_DM.c:1928
int AOloopControl_DM_setTrigChan(long DMindex, int chan)
Definition: AOloopControl_DM.c:1697
double wspeed
Definition: AOloopControl_DM.h:93
long xsize
Definition: AOloopControl_DM.h:27
long loopcnt
Definition: AOloopControl_DM.h:32
int TrigMode
Definition: AOloopControl_DM.h:44
long IDvolt
Definition: AOloopControl_DM.h:37
int AOloopControl_DM_dmturboff(long DMindex)
Definition: AOloopControl_DM.c:1892
int AOloopControl_DM_dmturb_ampl(long DMindex, double ampl)
Definition: AOloopControl_DM.c:1916
long ID_wfsref_out
Definition: AOloopControl_DM.h:76
int AOloopControl_DM_setvoltON(long DMindex)
Definition: AOloopControl_DM.c:1648
Definition: AOloopControl_DM.h:88
long xsizewfsref
Definition: AOloopControl_DM.h:72
static struct timespec time_diff(struct timespec start, struct timespec end)
long nsecwait
Definition: AOloopControl_DM.h:49
static int AOloopControl_DM_createconf()
long ysize
Definition: AOloopControl_DM.h:28
int AOloopControl_DMturb_loadconf()
double ampl
Definition: AOloopControl_DM.h:94
static int make_master_turbulence_screen_local(const char *ID_name1, const char *ID_name2, long size, float outerscale, float innerscale)
int AveMode
Definition: AOloopControl_DM.h:41
int TrigSem
Definition: AOloopControl_DM.h:46
int busy
Definition: AOloopControl_DM.h:34
long moninterval
Definition: AOloopControl_DM.h:80
int init_AOloopControl_DM()
Definition: AOloopControl_DM.c:309
long ID_wfsref_RespMat
Definition: AOloopControl_DM.h:74
float MAXVOLT
Definition: AOloopControl_DM.h:40
int AOloopControl_DM_setMAXVOLT(long DMindex, float maxvolt)
Definition: AOloopControl_DM.c:1668
int AOloopControl_DM_chan_setgain(long DMindex, int ch, float gain)
Definition: AOloopControl_DM.c:1634
long ID_dm2dm_outdisp
Definition: AOloopControl_DM.h:68
long ID_dm2dm_DMmodes
Definition: AOloopControl_DM.h:66
int AOloopControl_DM_dmtrigoff(long DMindex)
Definition: AOloopControl_DM.c:1461
long tint
Definition: AOloopControl_DM.h:97
int AOloopControl_DM_setTrigSem(long DMindex, int sem)
Definition: AOloopControl_DM.c:1706
long AOloopControl_mkDM_TT_circle(char *IDoutname, long DMindex, long NBpts, float ampl)
Definition: AOloopControl_DM.c:2358
double time_disp2V
Definition: AOloopControl_DM.h:53
int voltmode
Definition: AOloopControl_DM.h:36
long ysizeout
Definition: AOloopControl_DM.h:65
long ysizewfsref
Definition: AOloopControl_DM.h:73
Definition: AOloopControl_DM.h:23
double simtime
Definition: AOloopControl_DM.h:100
int AOloopControl_DM_dmturb_printstatus(long DMindex)
Definition: AOloopControl_DM.c:1954
long updatecnt
Definition: AOloopControl_DM.h:33
int status
Definition: AOloopControl_DM.h:79
long IDdisp
Definition: AOloopControl_DM.h:60
float DClevel
Definition: AOloopControl_DM.h:42
int AOloopControl_DM_disp2V(long DMindex)
Definition: AOloopControl_DM.c:906
int voltON
Definition: AOloopControl_DM.h:39
int AOloopControl_DM_setvoltOFF(long DMindex)
Definition: AOloopControl_DM.c:1658
int AOloopControl_DM_setDClevel(long DMindex, float DClevel)
Definition: AOloopControl_DM.c:1678
double tdelay
Definition: AOloopControl_DM.h:52
int TrigChan
Definition: AOloopControl_DM.h:45
int AOloopControl_DM_dmturb_tint(long DMindex, long tint)
Definition: AOloopControl_DM.c:1940
int AOloopControl_DM_CombineChannels(long DMindex, long xsize, long ysize, int NBchannel, int AveMode, int dm2dm_mode, const char *dm2dm_DMmodes, const char *dm2dm_outdisp, int wfsrefmode, const char *wfsref_WFSRespMat, const char *wfsref_out, int voltmode, const char *IDvolt_name, float DClevel, float maxvolt)
Definition: AOloopControl_DM.c:978
int AOloopControl_DM_setTrigMode(long DMindex, int mode)
Definition: AOloopControl_DM.c:1688