Rev 291 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 291 | Rev 299 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 |
|
1 | #define USE_DAQ |
2 | //#define USE_MIKRO |
2 | //#define USE_MIKRO |
3 | #define USE_EASIROC |
3 | #define USE_EASIROC |
4 | #define USE_UDPCONTROL |
4 | #define USE_UDPCONTROL |
5 | 5 | ||
6 | #ifdef USE_EASIROC |
6 | #ifdef USE_EASIROC |
7 | #include "easiroc.h" |
7 | #include "easiroc.h" |
8 | 8 | ||
9 | #define erIpAddr "192.168.10.16" |
9 | #define erIpAddr "192.168.10.16" |
10 | #define erDAQmode 3 |
10 | #define erDAQmode 3 |
- | 11 | ||
- | 12 | #define ID_ADC_HG 0x81 |
|
- | 13 | #define ID_ADC_LG 0x60 |
|
- | 14 | #define ID_TDC 0xCC |
|
- | 15 | unsigned int esrcdata[EASIROC_MAX_READ_N_WORDS]; |
|
11 | #endif |
16 | #endif |
12 | 17 | ||
13 | #ifdef USE_UDPCONTROL |
18 | #ifdef USE_UDPCONTROL |
14 | #include "SiTCP.h" |
19 | #include "SiTCP.h" |
15 | #include "sender.h" |
20 | #include "sender.h" |
Line 45... | Line 50... | ||
45 | 50 | ||
46 | // Izberi ustrezni interface v meniju projektnega okna |
51 | // Izberi ustrezni interface v meniju projektnega okna |
47 | // Options->CompilerDefines (dodaj /DSISVME ali /DWIENVME) |
52 | // Options->CompilerDefines (dodaj /DSISVME ali /DWIENVME) |
48 | #ifdef USE_DAQ |
53 | #ifdef USE_DAQ |
49 | # define USE_CAMAC |
54 | # define USE_CAMAC |
- | 55 | int cres; |
|
50 | # include "camac.h" |
56 | # include "camac.h" |
51 | # ifdef SISVME |
57 | # ifdef SISVME |
52 | # include "sisWIENVME_VME_dll.h" |
58 | # include "sisWIENVME_VME_dll.h" |
53 | # endif |
59 | # endif |
54 | # ifdef WIENVME |
60 | # ifdef WIENVME |
Line 68... | Line 74... | ||
68 | #include <analysis.h> |
74 | #include <analysis.h> |
69 | 75 | ||
70 | #include "l2d_ui.h" |
76 | #include "l2d_ui.h" |
71 | 77 | ||
72 | #ifdef USE_DAQ |
78 | #ifdef USE_DAQ |
73 |
|
79 | //# define VADC_ADDR1 0x55550000 |
74 | # define VADC1 1 |
80 | # define VADC1 1 |
75 | //# define VADC_ADDR2 0x550000 |
81 | //# define VADC_ADDR2 0x550000 |
76 | # define VADC2 2 |
82 | # define VADC2 2 |
77 | //# define NTDCJ1 17 |
83 | //# define NTDCJ1 17 |
78 | //# define NTDCJ2 18 |
84 | //# define NTDCJ2 18 |
Line 89... | Line 95... | ||
89 | 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; |
95 | 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; |
90 | #endif |
96 | #endif |
91 | 97 | ||
92 | #ifdef USE_CAEN_TDC |
98 | #ifdef USE_CAEN_TDC |
93 | // CAEN V1290 TDC |
99 | // CAEN V1290 TDC |
- | 100 | #define TDC_CH_SHIFT |
|
94 | int V1290_writeOC(int *write_buffer); |
101 | int V1290_writeOC(int *write_buffer); |
95 | int V1290_readOC(int *write_buffer); |
102 | int V1290_readOC(int *write_buffer); |
96 | void V1290_init(); |
103 | void V1290_init(); |
- | 104 | void V1290_readConfig(); |
|
97 | #endif |
105 | #endif |
98 | // Pomozne funkcije |
106 | // Pomozne funkcije |
99 | int max_from(int* array, int ifrom, int ito); |
107 | int max_from(int* array, int ifrom, int ito); |
100 | 108 | ||
101 | #ifdef USE_MIKRO |
109 | #ifdef USE_MIKRO |
Line 169... | Line 177... | ||
169 | } |
177 | } |
170 | 178 | ||
171 | int CVICALLBACK daq_run(void *functionData) |
179 | int CVICALLBACK daq_run(void *functionData) |
172 | { |
180 | { |
173 | int i,j; |
181 | int i,j; |
174 | int ndat,dtype,ch,rg,adc |
182 | int ndat,dtype,ch,rg,adc; |
175 | unsigned long a,b,ec1,ec2; |
183 | unsigned long a,b,ec1,ec2; |
176 | unsigned long data[100], data2[100]; |
184 | unsigned long data[100], data2[100]; |
177 | unsigned long aa[NCH][4]; |
185 | unsigned long aa[NCH][4]; |
178 | unsigned long step_minutes, end_time_s, cur_time_s; |
186 | unsigned long step_minutes, end_time_s, cur_time_s; |
179 | int start_hours, start_minutes, start_seconds; |
187 | int start_hours, start_minutes, start_seconds; |
Line 303... | Line 311... | ||
303 | } |
311 | } |
304 | #endif |
312 | #endif |
305 | #ifdef USE_CAEN_TDC |
313 | #ifdef USE_CAEN_TDC |
306 | dum=0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); Delay(0.01); |
314 | dum=0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); Delay(0.01); |
307 | 315 | ||
308 | 316 | /* function moved to TDC INIT |
|
309 | //pair(00)/trailing(01)/leading(10)/both(11) edge |
317 | //pair(00)/trailing(01)/leading(10)/both(11) edge |
310 | dum=0x2200; V1290_writeOC(&dum); |
318 | dum=0x2200; V1290_writeOC(&dum); |
311 | GetCtrlVal (p1h, P1_TDC_EDGE, &dum); |
319 | GetCtrlVal (p1h, P1_TDC_EDGE, &dum); |
312 | V1290_writeOC(&dum); |
320 | V1290_writeOC(&dum); |
- | 321 | */ |
|
313 | #endif |
322 | #endif |
314 | 323 | ||
- | 324 | //some init moved to Main |
|
- | 325 | /* |
|
315 | #ifdef USE_CAMAC |
326 | #ifdef USE_CAMAC |
316 | BZ(&cres); |
327 | BZ(&cres); |
317 | CAMAC_cccz(&cres); |
328 | CAMAC_cccz(&cres); |
318 | CAMAC_cccc(&cres); |
329 | CAMAC_cccc(&cres); |
319 | CREM_I(&cres); |
330 | CREM_I(&cres); |
Line 322... | Line 333... | ||
322 | //CAEN C 219 Progammable I/O |
333 | //CAEN C 219 Progammable I/O |
323 | CSSA_R(NPIO, 0, 9, &dum);//init |
334 | CSSA_R(NPIO, 0, 9, &dum);//init |
324 | //dum=6; //(OUTPUT, POSITIVE, NORMAL, TRANSPARENT) |
335 | //dum=6; //(OUTPUT, POSITIVE, NORMAL, TRANSPARENT) |
325 | dum=2; //(OUTPUT, NEGATIVE, NORMAL, TRANSPARENT) |
336 | dum=2; //(OUTPUT, NEGATIVE, NORMAL, TRANSPARENT) |
326 | CSSA_W(NPIO, 0, 17, &dum); |
337 | CSSA_W(NPIO, 0, 17, &dum); |
327 | Delay |
338 | Delay(0.01); |
328 |
|
339 | #endif |
329 | Delay(0.01); |
340 | Delay(0.01); |
330 | #ifdef NTDCJ1 |
341 | #ifdef NTDCJ1 |
331 | CSSA_R(NTDCJ1,0,9,&cres); |
342 | CSSA_R(NTDCJ1,0,9,&cres); |
332 | printf("CSSA_R(NTDCJ1,0,9,&cres)=0x%0x\n", cres); |
343 | printf("CSSA_R(NTDCJ1,0,9,&cres)=0x%0x\n", cres); |
333 | CSSA_R(NTDCJ1,0,26,&cres); |
344 | CSSA_R(NTDCJ1,0,26,&cres); |
334 | CSSA_R(NTDCJ1,1,26,&cres); |
345 | CSSA_R(NTDCJ1,1,26,&cres); |
335 | printf("CSSA_R(NTDCJ1,0,26,&cres)=0x%0x\n", cres); |
346 | printf("CSSA_R(NTDCJ1,0,26,&cres)=0x%0x\n", cres); |
336 |
|
347 | #endif |
337 | #ifdef NTDCJ2 |
348 | #ifdef NTDCJ2 |
338 | CSSA_R(NTDCJ2,0,9,&cres); |
349 | CSSA_R(NTDCJ2,0,9,&cres); |
339 | printf("CSSA_R(NTDCJ2,0,9,&cres)=0x%0x\n", cres); |
350 | printf("CSSA_R(NTDCJ2,0,9,&cres)=0x%0x\n", cres); |
340 | CSSA_R(NTDCJ2,0,26,&cres); |
351 | CSSA_R(NTDCJ2,0,26,&cres); |
341 | printf("CSSA_R(NTDCJ2,0,26,&cres)=0x%0x\n", cres); |
352 | printf("CSSA_R(NTDCJ2,0,26,&cres)=0x%0x\n", cres); |
342 | #endif |
353 | #endif |
343 | #endif |
354 | #endif |
- | 355 | */ |
|
344 | #endif |
356 | #endif |
345 | 357 | ||
- | 358 | #ifdef USE_EASIROC |
|
- | 359 | //easiroc_singleADCstop(); // clear?? |
|
- | 360 | easiroc_singleADCstart(); |
|
- | 361 | #endif |
|
- | 362 | ||
346 | if (dsave) { |
363 | if (dsave) { |
347 | sprintf(dfile,"%s_file%02d.dat",dfile0,fcount); |
364 | sprintf(dfile,"%s_file%02d.dat",dfile0,fcount); |
348 | /* |
365 | /* |
349 | // checks if file already exists and prompts user for action |
366 | // checks if file already exists and prompts user for action |
350 | if( fopen(dfile, "r") != NULL ) { |
367 | if( fopen(dfile, "r") != NULL ) { |
Line 387... | Line 404... | ||
387 | #endif |
404 | #endif |
388 | 405 | ||
389 | SetCtrlVal (p1h, P1_Y, posrec.yset); |
406 | SetCtrlVal (p1h, P1_Y, posrec.yset); |
390 | SetCtrlVal (p1h, P1_IY, posrec.iy); |
407 | SetCtrlVal (p1h, P1_IY, posrec.iy); |
391 | 408 | ||
392 | 409 | ||
393 | for (posrec.ix=0;posrec.ix<runrec.nx;posrec.ix++) { |
410 | for (posrec.ix=0;posrec.ix<runrec.nx;posrec.ix++) { |
394 | posrec.xset=runrec.x0+posrec.ix*runrec.dx; |
411 | posrec.xset=runrec.x0+posrec.ix*runrec.dx; |
395 | #ifdef USE_MIKRO |
412 | #ifdef USE_MIKRO |
396 | // printf("MIKRO_MoveTo (1, x);%d\n",x); |
413 | // printf("MIKRO_MoveTo (1, x);%d\n",x); |
397 | MIKRO_MoveTo (MIKRO_X, posrec.xset); |
414 | MIKRO_MoveTo (MIKRO_X, posrec.xset); |
Line 417... | Line 434... | ||
417 | // clear the plots |
434 | // clear the plots |
418 | for (j=0;j<NCH;j++) { |
435 | for (j=0;j<NCH;j++) { |
419 | for (i=0;i<MAXCH_TDC;i++){ |
436 | for (i=0;i<MAXCH_TDC;i++){ |
420 | dtdc[j][0][i]=0; |
437 | dtdc[j][0][i]=0; |
421 | dtdc[j][1][i]=0; |
438 | dtdc[j][1][i]=0; |
422 | } |
439 | } |
423 | for (i=0;i<MAXCH_QDC;i++){ |
440 | for (i=0;i<MAXCH_QDC;i++){ |
424 | dadc[j][0][i]=0; |
441 | dadc[j][0][i]=0; |
425 | dadc[j][1][i]=0; |
442 | dadc[j][1][i]=0; |
426 | } |
443 | } |
427 | } |
444 | } |
Line 455... | Line 472... | ||
455 | 472 | ||
456 | // Delay(0.001); |
473 | // Delay(0.001); |
457 | wait_loop(IWAIT); |
474 | wait_loop(IWAIT); |
458 | //CSSA_R(NGL,0,10,&cres); |
475 | //CSSA_R(NGL,0,10,&cres); |
459 | 476 | ||
- | 477 | ||
- | 478 | #ifdef USE_EASIROC |
|
- | 479 | //easiroc_singleADCstop(); // clear?? |
|
- | 480 | //easiroc_singleADCstart(); |
|
- | 481 | #endif |
|
460 | 482 | ||
461 | 483 | ||
462 | # ifdef NPIO |
484 | # ifdef NPIO |
463 | dum=0x0; |
485 | dum=0x0; |
464 | CSSA_W(NPIO, 0, 16, &dum); |
486 | CSSA_W(NPIO, 0, 16, &dum); |
465 | //printf("PIO VETO OFF\n"); |
487 | //printf("PIO VETO OFF\n"); |
466 | # endif |
488 | # endif |
467 | # endif |
489 | # endif |
- | 490 | ||
- | 491 | ||
468 | 492 | ||
469 | // Waiting for LAM |
493 | // Waiting for LAM |
470 | 494 | ||
471 | ntics=0; |
495 | ntics=0; |
472 | 496 | ||
Line 580... | Line 604... | ||
580 | 604 | ||
581 | 605 | ||
582 | // TDC |
606 | // TDC |
583 | #ifdef USE_CAEN_TDC |
607 | #ifdef USE_CAEN_TDC |
584 | 608 | ||
- | 609 | ||
585 | int dbg_tdc_t = 0; |
610 | int dbg_tdc_t = 0; GetCtrlVal(p1h, P1_TDC_DBG_STDOUT, &dbg_tdc_t); |
586 | int dbg_tdc_f = 0; |
611 | int dbg_tdc_f = 0; GetCtrlVal(p1h, P1_TDC_DBG_FILOUT, &dbg_tdc_f); |
587 | FILE *fpout=NULL; |
612 | FILE *fpout=NULL; |
588 | if(dbg_tdc_f) fpout=fopen("TDCout.txt", "at"); |
613 | if(dbg_tdc_f) fpout=fopen("TDCout.txt", "at"); |
589 | 614 | ||
590 | 615 | ||
591 | 616 | ||
Line 624... | Line 649... | ||
624 | if(dbg_tdc_t) printf(">>> TDC Measurement !!!!!!!! >>> CH = %d | edge = %d | ev = %d\n", (dum32 & 0x3FFFFFF) >> 21, (dum32 & 0x7FFFFFF) >> 26, dum32 & 0x1FFFFF); |
649 | if(dbg_tdc_t) printf(">>> TDC Measurement !!!!!!!! >>> CH = %d | edge = %d | ev = %d\n", (dum32 & 0x3FFFFFF) >> 21, (dum32 & 0x7FFFFFF) >> 26, dum32 & 0x1FFFFF); |
625 | if(dbg_tdc_f) fprintf(fpout, ">>> TDC Measurement !!!!!!!! >>> CH = %d | edge = %d | ev = %d\n", (dum32 & 0x3FFFFFF) >> 21, (dum32 & 0x7FFFFFF) >> 26, dum32 & 0x1FFFFF); |
650 | if(dbg_tdc_f) fprintf(fpout, ">>> TDC Measurement !!!!!!!! >>> CH = %d | edge = %d | ev = %d\n", (dum32 & 0x3FFFFFF) >> 21, (dum32 & 0x7FFFFFF) >> 26, dum32 & 0x1FFFFF); |
626 | 651 | ||
627 | //TDC Channel = 0000 0x<...Channel...>x 20*x |
652 | //TDC Channel = 0000 0x<...Channel...>x 20*x |
628 | tdcch = tdcmap[(dum32 & 0x3FFFFFF) >> 21]; |
653 | tdcch = tdcmap[(dum32 & 0x3FFFFFF) >> 21]; |
- | 654 | #ifdef TDC_CH_SHIFT |
|
- | 655 | if( (0<tdcch) && (tdcch<=15) ) tdcch -= 1; |
|
- | 656 | ||
- | 657 | #endif |
|
629 | 658 | ||
630 | 659 | ||
631 | //TDC Measurement = 0000 0xxx xxx<...TDC...> |
660 | //TDC Measurement = 0000 0xxx xxx<...TDC...> |
632 | unsigned long tdc_ev = dum32 & 0x1FFFFF; |
661 | unsigned long tdc_ev = dum32 & 0x1FFFFF; |
- | 662 | //if(tdcch < 31) printf("tdc_ev[%d] = %d\n", tdcch, tdc_ev); |
|
633 | 663 | ||
634 | int tdc_edge = (dum32 & 0x1) >> 26; |
664 | int tdc_edge = (dum32 & 0x1) >> 26; |
635 | 665 | ||
636 | /* |
666 | /* |
637 | adc = (int)(tdc_ev/4.0); // 21 bit -> 16 bit ??? |
667 | adc = (int)(tdc_ev/4.0); // 21 bit -> 16 bit ??? |
Line 646... | Line 676... | ||
646 | */ |
676 | */ |
647 | 677 | ||
648 | if(dbg_tdc_t) printf(">>> tdcch = %d | tdc_ev = %d | raw = %d\n", tdcch, tdc_ev, dum32); |
678 | if(dbg_tdc_t) printf(">>> tdcch = %d | tdc_ev = %d | raw = %d\n", tdcch, tdc_ev, dum32); |
649 | if(dbg_tdc_f) fprintf(fpout, ">>> tdcch = %d | tdc_ev = %d | raw = %d\n", tdcch, tdc_ev, dum32); |
679 | if(dbg_tdc_f) fprintf(fpout, ">>> tdcch = %d | tdc_ev = %d | raw = %d\n", tdcch, tdc_ev, dum32); |
650 | 680 | ||
651 |
|
681 | //if(l==0) |
652 | if(tdcchhit[tdcch]==0) |
682 | if(tdcchhit[tdcch]==0) |
653 |
|
683 | if(tdc_edge==0) |
654 | if(tdcch < NCH_TDC) { |
684 | if(tdcch < NCH_TDC) { |
655 | aa[tdcch][0]=tdc_ev; |
685 | aa[tdcch][0]=tdc_ev; |
656 | if(tdcch < MAXCH_TDC) { |
686 | if(tdcch < MAXCH_TDC) { |
657 | dtdc[tdcch][0][tdc_ev]+=1; |
687 | dtdc[tdcch][0][tdc_ev]+=1; |
658 | } |
688 | } |
- | 689 | if(dbg_tdc_t) printf(">>>>>> TDC Measurement saved >>> CH = %d | edge = %d | ev = %d\n", tdcch, tdc_edge, tdc_ev); |
|
- | 690 | if(dbg_tdc_f) fprintf(fpout, ">>>>>> TDC Measurement saved >>> CH = %d | edge = %d | ev = %d\n", tdcch, tdc_edge, tdc_ev); |
|
- | 691 | ||
659 | } |
692 | } |
660 |
|
693 | |
661 | tdcchhit[tdcch]=1; |
694 | tdcchhit[tdcch]=1; |
662 | 695 | ||
663 | break; |
696 | break; |
664 | case 0x18000000://00011 = TDC Trailer |
697 | case 0x18000000://00011 = TDC Trailer |
665 | if(dbg_tdc_t) printf(">>> TDC Trailer | Event ID =%d\n", (dum32 & 0xFFFFFF) >> 12); |
698 | if(dbg_tdc_t) printf(">>> TDC Trailer | Event ID =%d\n", (dum32 & 0xFFFFFF) >> 12); |
Line 759... | Line 792... | ||
759 | dadc[ch][rg][adc]+=1; |
792 | dadc[ch][rg][adc]+=1; |
760 | } |
793 | } |
761 | } |
794 | } |
762 | } |
795 | } |
763 | # endif |
796 | # endif |
- | 797 | ||
- | 798 | ||
- | 799 | #ifdef USE_EASIROC |
|
- | 800 | ndat = easiroc_singleADCevent(esrcdata); |
|
- | 801 | //printf("ndat = %d\n", ndat); |
|
- | 802 | //for(int iw=0; iw<ndat; iw++) printf("[%d] 0x%x ", iw, esrcdata[iw]); |
|
- | 803 | //printf("\n"); |
|
- | 804 | for (i=0; i<ndat; i++) { |
|
- | 805 | dtype = (esrcdata[i] >> 24) & 0xFF; |
|
- | 806 | //int ch, overflow, edge, data; |
|
- | 807 | switch(dtype) { |
|
- | 808 | case ID_ADC_HG: |
|
- | 809 | rg=0; |
|
- | 810 | ch = (esrcdata[i] >> 16) & 0x1F; |
|
- | 811 | //overflow = (esrcdata[i] >> 13) & 0x1; |
|
- | 812 | adc = (esrcdata[i]) & 0xFFF; |
|
- | 813 | //printf("ID_ADC_HG: ch = %d | X = %d | data = %d\n", ch, overflow, data); |
|
- | 814 | aa[ch][rg+2]=adc; |
|
- | 815 | dadc[ch][rg][adc]+=1; |
|
- | 816 | break; |
|
- | 817 | case ID_ADC_LG: |
|
- | 818 | rg=1; |
|
- | 819 | ch = (esrcdata[i] >> 16) & 0x1F; |
|
- | 820 | //overflow = (esrcdata[i] >> 13) & 0x1; |
|
- | 821 | adc = (esrcdata[i]) & 0xFFF; |
|
- | 822 | //printf("ID_ADC_LG: ch = %d | X = %d | data = %d\n", ch, overflow, data); |
|
- | 823 | aa[ch][rg+2]=adc; |
|
- | 824 | dadc[ch][rg][adc]+=1; |
|
- | 825 | break; |
|
- | 826 | case ID_TDC: |
|
- | 827 | //ch = (esrcdata[i] >> 16) & 0x1F; |
|
- | 828 | //edge = (esrcdata[i] >> 15) & 0x1; |
|
- | 829 | //data = (esrcdata[i]) & 0x3FFF; |
|
- | 830 | //printf("ID_TDC: ch = %d | X = %d | data = %d\n", ch, overflow, data); |
|
- | 831 | printf("EASIROC TDC: esrcdata[i] = 0x%X !?!?!?\n", esrcdata[i]); |
|
- | 832 | break; |
|
- | 833 | default: |
|
- | 834 | printf("EASIROC default: esrcdata[i] = 0x%X !!!\n", esrcdata[i]); |
|
- | 835 | break; |
|
- | 836 | } |
|
- | 837 | } |
|
- | 838 | #endif |
|
764 | 839 | ||
765 | #else /* generate test data */ |
840 | #else /* generate test data */ |
766 | if (!daq_on) break; |
841 | if (!daq_on) break; |
767 | for (i=0;i<NCH;i++) { |
842 | for (i=0;i<NCH;i++) { |
768 | adc=100+evtrec.nev%200; |
843 | adc=100+evtrec.nev%200; |
Line 881... | Line 956... | ||
881 | //SetStdioWindowSize (150, 600); |
956 | //SetStdioWindowSize (150, 600); |
882 | //SetStdioWindowPosition (825, 250); |
957 | //SetStdioWindowPosition (825, 250); |
883 | SetStdioWindowSize (900, 600); |
958 | SetStdioWindowSize (900, 600); |
884 | //SetStdioWindowPosition (20, 800); |
959 | //SetStdioWindowPosition (20, 800); |
885 | SetStdioWindowPosition (20, 1100); |
960 | SetStdioWindowPosition (20, 1100); |
- | 961 | ||
- | 962 | /* |
|
- | 963 | easiroc_LoadIni("EASIROCini\\EASIROC.ini"); |
|
- | 964 | PrepareFPGA(); |
|
- | 965 | PrepareSC(1); |
|
- | 966 | PrepareReadSC(1); |
|
- | 967 | //easiroc_PrintData(); |
|
- | 968 | PrepareSC(2); |
|
- | 969 | PrepareReadSC(2); |
|
- | 970 | //easiroc_PrintData(); |
|
- | 971 | */ |
|
- | 972 | ||
886 | 973 | ||
- | 974 | if ((p1h = LoadPanel (0, "l2d_ui.uir", P1)) < 0) return -1; |
|
- | 975 | DisplayPanel (p1h); |
|
- | 976 | ||
- | 977 | // some Init |
|
887 | #ifdef USE_DAQ |
978 | #ifdef USE_DAQ |
888 | WIENVME_VME_START |
979 | //WIENVME_VME_START(NULL); |
- | 980 | WIENVME_VME_START("C:\\home\\cvi\\instr\\WIENVME_DLL\\pcivme_ni.dll"); |
|
- | 981 | ||
- | 982 | ||
- | 983 | #ifdef USE_CAMAC |
|
- | 984 | BZ(&cres); |
|
- | 985 | CAMAC_cccz(&cres); |
|
- | 986 | CAMAC_cccc(&cres); |
|
- | 987 | CREM_I(&cres); |
|
- | 988 | //CSSA_R(NGL,0,25,&cres); |
|
- | 989 | #ifdef NPIO |
|
- | 990 | //CAEN C 219 Progammable I/O |
|
- | 991 | CSSA_R(NPIO, 0, 9, &dum);//init |
|
- | 992 | //dum=6; //(OUTPUT, POSITIVE, NORMAL, TRANSPARENT) |
|
- | 993 | dum=2; //(OUTPUT, NEGATIVE, NORMAL, TRANSPARENT) |
|
- | 994 | CSSA_W(NPIO, 0, 17, &dum); |
|
- | 995 | Delay(0.01); |
|
- | 996 | #endif |
|
- | 997 | ||
- | 998 | Delay(0.01); |
|
- | 999 | #ifdef NTDCJ1 |
|
- | 1000 | CSSA_R(NTDCJ1,0,9,&cres); |
|
- | 1001 | printf("CSSA_R(NTDCJ1,0,9,&cres)=0x%0x\n", cres); |
|
- | 1002 | CSSA_R(NTDCJ1,0,26,&cres); |
|
- | 1003 | CSSA_R(NTDCJ1,1,26,&cres); |
|
- | 1004 | printf("CSSA_R(NTDCJ1,0,26,&cres)=0x%0x\n", cres); |
|
- | 1005 | #endif |
|
- | 1006 | #ifdef NTDCJ2 |
|
- | 1007 | CSSA_R(NTDCJ2,0,9,&cres); |
|
- | 1008 | printf("CSSA_R(NTDCJ2,0,9,&cres)=0x%0x\n", cres); |
|
- | 1009 | CSSA_R(NTDCJ2,0,26,&cres); |
|
- | 1010 | printf("CSSA_R(NTDCJ2,0,26,&cres)=0x%0x\n", cres); |
|
889 | #endif |
1011 | #endif |
- | 1012 | #endif //USE_CAMAC |
|
- | 1013 | ||
890 | 1014 | ||
891 | #ifdef USE_CAEN_TDC |
1015 | #ifdef USE_CAEN_TDC |
892 | V1290_init(); |
1016 | V1290_init(); |
893 | #endif |
1017 | #endif |
- | 1018 | ||
- | 1019 | #endif //USE_DAQ |
|
- | 1020 | ||
894 | 1021 | ||
895 | #ifdef USE_MIKRO |
1022 | #ifdef USE_MIKRO |
896 | MIKRO_Open (MIKRO_COM); |
1023 | MIKRO_Open (MIKRO_COM); |
897 | MIKRO_Init (MIKRO_X,0); |
1024 | MIKRO_Init (MIKRO_X,0); |
898 | #ifdef USE_MIKRO_Y |
1025 | #ifdef USE_MIKRO_Y |
899 | MIKRO_Init (MIKRO_Y,0); |
1026 | MIKRO_Init (MIKRO_Y,0); |
900 | #endif |
1027 | #endif |
901 | #ifdef USE_MIKRO_Z |
1028 | #ifdef USE_MIKRO_Z |
902 | MIKRO_Init (MIKRO_Z,0); |
1029 | MIKRO_Init (MIKRO_Z,0); |
903 | #endif |
1030 | #endif |
904 | #endif |
1031 | #endif |
905 | 1032 | ||
906 | if ((p1h = LoadPanel (0, "l2d_ui.uir", P1)) < 0) return -1; |
- | |
907 | DisplayPanel (p1h); |
- | |
908 | SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1); |
1033 | SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1); |
909 | 1034 | ||
910 | GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy); |
1035 | GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy); |
911 | SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2); |
1036 | SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2); |
912 | 1037 | ||
Line 945... | Line 1070... | ||
945 | MIKRO_MoveTo (MIKRO_Z, zpos); |
1070 | MIKRO_MoveTo (MIKRO_Z, zpos); |
946 | #endif |
1071 | #endif |
947 | } |
1072 | } |
948 | break; |
1073 | break; |
949 | case P1_REREAD: |
1074 | case P1_REREAD: |
950 | if (!daq_on) { |
1075 | if (!daq_on) { |
951 | status = FileSelectPopup ("", "*.dat", ".dat", |
1076 | status = FileSelectPopup ("", "*.dat", ".dat", |
952 | "Izberi datoteko s podatki", |
1077 | "Izberi datoteko s podatki", |
953 | VAL_LOAD_BUTTON, 0, 0, 1, 0, dfile); |
1078 | VAL_LOAD_BUTTON, 0, 0, 1, 0, dfile); |
954 | if (status==1) { |
1079 | if (status==1) { |
955 | fp = fopen (dfile, "rb"); |
1080 | fp = fopen (dfile, "rb"); |
Line 1008... | Line 1133... | ||
1008 | for (i=0;i<MAXCH_QDC;i++){ |
1133 | for (i=0;i<MAXCH_QDC;i++){ |
1009 | dadc[j][0][i]=0; |
1134 | dadc[j][0][i]=0; |
1010 | dadc[j][1][i]=0; |
1135 | dadc[j][1][i]=0; |
1011 | } |
1136 | } |
1012 | } |
1137 | } |
1013 | update_plots(); |
1138 | update_plots(); |
1014 | break; |
1139 | break; |
1015 | case P1_TDCLOG: |
1140 | case P1_TDCLOG: |
1016 | GetCtrlVal (p1h, P1_TDCLOG, &status); |
1141 | GetCtrlVal (p1h, P1_TDCLOG, &status); |
1017 | SetCtrlAttribute (p1h, P1_TDC, ATTR_YMAP_MODE, status); |
1142 | SetCtrlAttribute (p1h, P1_TDC, ATTR_YMAP_MODE, status); |
1018 | update_plots(); |
1143 | update_plots(); |
1019 | break; |
1144 | break; |
1020 | case P1_ADCLOG: |
1145 | case P1_ADCLOG: |
1021 | GetCtrlVal (p1h, P1_ADCLOG, &status); |
1146 | GetCtrlVal (p1h, P1_ADCLOG, &status); |
1022 | SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status); |
1147 | SetCtrlAttribute (p1h, P1_ADC, ATTR_YMAP_MODE, status); |
1023 | update_plots(); |
1148 | update_plots(); |
1024 | break; |
1149 | break; |
1025 | case P1_PIO_ON: |
1150 | case P1_PIO_ON: |
1026 | # ifdef NPIO |
1151 | # ifdef NPIO |
1027 | dum=0x1; |
1152 | dum=0x1; |
1028 | CSSA_W(NPIO, 0, 16, &dum); |
1153 | CSSA_W(NPIO, 0, 16, &dum); |
1029 | printf("PIO VETO ON\n"); |
1154 | printf("PIO VETO ON\n"); |
1030 | # endif |
1155 | # endif |
1031 | break; |
1156 | break; |
1032 | case P1_PIO_OFF: |
1157 | case P1_PIO_OFF: |
- | 1158 | # ifdef NPIO |
|
- | 1159 | dum=0x0; |
|
- | 1160 | CSSA_W(NPIO, 0, 16, &dum); |
|
- | 1161 | printf("PIO VETO OFF\n"); |
|
- | 1162 | # endif |
|
- | 1163 | break; |
|
- | 1164 | case P1_PIO_PULSE: |
|
1033 | # ifdef NPIO |
1165 | # ifdef NPIO |
- | 1166 | dum=0x1; |
|
- | 1167 | CSSA_W(NPIO, 0, 16, &dum); |
|
- | 1168 | Delay(0.001); |
|
1034 | dum=0x0; |
1169 | dum=0x0; |
1035 | CSSA_W(NPIO, 0, 16, &dum); |
1170 | CSSA_W(NPIO, 0, 16, &dum); |
1036 | printf("PIO VETO OFF\n"); |
- | |
1037 | # endif |
1171 | # endif |
1038 | break; |
1172 | break; |
1039 | case P1_TDCCLEAR: |
1173 | case P1_TDCCLEAR: |
1040 | #ifdef USE_CAEN_TDC |
1174 | #ifdef USE_CAEN_TDC |
1041 | dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1014, &dum16); Delay(0.1); |
1175 | dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1014, &dum16); Delay(0.1); |
1042 | dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum16); Delay(0.1); |
1176 | dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum16); Delay(0.1); |
1043 | dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1018, &dum16); Delay(0.1); |
1177 | dum16=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1018, &dum16); Delay(0.1); |
1044 | #endif |
1178 | #endif |
1045 | break; |
1179 | break; |
1046 | case P1_TDCMIKRO: |
1180 | case P1_TDCMIKRO: |
1047 | #ifdef USE_CAEN_TDC |
1181 | #ifdef USE_CAEN_TDC |
1048 | dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR + 0x1030, &dum); Delay(0.01); printf("Micro handshake = %x\n", dum); |
1182 | dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR + 0x1030, &dum); Delay(0.01); printf("Micro handshake = %x\n", dum); |
1049 | #endif |
1183 | #endif |
1050 | break; |
1184 | break; |
1051 | case P1_TDCINIT: |
1185 | case P1_TDCINIT: |
1052 | 1186 | ||
1053 | #ifdef USE_CAEN_TDC |
1187 | #ifdef USE_CAEN_TDC |
1054 |
|
1188 | V1290_init(); |
- | 1189 | V1290_readConfig(); |
|
1055 | 1190 | /* |
|
1056 | ////Maximum number of hits per event |
1191 | ////Maximum number of hits per event |
1057 | printf("V1290_writeOC(0x3300)\n"); |
- | |
1058 |
|
1192 | printf("V1290_writeOC(0x3300)\n"); dum=0x3300; V1290_writeOC(&dum); Delay(0.1); |
1059 | //dum=0x0001; V1290_writeOC(&dum); Delay(0.1); |
- | |
1060 | printf("V1290_writeOC(0x1000)\n"); |
- | |
1061 |
|
1193 | printf("V1290_writeOC(0x1000)\n"); dum= 8; V1290_writeOC(&dum); Delay(0.1); |
1062 | printf("V1290_writeOC(0x3400)\n"); |
- | |
1063 |
|
1194 | printf("V1290_writeOC(0x3400)\n"); dum=0x3400; V1290_writeOC(&dum); Delay(0.1); |
1064 | dum=0x0; |
1195 | dum=0x0; |
1065 | printf("V1290_readOC()\n"); |
1196 | printf("V1290_readOC()\n"); |
1066 | if(V1290_readOC(&dum) == -1) |
1197 | if(V1290_readOC(&dum) == -1) |
1067 | printf("V1290_readOC timeout!!!\n"); |
1198 | printf("V1290_readOC timeout!!!\n"); |
1068 | else { |
1199 | else { |
1069 | Delay(0.1); |
1200 | Delay(0.1); |
1070 | printf("TDC Maximum number of hits per event = %d\n", dum); |
1201 | printf("TDC Maximum number of hits per event = %d\n", dum); |
1071 | } |
1202 | } |
1072 | 1203 | */ |
|
1073 | #endif |
1204 | #endif |
1074 | break; |
1205 | break; |
1075 | case P1_TDCTEST: |
1206 | case P1_TDCTEST: |
1076 | 1207 | ||
1077 | #ifdef USE_CAEN_TDC |
1208 | #ifdef USE_CAEN_TDC |
- | 1209 | V1290_readConfig(); |
|
- | 1210 | ||
1078 | /* |
1211 | /* |
1079 | for (i=0x4000;i<0x4050;i+=4) { |
1212 | for (i=0x4000;i<0x4050;i+=4) { |
1080 | dum=0; |
1213 | dum=0; |
1081 | WIENVME_VME_A24D16_R(TDC_ADDR+i, &dum); |
1214 | WIENVME_VME_A24D16_R(TDC_ADDR+i, &dum); |
1082 | printf("0x%04X -> 0x%04X\n",i,dum); |
1215 | printf("0x%04X -> 0x%04X\n",i,dum); |
1083 | } |
1216 | } |
Line 1092... | Line 1225... | ||
1092 | |
1225 | |
1093 | 1226 | ||
1094 | dum=0x0200; V1290_writeOC(&dum); |
1227 | dum=0x0200; V1290_writeOC(&dum); |
1095 | dum=0x0; V1290_readOC(&dum); printf("dum = %04X\n", dum&0xFFFF); |
1228 | dum=0x0; V1290_readOC(&dum); printf("dum = %04X\n", dum&0xFFFF); |
1096 | */ |
1229 | */ |
1097 | - | ||
1098 | dum=0x4500; V1290_writeOC(&dum); |
- | |
1099 | dum=0x0; V1290_readOC(&dum); printf("Ch Enable 1 = %04X\n", dum&0xFFFF); |
- | |
1100 | dum=0x0; V1290_readOC(&dum); printf("Ch Enable 2 = %04X\n", dum&0xFFFF); |
- | |
1101 | - | ||
1102 | - | ||
1103 | dum=0x1600; V1290_writeOC(&dum); |
- | |
1104 | dum=0x0000; V1290_readOC(&dum); printf("Match window Width = %d\n", dum&0xFFFF); |
- | |
1105 | dum=0x0000; V1290_readOC(&dum); printf("Window Offset = %d\n", dum&0xFFFF); |
- | |
1106 | dum=0x0000; V1290_readOC(&dum); printf("Extra Search Window = %d\n", dum&0xFFFF); |
- | |
1107 | dum=0x0000; V1290_readOC(&dum); printf("Reject Margin = %d\n", dum&0xFFFF); |
- | |
1108 | dum=0x0000; V1290_readOC(&dum); printf("Trigger Subtraction = %d\n", dum&0xFFFF); |
- | |
1109 | - | ||
1110 | - | ||
1111 | dum=0x3400; V1290_writeOC(&dum); |
- | |
1112 | dum=0x0000; V1290_readOC(&dum); printf("TDC Maximum number of hits per event = %d\n", dum); |
- | |
1113 | 1230 | ||
1114 | 1231 | ||
1115 | /* |
1232 | /* |
1116 | // test |
1233 | // test |
1117 | |
1234 | |
Line 1131... | Line 1248... | ||
1131 | printf("tdcneve = %d | triggneve = %u\n", tdcneve, triggneve); |
1248 | printf("tdcneve = %d | triggneve = %u\n", tdcneve, triggneve); |
1132 | |
1249 | |
1133 | dum=0x4500; V1290_writeOC(&dum); |
1250 | dum=0x4500; V1290_writeOC(&dum); |
1134 | dum=0x0; V1290_readOC(&dum); printf("Channel enable mask word 1 = %x\n", dum); |
1251 | dum=0x0; V1290_readOC(&dum); printf("Channel enable mask word 1 = %x\n", dum); |
1135 | dum=0x0; V1290_readOC(&dum); printf("Channel enable mask word 2 = %x\n", dum); |
1252 | dum=0x0; V1290_readOC(&dum); printf("Channel enable mask word 2 = %x\n", dum); |
1136 | |
1253 | |
1137 | //dum=0x4500; WIENVME_VME_A24D16_W(TDC_ADDR+0x102E, &dum); Delay(0.1); |
1254 | //dum=0x4500; WIENVME_VME_A24D16_W(TDC_ADDR+0x102E, &dum); Delay(0.1); |
1138 | //dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR+0x102E, &dum); Delay(0.1); printf("Channel enable mask word 1 = %x\n", dum); |
1255 | //dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR+0x102E, &dum); Delay(0.1); printf("Channel enable mask word 1 = %x\n", dum); |
1139 | //dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR+0x102E, &dum); Delay(0.1); printf("Channel enable mask word 2 = %x\n", dum); |
1256 | //dum=0x0000; WIENVME_VME_A24D16_R(TDC_ADDR+0x102E, &dum); Delay(0.1); printf("Channel enable mask word 2 = %x\n", dum); |
1140 | |
1257 | |
1141 | */ |
1258 | */ |
Line 1162... | Line 1279... | ||
1162 | 1279 | ||
1163 | #endif |
1280 | #endif |
1164 | break; |
1281 | break; |
1165 | #ifdef USE_EASIROC |
1282 | #ifdef USE_EASIROC |
1166 | case P1_ESRC_INIT: |
1283 | case P1_ESRC_INIT: |
- | 1284 | easiroc_LoadIni("EASIROCini\\EASIROC.ini"); |
|
1167 | easiroc_Init(erIpAddr, erDAQmode); |
1285 | easiroc_Init(erIpAddr, erDAQmode); |
1168 | break; |
1286 | break; |
- | 1287 | ||
- | 1288 | case P1_ESRC_LOAD_INI: |
|
- | 1289 | char iniFileBuff[MAX_PATHNAME_LEN]; |
|
- | 1290 | if( 0 < FileSelectPopupEx ("", "*.ini", "*.ini;*.*", "EASIROC ini file", VAL_LOAD_BUTTON, 0, 0, iniFileBuff) ) { |
|
- | 1291 | printf("Loading ini file %s\n", iniFileBuff); |
|
- | 1292 | if( !easiroc_LoadIni(iniFileBuff) ) { |
|
- | 1293 | printf("Error loading Ini file %s!!!\n", iniFileBuff); |
|
- | 1294 | } |
|
- | 1295 | } |
|
- | 1296 | break; |
|
- | 1297 | ||
1169 | 1298 | ||
1170 | case P1_ESRC_F1: |
1299 | case P1_ESRC_F1: |
1171 | easiroc_fTransmitSC(); |
1300 | easiroc_fTransmitSC(); |
1172 | break; |
1301 | break; |
1173 | 1302 | ||
Line 1193... | Line 1322... | ||
1193 | case P1_ESRC_DAQ: |
1322 | case P1_ESRC_DAQ: |
1194 | char esrcDaqFile[256]; |
1323 | char esrcDaqFile[256]; |
1195 | GetCtrlVal (p1h, P1_DFILE, esrcDaqFile); |
1324 | GetCtrlVal (p1h, P1_DFILE, esrcDaqFile); |
1196 | int esrcDaqNeve = 0; |
1325 | int esrcDaqNeve = 0; |
1197 | GetCtrlVal (p1h, P1_NEVE, &esrcDaqNeve); |
1326 | GetCtrlVal (p1h, P1_NEVE, &esrcDaqNeve); |
1198 | 1327 | ||
1199 | if(easiroc_fDAQ(esrcDaqFile, esrcDaqNeve) == 0) |
1328 | if(easiroc_fDAQ(esrcDaqFile, esrcDaqNeve) == 0) |
1200 | printf("\nEASIROC DAQ SUCESS\n"); |
1329 | printf("\nEASIROC DAQ SUCESS\n"); |
- | 1330 | break; |
|
- | 1331 | ||
- | 1332 | case P1_ESRC_ADC_START: |
|
- | 1333 | easiroc_singleADCstart(); |
|
- | 1334 | break; |
|
- | 1335 | case P1_ESRC_ADC_EVENT: |
|
- | 1336 | int esrcADCreturn = 0; |
|
- | 1337 | esrcADCreturn = easiroc_singleADCevent(esrcdata); |
|
- | 1338 | printf("esrcADCreturn = %d\n", esrcADCreturn); |
|
- | 1339 | for(int iw=0; iw<esrcADCreturn; iw++) printf("[%d] 0x%x ", iw, esrcdata[iw]); |
|
- | 1340 | printf("\n"); |
|
- | 1341 | break; |
|
- | 1342 | case P1_ESRC_ADC_STOP: |
|
- | 1343 | easiroc_singleADCstop(); |
|
1201 | break; |
1344 | break; |
1202 | 1345 | ||
1203 | case P1_ESRC_CLOSE: |
1346 | case P1_ESRC_CLOSE: |
1204 | easiroc_Close(); |
1347 | easiroc_Close(); |
1205 | break; |
1348 | break; |
Line 1275... | Line 1418... | ||
1275 | //printf("V1290_writeOC wait_count = %d | read_buffer = %x\n", wait_count, read_buffer); |
1418 | //printf("V1290_writeOC wait_count = %d | read_buffer = %x\n", wait_count, read_buffer); |
1276 | if(100 < wait_count++) |
1419 | if(100 < wait_count++) |
1277 | return -1; |
1420 | return -1; |
1278 | 1421 | ||
1279 | } while (!(read_buffer & 0x1)); |
1422 | } while (!(read_buffer & 0x1)); |
1280 | 1423 | ||
1281 | // Micro Register |
1424 | // Micro Register |
1282 | WIENVME_VME_A24D16_W(TDC_ADDR + 0x102E, write_buffer); |
1425 | WIENVME_VME_A24D16_W(TDC_ADDR + 0x102E, write_buffer); |
1283 | 1426 | ||
1284 | return 0; |
1427 | return 0; |
1285 | } |
1428 | } |
1286 | /* ****************** CAEN V1290 TDC Read OPCODE ****************** */ |
1429 | /* ****************** CAEN V1290 TDC Read OPCODE ****************** */ |
Line 1307... | Line 1450... | ||
1307 | /* ****************** ******************************************* */ |
1450 | /* ****************** ******************************************* */ |
1308 | void V1290_init() |
1451 | void V1290_init() |
1309 | { |
1452 | { |
1310 | int dum; |
1453 | int dum; |
1311 | // intialization |
1454 | // intialization |
- | 1455 | printf("V1290_init()."); |
|
1312 | 1456 | ||
1313 | dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1014, &dum); Delay(0.1); |
1457 | dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1014, &dum); Delay(0.1); printf("."); |
1314 | dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); Delay(0.1); |
1458 | dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1016, &dum); Delay(0.1); printf("."); |
1315 | dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1018, &dum); Delay(0.1); |
1459 | dum=0x0; WIENVME_VME_A24D16_W(TDC_ADDR+0x1018, &dum); Delay(0.1); printf("."); |
1316 | 1460 | ||
1317 | //Trigger matching |
1461 | //Trigger matching |
1318 | dum=0x0000; V1290_writeOC(&dum); |
1462 | dum=0x0000; V1290_writeOC(&dum); |
1319 | 1463 | /* |
|
- | 1464 | // window precedes trigger |
|
1320 |
|
1465 | // Constraints: tdc_window < |tdc_offset| <= 4095 |
1321 | // Largest window: 4095-margin; |
1466 | // Largest window: 4095-margin; |
1322 |
|
1467 | // units: clock cycles = 25 ns |
1323 | int tdc_margin = 0; |
1468 | int tdc_margin = 0; |
1324 |
|
1469 | int tdc_offset = 40; //negative, see below! |
1325 | int tdc_window = tdc_offset - tdc_margin; |
1470 | int tdc_window = tdc_offset - tdc_margin; |
1326 | 1471 | |
|
- | 1472 | // window straddles trigger |
|
- | 1473 | // Constraints: tdc_window + tdc_offset <= 40 |
|
- | 1474 | // units: clock cycles = 25 ns |
|
- | 1475 | int tdc_margin = 8; |
|
- | 1476 | int tdc_offset = 10; //negative, see below! |
|
- | 1477 | int tdc_window = 32; |
|
- | 1478 | */ |
|
1327 | //set window width |
1479 | //set window width |
1328 | dum=0x1000; V1290_writeOC(&dum); |
1480 | dum=0x1000; V1290_writeOC(&dum); |
1329 |
|
1481 | GetCtrlVal(p1h, P1_TDC_WINDOW, &dum); V1290_writeOC(&dum); |
1330 | //set window offset |
1482 | //set window offset |
1331 | dum=0x1100; V1290_writeOC(&dum); |
1483 | dum=0x1100; V1290_writeOC(&dum); |
1332 |
|
1484 | GetCtrlVal(p1h, P1_TDC_OFFSET, &dum); V1290_writeOC(&dum); |
1333 | //set extra search margin |
1485 | //set extra search margin |
1334 | dum=0x1200; V1290_writeOC(&dum); |
1486 | dum=0x1200; V1290_writeOC(&dum); |
1335 |
|
1487 | GetCtrlVal(p1h, P1_TDC_MARGIN, &dum); V1290_writeOC(&dum); |
1336 | 1488 | ||
- | 1489 | printf("."); |
|
- | 1490 | ||
1337 | //enable all channels |
1491 | //enable all channels |
1338 | dum=0x4200; V1290_writeOC(&dum); |
1492 | dum=0x4200; V1290_writeOC(&dum); |
1339 | //disable all channels |
1493 | //disable all channels |
1340 | //dum=0x4300; V1290_writeOC(&dum); |
1494 | //dum=0x4300; V1290_writeOC(&dum); |
1341 | //enable first NCH_TDC channels |
1495 | //enable first NCH_TDC channels |
Line 1349... | Line 1503... | ||
1349 | // if(tdcmap[i]<32) |
1503 | // if(tdcmap[i]<32) |
1350 | // { |
1504 | // { |
1351 | // dum=0x4000 + i; |
1505 | // dum=0x4000 + i; |
1352 | // V1290_writeOC(&dum); |
1506 | // V1290_writeOC(&dum); |
1353 | // } |
1507 | // } |
- | 1508 | //disable channels |
|
- | 1509 | //for(int i=0;i<1;i++) {dum=0x4100 + i; V1290_writeOC(&dum);} |
|
1354 | 1510 | ||
1355 | //enable(0x30xx)/disable(0x31xx) TDC Header and Trailer |
1511 | //enable(0x30xx)/disable(0x31xx) TDC Header and Trailer |
1356 | dum=0x3100; V1290_writeOC(&dum); |
1512 | dum=0x3100; V1290_writeOC(&dum); |
1357 | /* |
1513 | /* |
1358 | ////Maximum number of hits per event (does not work for unknown reason, sets to 0!) |
1514 | ////Maximum number of hits per event (does not work for unknown reason, sets to 0!) |
Line 1360... | Line 1516... | ||
1360 | //dum=0x0001; V1290_writeOC(&dum); |
1516 | //dum=0x0001; V1290_writeOC(&dum); |
1361 | dum=0x1000; V1290_writeOC(&dum); |
1517 | dum=0x1000; V1290_writeOC(&dum); |
1362 | */ |
1518 | */ |
1363 | dum=0x3400; V1290_writeOC(&dum); |
1519 | dum=0x3400; V1290_writeOC(&dum); |
1364 | dum=0x0000; V1290_readOC(&dum); |
1520 | dum=0x0000; V1290_readOC(&dum); |
1365 |
|
1521 | //printf("TDC Maximum number of hits per event = %d\n", dum); |
- | 1522 | printf("."); |
|
1366 | 1523 | ||
1367 | //pair(00)/trailing(01)/leading(10)/both(11) edge |
1524 | //pair(00)/trailing(01)/leading(10)/both(11) edge |
1368 | dum=0x2200; V1290_writeOC(&dum); |
1525 | dum=0x2200; V1290_writeOC(&dum); |
1369 |
|
1526 | GetCtrlVal(p1h, P1_TDC_EDGE, &dum); V1290_writeOC(&dum); |
1370 | 1527 | ||
1371 | //enable(0x14xx)/disable(0x15xx) substraction of trigger time |
1528 | //enable(0x14xx)/disable(0x15xx) substraction of trigger time |
1372 | dum=0x1400; V1290_writeOC(&dum); |
1529 | dum=0x1400; V1290_writeOC(&dum); |
- | 1530 | printf(".Done\n"); |
|
1373 | } |
1531 | } |
- | 1532 | /* ****************** ******************************************* */ |
|
- | 1533 | void V1290_readConfig() |
|
- | 1534 | { |
|
- | 1535 | int dum; |
|
- | 1536 | dum=0x4500; V1290_writeOC(&dum); |
|
- | 1537 | dum=0x0; V1290_readOC(&dum); printf("Ch Enable 1 = %04X\n", dum&0xFFFF); |
|
- | 1538 | dum=0x0; V1290_readOC(&dum); printf("Ch Enable 2 = %04X\n", dum&0xFFFF); |
|
- | 1539 | ||
- | 1540 | ||
- | 1541 | dum=0x1600; V1290_writeOC(&dum); |
|
- | 1542 | dum=0x0000; V1290_readOC(&dum); printf("Match window Width = %d\n", dum&0xFFFF); |
|
- | 1543 | dum=0x0000; V1290_readOC(&dum); printf("Window Offset = %d\n", dum&0xFFFF); |
|
- | 1544 | dum=0x0000; V1290_readOC(&dum); printf("Extra Search Window = %d\n", dum&0xFFFF); |
|
- | 1545 | dum=0x0000; V1290_readOC(&dum); printf("Reject Margin = %d\n", dum&0xFFFF); |
|
- | 1546 | dum=0x0000; V1290_readOC(&dum); printf("Trigger Subtraction = %d\n", dum&0xFFFF); |
|
- | 1547 | ||
- | 1548 | ||
- | 1549 | dum=0x3400; V1290_writeOC(&dum); |
|
- | 1550 | dum=0x0000; V1290_readOC(&dum); printf("TDC Maximum number of hits per event = %d\n", dum); |
|
- | 1551 | ||
- | 1552 | dum=0x2300; V1290_writeOC(&dum); |
|
- | 1553 | dum=0x0000; V1290_readOC(&dum); printf("TDC Edge type = %d\n", dum); |
|
- | 1554 | ||
- | 1555 | dum=0x2600; V1290_writeOC(&dum); |
|
- | 1556 | dum=0x0000; V1290_readOC(&dum); printf("TDC resolution= %d\n", dum); |
|
- | 1557 | } |
|
- | 1558 | ||
1374 | #endif |
1559 | #endif |
1375 | /* ****** vrne (INT!) max vrednost iz arraya od elementa do elementa ****** */ |
1560 | /* ****** vrne (INT!) max vrednost iz arraya od elementa do elementa ****** */ |
1376 | int max_from(int* array, int ifrom, int ito) |
1561 | int max_from(int* array, int ifrom, int ito) |
1377 | { |
1562 | { |
1378 | int i; |
1563 | int i; |