Commit 63a793dff475f8cc63c9cd7bb6e271ada197e97b
1 parent
ecf46cbe
Exists in
master
TP CCD
Showing
3 changed files
with
574 additions
and
3 deletions
Show diff stats
... | ... | @@ -0,0 +1,550 @@ |
1 | +/* | |
2 | + * Fichier pour travaux pratiques | |
3 | + * Universite de Toulouse | |
4 | + * | |
5 | + * --- rappel des bits de donnes du port parallele pour Audine | |
6 | + * ordre : 87654321 | |
7 | + * bit 1 : horloge V1 | |
8 | + * bit 2 : horloge V2 | |
9 | + * bit 3 : horloge H1 | |
10 | + * bit 4 : horloge R (reset) | |
11 | + * bit 5 : horloge CL (clamp) | |
12 | + * bit 6 : horloge Start Convert (CAN) | |
13 | + * bit 7 : horloge Select Byte (CAN) | |
14 | + * bit 8 : horloge Select Nibble | |
15 | + * | |
16 | + */ | |
17 | + | |
18 | + // https://raspberry-projects.com/pi/programming-in-c/io-pins/bcm2835-by-mike-mccauley | |
19 | +// http://www.airspayce.com/mikem/bcm2835/ | |
20 | +// sudo chown user:user /dev/gpiomem | |
21 | +// Dans CodeBlocks, Menu Settings -> Compiler Settings, tab Other compiler options: Add -lbcm2835 | |
22 | +// spyder : https://stackoverflow.com/questions/72114520/error-when-starting-spyder-on-ubuntu-22-04 | |
23 | + | |
24 | +#include <stdlib.h> | |
25 | +#include <stdio.h> | |
26 | +#include <string.h> | |
27 | +#include <math.h> | |
28 | +#include <bcm2835.h> | |
29 | + | |
30 | +#define PHI_V1 RPI_BPLUS_GPIO_J8_11 | |
31 | +#define PHI_V2 RPI_BPLUS_GPIO_J8_13 | |
32 | +#define PHI_H1 RPI_BPLUS_GPIO_J8_15 | |
33 | +#define PHI_R RPI_BPLUS_GPIO_J8_16 | |
34 | +#define PHI_CL RPI_BPLUS_GPIO_J8_18 | |
35 | +#define PHI_SC RPI_BPLUS_GPIO_J8_22 | |
36 | +#define PHI_SB RPI_BPLUS_GPIO_J8_32 | |
37 | +#define PHI_SN RPI_BPLUS_GPIO_J8_36 | |
38 | + | |
39 | +#define BIT_0 RPI_BPLUS_GPIO_J8_29 | |
40 | +#define BIT_1 RPI_BPLUS_GPIO_J8_31 | |
41 | +#define BIT_2 RPI_BPLUS_GPIO_J8_33 | |
42 | +#define BIT_3 RPI_BPLUS_GPIO_J8_35 | |
43 | + | |
44 | +#define DELAY RPI_BPLUS_GPIO_J8_40 | |
45 | + | |
46 | +#define LEVEL_HIGH 0 | |
47 | +#define LEVEL_LOW 1 | |
48 | + | |
49 | +struct camprop { | |
50 | + /* --- parametres standards, ne pas changer --- */ | |
51 | + char msg[2048]; | |
52 | + float exptime; | |
53 | + int binx, biny; | |
54 | + int x1, y1, x2, y2; | |
55 | + int w, h; | |
56 | + double celldimx; | |
57 | + double celldimy; | |
58 | + int overscanindex; | |
59 | + int nb_deadbeginphotox; | |
60 | + int nb_deadendphotox; | |
61 | + int nb_deadbeginphotoy; | |
62 | + int nb_deadendphotoy; | |
63 | + int nb_photox; | |
64 | + int nb_photoy; | |
65 | + unsigned short *p; | |
66 | + /* --- pour l'amplificateur des Kaf-401 --- */ | |
67 | + int ampliindex; | |
68 | + int nbampliclean; | |
69 | + timespec t1; | |
70 | + timespec t2; | |
71 | +}; | |
72 | + | |
73 | +int cmdAudineAcqNormal(struct camprop *cam); | |
74 | + | |
75 | +static int tp_fast_vidage(struct camprop *cam); | |
76 | +static int tp_read_win(struct camprop *cam); | |
77 | +static void libcam_sleep(float us); | |
78 | + | |
79 | +static int tp_zi_zh(struct camprop *cam); | |
80 | +static int tp_read_pel_fast2(struct camprop *cam); | |
81 | + | |
82 | +int tp_fast_line(struct camprop *cam); | |
83 | + | |
84 | + | |
85 | +/* | |
86 | + * Attente en micro-secondes. | |
87 | + */ | |
88 | +void libcam_sleep(float us) | |
89 | +{ | |
90 | + int i,n; | |
91 | + n = (int)(us*10); | |
92 | + for (i=0; i<n ; i++) { | |
93 | + bcm2835_gpio_write (DELAY, 1) ; | |
94 | + } | |
95 | +} | |
96 | + | |
97 | +int cmdAudineAcqNormal(struct camprop *cam) | |
98 | +{ | |
99 | + int i; | |
100 | + int nb_vidages = 1; | |
101 | + /* =============================================== */ | |
102 | + /* === Etape de rincage de la matrice CCD === */ | |
103 | + /* =============================================== */ | |
104 | + /* vidage de la matrice */ | |
105 | + for (i = 0; i < nb_vidages; i++) { | |
106 | + tp_fast_vidage(cam); | |
107 | + } | |
108 | + /* =============================================== */ | |
109 | + /* === Integration de l'image (attente) === */ | |
110 | + /* =============================================== */ | |
111 | + /* Delais du temps de pose (en micro-secondes) */ | |
112 | + libcam_sleep((int) (1e6 * cam->exptime)); | |
113 | + /* =============================================== */ | |
114 | + /* === Etape de lecture de la matrice CCD === */ | |
115 | + /* =============================================== */ | |
116 | + /* Parametres de dimensions pour allouer le pointeur image */ | |
117 | + cam->w = cam->nb_photox / cam->binx; | |
118 | + cam->h = cam->nb_photoy / cam->biny; | |
119 | + /* Allocation memoire du pointeur image */ | |
120 | + cam->p = (unsigned short *) calloc(cam->w*cam->h, sizeof(unsigned short)); | |
121 | + /* Lecture et num�risation de l'image vers le pointeur p */ | |
122 | + tp_read_win(cam); | |
123 | + return 0; | |
124 | +} | |
125 | + | |
126 | +/* | |
127 | +fast_vidage(struct camprop *cam) -- | |
128 | + Vidage rapide de la matrice. Le decalage des lignes s'effectue | |
129 | + ici par groupe de 20. C'est le seul parametre a regler ici. | |
130 | +*/ | |
131 | +int tp_fast_vidage(struct camprop *cam) | |
132 | +{ | |
133 | + int i, j; | |
134 | + int imax, jmax, decaligne; | |
135 | + | |
136 | + /* Nombre total de photocellules dans le registre horizontal. */ | |
137 | + imax = cam->nb_photox + cam->nb_deadbeginphotox + cam->nb_deadendphotox; | |
138 | + | |
139 | + /* Nombre total de photocellules dans une colonne de la matrice. */ | |
140 | + jmax = cam->nb_photoy + cam->nb_deadbeginphotoy + cam->nb_deadendphotoy; | |
141 | + | |
142 | + /* Nombre de lignes decalees a chaque boucle sur l'axe vertical. */ | |
143 | + decaligne = 20; | |
144 | + | |
145 | + /* Nombre total de boucles sur l'axe vertical. */ | |
146 | + jmax = (int) ceil (1. * jmax / decaligne) ; | |
147 | + | |
148 | + /* Boucle sur les paquets de lignes. */ | |
149 | + for (j = 0; j < jmax; j++) { | |
150 | + /* Decalage d'un paquet de 20 lignes. */ | |
151 | + for (i = 0; i < decaligne; i++) { | |
152 | + tp_zi_zh(cam); | |
153 | + } | |
154 | + /* Lecture du registre horizontal sans reset */ | |
155 | + for (i = 0; i < imax; i++) { | |
156 | + tp_read_pel_fast2(cam); | |
157 | + } | |
158 | + } | |
159 | + return 0; | |
160 | +} | |
161 | + | |
162 | + | |
163 | +/* | |
164 | +tp_zi_zh(struct camprop *cam) -- | |
165 | + Decalage vertical de toutes les lignes d'un cran vers le bas. | |
166 | + La premiere ligne du bas est donc transferee dans le registre | |
167 | + horizontal. | |
168 | +*/ | |
169 | +int tp_zi_zh(struct camprop *cam) | |
170 | +{ | |
171 | + float tphiV=2.0; | |
172 | + float tphiHS=1.0; | |
173 | + // --- | |
174 | + bcm2835_gpio_write (PHI_V1, LEVEL_HIGH) ; | |
175 | + libcam_sleep(tphiV); | |
176 | + bcm2835_gpio_write (PHI_V1, LEVEL_LOW) ; | |
177 | + bcm2835_gpio_write (PHI_V2, LEVEL_HIGH) ; | |
178 | + libcam_sleep(tphiV); | |
179 | + bcm2835_gpio_write (PHI_V1, LEVEL_HIGH) ; | |
180 | + bcm2835_gpio_write (PHI_V2, LEVEL_LOW) ; | |
181 | + libcam_sleep(tphiV); | |
182 | + bcm2835_gpio_write (PHI_V1, LEVEL_LOW) ; | |
183 | + libcam_sleep(tphiHS); | |
184 | + return 0; | |
185 | +} | |
186 | + | |
187 | + | |
188 | +/* | |
189 | +tp_read_pel_fast2(struct camprop *cam) -- | |
190 | + Lecture rapide d'un pixel : decalage du registre horizontal | |
191 | + sans Reset, mais sans lecture du CAN, | |
192 | +*/ | |
193 | +int tp_read_pel_fast2(struct camprop *cam) | |
194 | +{ | |
195 | + float tphiPIX=0.25; | |
196 | + // --- | |
197 | + bcm2835_gpio_write (PHI_H1, LEVEL_LOW) ; | |
198 | + libcam_sleep(tphiPIX); | |
199 | + bcm2835_gpio_write (PHI_H1, LEVEL_HIGH) ; | |
200 | + libcam_sleep(tphiPIX); | |
201 | + return 0; | |
202 | +} | |
203 | + | |
204 | +/* | |
205 | +tp_read_pel_fast(struct camprop *cam) -- | |
206 | + Lecture rapide d'un pixel : decalage du registre horizontal | |
207 | + avec Reset, mais sans lecture du CAN, | |
208 | +*/ | |
209 | +int tp_read_pel_fast(struct camprop *cam) | |
210 | +{ | |
211 | + float tphiPIX=0.25; | |
212 | + float tphiR=0.020; | |
213 | + // --- | |
214 | + bcm2835_gpio_write (PHI_R, LEVEL_HIGH) ; | |
215 | + libcam_sleep(tphiR); | |
216 | + bcm2835_gpio_write (PHI_R, LEVEL_LOW) ; | |
217 | + libcam_sleep(tphiR); | |
218 | + bcm2835_gpio_write (PHI_H1, LEVEL_LOW) ; | |
219 | + libcam_sleep(tphiPIX); | |
220 | + bcm2835_gpio_write (PHI_H1, LEVEL_HIGH) ; | |
221 | + libcam_sleep(tphiPIX); | |
222 | + return 0; | |
223 | +} | |
224 | + | |
225 | +/* | |
226 | +tp_fast_line_() -- | |
227 | + Lecture rapide du registre horizontal, avec la fonction read_pel_fast. | |
228 | +*/ | |
229 | +int tp_fast_line(struct camprop *cam) | |
230 | +{ | |
231 | + int i, imax; | |
232 | + /* Nombre total de photocellules dans le registre horizontal. */ | |
233 | + imax = cam->nb_photox + cam->nb_deadbeginphotox + cam->nb_deadendphotox; | |
234 | + for (i = 0; i < imax; i++) { | |
235 | + tp_read_pel_fast(cam); | |
236 | + } | |
237 | + return 0; | |
238 | +} | |
239 | + | |
240 | +int tp_read_win(struct camprop *cam) | |
241 | +{ | |
242 | + | |
243 | + int i, j; | |
244 | + int k, l; | |
245 | + int imax, jmax; | |
246 | + int cx1, cx2, cy1; | |
247 | + unsigned short buffer[2048]; | |
248 | + int x; | |
249 | + | |
250 | + /* dimensions de l'image a digitaliser */ | |
251 | + imax = cam->w; | |
252 | + jmax = cam->h; | |
253 | + /* nombre de colonnes de debut a ne pas digitaliser */ | |
254 | + cx1 = cam->nb_deadbeginphotox; | |
255 | + /* nombre de colonnes de fin a ne pas digitaliser */ | |
256 | + cx2 = cam->nb_deadendphotox; | |
257 | + /* nombre de lignes de debut a ne pas digitaliser */ | |
258 | + cy1 = cam->nb_deadbeginphotoy; | |
259 | + | |
260 | + /* On supprime les cy1 premieres lignes */ | |
261 | + for (i = 0; i < cy1; i++) { | |
262 | + tp_zi_zh(cam); | |
263 | + } | |
264 | + | |
265 | + /* On nettoie le registre horizontal */ | |
266 | + for (i = 0; i < 1; i++) { | |
267 | + tp_fast_line(cam); | |
268 | + } | |
269 | + | |
270 | + /* boucle sur l'horloge verticale (transfert) */ | |
271 | + for (i = 0; i < jmax; i++) { | |
272 | + | |
273 | + /* boucle de binning vertical */ | |
274 | + for (k = 0; k < cam->biny; k++) { | |
275 | + tp_zi_zh(cam); | |
276 | + } | |
277 | + | |
278 | + /* On retire les cx1 premiers pixels avec reset */ | |
279 | + for (j = 0; j < cx1; j++) { | |
280 | + tp_read_pel_fast(cam); | |
281 | + } | |
282 | + | |
283 | + /* boucle sur l'horloge horizontale (registre de sortie) */ | |
284 | + for (j = 0; j < imax; j++) { | |
285 | + float tphiR=0.020; | |
286 | + float tRef1=4.0; | |
287 | + float tRef2=1.0; | |
288 | + float tRef3=1.0; | |
289 | + float tphiPIX=0.25; | |
290 | + float tVid1=4.0; | |
291 | + // palier de reset | |
292 | + bcm2835_gpio_write (PHI_R, LEVEL_HIGH) ; | |
293 | + bcm2835_gpio_write (PHI_H1, LEVEL_LOW) ; | |
294 | + libcam_sleep(tphiR); | |
295 | + bcm2835_gpio_write (PHI_R, LEVEL_LOW) ; | |
296 | + libcam_sleep(tphiR); | |
297 | + // palier de reference | |
298 | + libcam_sleep(tRef1); | |
299 | + bcm2835_gpio_write (PHI_CL, LEVEL_HIGH) ; | |
300 | + libcam_sleep(tRef2); | |
301 | + bcm2835_gpio_write (PHI_CL, LEVEL_LOW) ; | |
302 | + libcam_sleep(tRef3); | |
303 | + | |
304 | + /* boucle de binning horizontal */ | |
305 | + for (l = 0; l < cam->binx; l++) { | |
306 | + bcm2835_gpio_write (PHI_H1, LEVEL_LOW) ; | |
307 | + libcam_sleep(tphiPIX); | |
308 | + bcm2835_gpio_write (PHI_H1, LEVEL_HIGH) ; | |
309 | + libcam_sleep(tphiPIX); | |
310 | + } | |
311 | + | |
312 | + // palier video | |
313 | + libcam_sleep(tVid1); | |
314 | + bcm2835_gpio_write (PHI_SC, LEVEL_HIGH) ; | |
315 | + | |
316 | + // -- recupere le nibble _ _ _ _ _ _ _ _ _ _ _ _ 3 2 1 0 | |
317 | + // SB = Select Byte <---- SB=1 ----> <---- SB=0 ----> | |
318 | + // SN = Select Nibble <SN=1 > <SN=0 > <SN=1 > <SN=0 > | |
319 | + bcm2835_gpio_write (PHI_SB, LEVEL_LOW) ; | |
320 | + bcm2835_gpio_write (PHI_SN, LEVEL_LOW) ; | |
321 | + x = (int)bcm2835_gpio_lev(BIT_0); | |
322 | + x += (int)bcm2835_gpio_lev(BIT_1) << 1; | |
323 | + x += (int)bcm2835_gpio_lev(BIT_2) << 2; | |
324 | + x += (int)bcm2835_gpio_lev(BIT_3) << 3; | |
325 | + | |
326 | + // -- recupere le nibble _ _ _ _ _ _ _ _ 3 2 1 0 _ _ _ _ | |
327 | + bcm2835_gpio_write (PHI_SB, LEVEL_LOW) ; | |
328 | + bcm2835_gpio_write (PHI_SN, LEVEL_HIGH) ; | |
329 | + x += (int)bcm2835_gpio_lev(BIT_0) << 4; | |
330 | + x += (int)bcm2835_gpio_lev(BIT_1) << 5; | |
331 | + x += (int)bcm2835_gpio_lev(BIT_2) << 6; | |
332 | + x += (int)bcm2835_gpio_lev(BIT_3) << 7; | |
333 | + | |
334 | + // -- recupere le nibble _ _ _ _ 3 2 1 0 _ _ _ _ _ _ _ _ | |
335 | + bcm2835_gpio_write (PHI_SB, LEVEL_HIGH) ; | |
336 | + bcm2835_gpio_write (PHI_SN, LEVEL_LOW) ; | |
337 | + x += (int)bcm2835_gpio_lev(BIT_0) << 8; | |
338 | + x += (int)bcm2835_gpio_lev(BIT_1) << 9; | |
339 | + x += (int)bcm2835_gpio_lev(BIT_2) << 10; | |
340 | + x += (int)bcm2835_gpio_lev(BIT_3) << 11; | |
341 | + | |
342 | + // -- recupere le nibble 3 2 1 0 _ _ _ _ _ _ _ _ _ _ _ _ | |
343 | + bcm2835_gpio_write (PHI_SB, LEVEL_HIGH) ; | |
344 | + bcm2835_gpio_write (PHI_SN, LEVEL_HIGH) ; | |
345 | + x += (int)bcm2835_gpio_lev(BIT_0) << 12; | |
346 | + x += (int)bcm2835_gpio_lev(BIT_1) << 13; | |
347 | + x += (int)bcm2835_gpio_lev(BIT_2) << 14; | |
348 | + x += (int)bcm2835_gpio_lev(BIT_3) << 15; | |
349 | + | |
350 | + // -- remises au niveaux bas | |
351 | + bcm2835_gpio_write (PHI_SC, LEVEL_LOW) ; | |
352 | + bcm2835_gpio_write (PHI_SB, LEVEL_LOW) ; | |
353 | + bcm2835_gpio_write (PHI_SN, LEVEL_LOW) ; | |
354 | + | |
355 | + if (x > 32767) { | |
356 | + x = 32767; | |
357 | + } | |
358 | + /* Stockage dans un buffer dans la meme page mem */ | |
359 | + buffer[j] = (unsigned short) x; | |
360 | + | |
361 | + } | |
362 | + | |
363 | + /* On retire cx2 pixels a la fin */ | |
364 | + for (j = 0; j < cx2; j++) { | |
365 | + tp_read_pel_fast(cam); | |
366 | + } | |
367 | + | |
368 | + /* On transfere le tableau vers la matrice image */ | |
369 | + if (i != 0) { | |
370 | + cam->p[(i - 1) * imax] = buffer[0]; | |
371 | + } | |
372 | + for (j = 1; j < imax; j++) { | |
373 | + cam->p[(i + 1) * imax - j] = buffer[j]; | |
374 | + } | |
375 | + | |
376 | + } | |
377 | + return 0; | |
378 | +} | |
379 | + | |
380 | +void mc_savefits(struct camprop *cam, char *filename) | |
381 | +{ | |
382 | + FILE *f; | |
383 | + char line[1024],car; | |
384 | + float value0; | |
385 | + char *cars0; | |
386 | + int k,k0; | |
387 | + long one= 1; | |
388 | + int big_endian; | |
389 | + f=fopen(filename,"wb"); | |
390 | + strcpy(line,"SIMPLE = T / file does conform to FITS standard "); | |
391 | + fwrite(line,80,sizeof(char),f); | |
392 | + strcpy(line,"BITPIX = 16 / number of bits per data pixel "); | |
393 | + fwrite(line,80,sizeof(char),f); | |
394 | + strcpy(line,"NAXIS = 2 / number of data axes "); | |
395 | + fwrite(line,80,sizeof(char),f); | |
396 | + sprintf(line,"NAXIS1 = %3d / length of data axis 1 ",cam->w); | |
397 | + fwrite(line,80,sizeof(char),f); | |
398 | + sprintf(line,"NAXIS2 = %3d / length of data axis 2 ",cam->h); | |
399 | + fwrite(line,80,sizeof(char),f); | |
400 | + strcpy(line,"BZERO = 32768 / uint16 "); | |
401 | + fwrite(line,80,sizeof(char),f); | |
402 | + strcpy(line,"BSCALE = 1 / uint16 "); | |
403 | + fwrite(line,80,sizeof(char),f); | |
404 | + k0=9; | |
405 | + strcpy(line,"END "); | |
406 | + fwrite(line,80,sizeof(char),f); | |
407 | + strcpy(line," "); | |
408 | + for (k=k0;k<=36;k++) { | |
409 | + fwrite(line,80,sizeof(char),f); | |
410 | + } | |
411 | + /* byte order test */ | |
412 | + if (!(*((char *)(&one)))) { | |
413 | + big_endian=1; | |
414 | + } else { | |
415 | + big_endian=0; | |
416 | + } | |
417 | + /* write data */ | |
418 | + for (k=0;k<cam->h*cam->w;k++) { | |
419 | + value0=cam->p[k]; // 32=4*8bits | |
420 | + if (big_endian==0) { | |
421 | + cars0=(char*)&value0; | |
422 | + car=cars0[0]; | |
423 | + cars0[0]=cars0[1]; | |
424 | + cars0[1]=car; | |
425 | + } | |
426 | + fwrite(&value0,1,sizeof(unsigned short),f); | |
427 | + } | |
428 | + int dx=cam->h*cam->w/2880.; | |
429 | + int n=(int)(2880.*(dx-floor(dx))); | |
430 | + value0=(float)0.; | |
431 | + for (k=0;k<n;k++) { | |
432 | + if (big_endian==0) { | |
433 | + cars0=(char*)&value0; | |
434 | + car=cars0[0]; | |
435 | + cars0[0]=cars0[1]; | |
436 | + cars0[1]=car; | |
437 | + } | |
438 | + fwrite(&value0,1,sizeof(unsigned short),f); | |
439 | + } | |
440 | + fclose(f); | |
441 | +} | |
442 | + | |
443 | +int main(int argc, char* argv[]) | |
444 | +{ | |
445 | + | |
446 | + // decode la ligne de commandes. Exemple : tp_ccd.exe 0.5 1 | |
447 | + float exptime = 0.5; | |
448 | + int binning = 1; | |
449 | + if(argc < 2) | |
450 | + { | |
451 | + printf("ERR 1 : Not enough command line parameters\n"); | |
452 | + //exit(1); | |
453 | + } else { | |
454 | + exptime = atof(argv[1]); | |
455 | + binning = atoi(argv[2]); | |
456 | + } | |
457 | + printf("ERR 0 : %f %d\n", exptime, binning); | |
458 | + | |
459 | + struct camprop cam; | |
460 | + // === initialise la structure des donnees de la camera | |
461 | + strcpy(cam.msg,""); | |
462 | + cam.exptime=exptime; // sec | |
463 | + cam.binx=binning; | |
464 | + cam.biny=binning; | |
465 | + cam.x1=1; | |
466 | + cam.y1=1; | |
467 | + cam.x2=768; | |
468 | + cam.y2=512; | |
469 | + cam.nb_photox=cam.x2-cam.x1+1; | |
470 | + cam.nb_photoy=cam.y2-cam.y1+1; | |
471 | + cam.celldimx=9e-6; // m | |
472 | + cam.celldimy=9e-6; // m | |
473 | + cam.overscanindex=0; | |
474 | + cam.nb_deadbeginphotox=14; | |
475 | + cam.nb_deadendphotox=14; | |
476 | + cam.nb_deadbeginphotoy=4; | |
477 | + cam.nb_deadendphotoy=4; | |
478 | + cam.p=NULL; | |
479 | + /* --- pour l'amplificateur des Kaf-401 --- */ | |
480 | + cam.ampliindex=0; | |
481 | + cam.nbampliclean=0; | |
482 | + // === initialise le GPIO | |
483 | + if (!bcm2835_init()) { | |
484 | + printf("Probleme bcm2835_init"); | |
485 | + return 1; | |
486 | + } | |
487 | + // Set the pin to be an output | |
488 | + bcm2835_gpio_fsel(PHI_V1, BCM2835_GPIO_FSEL_OUTP); | |
489 | + bcm2835_gpio_fsel(PHI_V2, BCM2835_GPIO_FSEL_OUTP); | |
490 | + bcm2835_gpio_fsel(PHI_H1, BCM2835_GPIO_FSEL_OUTP); | |
491 | + bcm2835_gpio_fsel(PHI_R, BCM2835_GPIO_FSEL_OUTP); | |
492 | + bcm2835_gpio_fsel(PHI_CL, BCM2835_GPIO_FSEL_OUTP); | |
493 | + bcm2835_gpio_fsel(PHI_SB, BCM2835_GPIO_FSEL_OUTP); | |
494 | + bcm2835_gpio_fsel(PHI_SC, BCM2835_GPIO_FSEL_OUTP); | |
495 | + bcm2835_gpio_fsel(PHI_SN, BCM2835_GPIO_FSEL_OUTP); | |
496 | + bcm2835_gpio_fsel(DELAY, BCM2835_GPIO_FSEL_OUTP); // special delay us | |
497 | + // Set the pin to be an input | |
498 | + bcm2835_gpio_fsel(BIT_0, BCM2835_GPIO_FSEL_INPT); | |
499 | + bcm2835_gpio_fsel(BIT_1, BCM2835_GPIO_FSEL_INPT); | |
500 | + bcm2835_gpio_fsel(BIT_2, BCM2835_GPIO_FSEL_INPT); | |
501 | + bcm2835_gpio_fsel(BIT_3, BCM2835_GPIO_FSEL_INPT); | |
502 | + // Set default values for outputs | |
503 | + bcm2835_gpio_write (PHI_V1, LEVEL_LOW) ; | |
504 | + bcm2835_gpio_write (PHI_V2, LEVEL_LOW) ; | |
505 | + bcm2835_gpio_write (PHI_H1, LEVEL_HIGH) ; | |
506 | + bcm2835_gpio_write (PHI_R, LEVEL_LOW) ; | |
507 | + bcm2835_gpio_write (PHI_CL, LEVEL_LOW) ; | |
508 | + bcm2835_gpio_write (PHI_SB, LEVEL_LOW) ; | |
509 | + bcm2835_gpio_write (PHI_SC, LEVEL_LOW) ; | |
510 | + bcm2835_gpio_write (PHI_SN, LEVEL_LOW) ; | |
511 | + if (1==1) { | |
512 | + printf("=== init OK\n"); | |
513 | + cmdAudineAcqNormal(&cam); | |
514 | + printf("=== acq OK\n"); | |
515 | + char filename[1024]; | |
516 | + strcpy(filename,"/home/user/Documents/image.fit"); | |
517 | + mc_savefits(&cam, filename); | |
518 | + } else if (1==3) { | |
519 | + for (int i = 0; i < 100000; i++) { | |
520 | + float tphiV=2.0; | |
521 | + float tphiHS=1.0; | |
522 | + // --- | |
523 | + bcm2835_gpio_write (PHI_V1, LEVEL_HIGH) ; | |
524 | + bcm2835_gpio_write (PHI_V2, LEVEL_HIGH) ; | |
525 | + bcm2835_gpio_write (PHI_H1, LEVEL_HIGH) ; | |
526 | + bcm2835_gpio_write (PHI_R, LEVEL_HIGH) ; | |
527 | + bcm2835_gpio_write (PHI_CL, LEVEL_HIGH) ; | |
528 | + bcm2835_gpio_write (PHI_SB, LEVEL_HIGH) ; | |
529 | + bcm2835_gpio_write (PHI_SC, LEVEL_HIGH) ; | |
530 | + bcm2835_gpio_write (PHI_SN, LEVEL_HIGH) ; | |
531 | + libcam_sleep(tphiV); | |
532 | + bcm2835_gpio_write (PHI_V1, LEVEL_LOW) ; | |
533 | + bcm2835_gpio_write (PHI_V2, LEVEL_LOW) ; | |
534 | + bcm2835_gpio_write (PHI_H1, LEVEL_LOW) ; | |
535 | + bcm2835_gpio_write (PHI_R, LEVEL_LOW) ; | |
536 | + bcm2835_gpio_write (PHI_CL, LEVEL_LOW) ; | |
537 | + bcm2835_gpio_write (PHI_SB, LEVEL_LOW) ; | |
538 | + bcm2835_gpio_write (PHI_SC, LEVEL_LOW) ; | |
539 | + bcm2835_gpio_write (PHI_SN, LEVEL_LOW) ; | |
540 | + libcam_sleep(tphiHS); | |
541 | + } | |
542 | + } else { | |
543 | + for (int i = 0; i <2; i++) { | |
544 | + tp_zi_zh(&cam); | |
545 | + //libcam_sleep(20.0); | |
546 | + } | |
547 | + } | |
548 | + printf("=== Termine\n"); | |
549 | + return 0; | |
550 | +} | |
... | ... |
gui/tp_audine_elec/tp_audine_elec.py
... | ... | @@ -35,7 +35,7 @@ if __name__ == "__main__": |
35 | 35 | if not os.path.exists(fconfig): |
36 | 36 | config = {} |
37 | 37 | conf = {} |
38 | - conf["fits_path"] = path_products | |
38 | + conf["fits_path"] = "/home/user/Documents" | |
39 | 39 | config["visu1"] = conf |
40 | 40 | else: |
41 | 41 | with open(fconfig, 'r') as stream: |
... | ... | @@ -68,11 +68,12 @@ if __name__ == "__main__": |
68 | 68 | |
69 | 69 | # Fonction appelée par l'appui du bouton |
70 | 70 | def acquisition(): |
71 | + global widgets | |
71 | 72 | expo = var_exp.get() |
72 | 73 | binn = var_bin.get() |
73 | 74 | # --- |
74 | 75 | argus = [] |
75 | - argus.append("tp_ccd") | |
76 | + argus.append("/home/user/iut/tp_ccd/bin/Debug/tp_ccd") | |
76 | 77 | argus.append(f"{expo}") |
77 | 78 | argus.append(f"{binn}") |
78 | 79 | # --- Launch the acquisition process |
... | ... | @@ -86,6 +87,18 @@ if __name__ == "__main__": |
86 | 87 | message = f"Acquisition done in {dt:.3f} sec" |
87 | 88 | print(message) |
88 | 89 | print(stdo) |
90 | + # --- | |
91 | + time.sleep(0.5) | |
92 | + ima1.rootdir = "/home/user/Documents" | |
93 | + fullfile = ima1.load("image.fit") | |
94 | + path_new = os.path.dirname(fullfile) | |
95 | + config["visu1"]["fits_path"] = path_new | |
96 | + save_config() | |
97 | + # --- | |
98 | + visu1.autocuts() | |
99 | + visu1.disp() | |
100 | + widgets["button_saveima_1"].configure(state= tk.NORMAL) | |
101 | + | |
89 | 102 | # update the plot |
90 | 103 | tkroot.update() |
91 | 104 | |
... | ... | @@ -95,7 +108,7 @@ if __name__ == "__main__": |
95 | 108 | |
96 | 109 | # --- Create a simple Tk interface |
97 | 110 | tkroot = tk.Tk() |
98 | - tkroot.geometry("720x660+120+80") | |
111 | + tkroot.geometry("720x675+120+80") | |
99 | 112 | tkroot.title("TP Audine Electronique - BUT S5") |
100 | 113 | # --- |
101 | 114 | frame1 = tk.Frame(tkroot) |
... | ... |