Go to the source code of this file.
#define V1729_1GSPS (DWORD) 2 |
#define V1729_2GSPS (DWORD) 1 |
#define V1729_ACQ_START_W (DWORD) (0x1700) |
#define V1729_ALL_FOUR (DWORD) (0xF) |
#define V1729_AUTHORIZE_RANDOM (DWORD) (0x8) |
#define V1729_CHANMASK (DWORD) (0x2300) |
#define V1729_DATA_FIFO_R (DWORD) (0x0D00) |
Definition at line 52 of file v1729.h.
Referenced by v1729_DataRead(), and v1729_TimeCalibrationRun().
#define V1729_EXTERNAL_TRIGGER (DWORD) (0x2) |
#define V1729_FAST_READ_MODES (DWORD) (0x2100) |
#define V1729_FRQ_SAMPLING (DWORD) (0x8100) |
#define V1729_INHIBIT_RANDOM (DWORD) (0x0) |
#define V1729_INTERRUPT_ENABLE (DWORD) (0x8300) |
#define V1729_INTERRUPT_REG (DWORD) (0x8000) |
#define V1729_MAX_CHANNEL_SIZE (DWORD) 2560 |
Definition at line 22 of file v1729.h.
Referenced by v1729_DataRead(), v1729_OrderData(), and v1729_PedestalRun().
#define V1729_MAX_CHANNELS (DWORD) 4 |
#define V1729_N_COL (DWORD) (0x2200) |
Definition at line 55 of file v1729.h.
Referenced by v1729_NColsGet(), v1729_NColsSet(), and v1729_Status().
#define V1729_NORMAL_TRIGGER (DWORD) (0x0) |
#define V1729_POSTTRIG_LSB (DWORD) (0x1A00) |
Definition at line 27 of file v1729.h.
Referenced by v1729_OrderData(), v1729_PedestalRun(), v1729_PostTrigSet(), and v1729_Status().
#define V1729_POSTTRIG_MSB (DWORD) (0x1B00) |
Definition at line 28 of file v1729.h.
Referenced by v1729_OrderData(), v1729_PedestalRun(), v1729_PostTrigSet(), and v1729_Status().
#define V1729_PRETRIG_LSB (DWORD) (0x1800) |
#define V1729_PRETRIG_MSB (DWORD) (0x1900) |
#define V1729_RAM_SIZE (DWORD) (4*2563) |
#define V1729_RESET_W (DWORD) (0x0800) |
#define V1729_RISING_EDGE (DWORD) (0x0) |
#define V1729_SOFT_TRIGGER (DWORD) (0x0) |
#define V1729_SOFT_TRIGGER_W (DWORD) (0x1C00) |
#define V1729_SUCCESS 1 |
#define V1729_TRIGCHAN (DWORD) (0x1E00) |
#define V1729_TRIGREC_R (DWORD) (0x2000) |
#define V1729_TRIGTYPE (DWORD) (0x1D00) |
#define V1729_VERSION_R (DWORD) (0x8200) |
void v1729_AcqStart | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 29 of file v1729.c.
Referenced by v1729_PedestalRun(), and v1729_TimeCalibrationRun().
00030 { 00031 int cmode; 00032 00033 mvme_get_dmode(mvme, &cmode); 00034 mvme_set_dmode(mvme, MVME_DMODE_D16); 00035 mvme_write_value(mvme, base+V1729_INTERRUPT_REG, 0); 00036 mvme_write_value(mvme, base+V1729_ACQ_START_W, 0); 00037 mvme_set_dmode(mvme, cmode); 00038 }
void v1729_ChannelSelect | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | value | |||
) |
Definition at line 276 of file v1729.c.
Referenced by v1729_Setup().
00277 { 00278 int cmode; 00279 00280 mvme_get_dmode(mvme, &cmode); 00281 mvme_set_dmode(mvme, MVME_DMODE_D16); 00282 mvme_write_value(mvme, base+V1729_TRIGCHAN, value&0xF); 00283 mvme_set_dmode(mvme, cmode); 00284 }
void v1729_DataRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD * | pdest, | |||
int | nch, | |||
int | npt | |||
) |
Definition at line 183 of file v1729.c.
Referenced by v1729_PedestalRun().
00184 { 00185 int cmode, i, rdlen; 00186 00187 mvme_get_dmode(mvme, &cmode); 00188 mvme_set_dmode(mvme, MVME_DMODE_D16); 00189 if (nch>V1729_MAX_CHANNELS) nch = V1729_MAX_CHANNELS; 00190 if (npt>V1729_MAX_CHANNEL_SIZE) npt = V1729_MAX_CHANNEL_SIZE; 00191 rdlen = nch * (npt+3); 00192 00193 00194 for (i=0 ; i < rdlen ; i++) { 00195 pdest[i] = (int) mvme_read_value(mvme, base+V1729_DATA_FIFO_R); 00196 } 00197 00198 00199 // mvme_read(mvme, pdest, base+V1729_DATA_FIFO_R, rdlen*2); 00200 00201 get_ref = 1; 00202 mvme_set_dmode(mvme, cmode); 00203 }
void v1729_FrqSamplingSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | value | |||
) |
Definition at line 298 of file v1729.c.
Referenced by v1729_Setup().
00299 { 00300 int cmode; 00301 00302 mvme_get_dmode(mvme, &cmode); 00303 mvme_set_dmode(mvme, MVME_DMODE_D16); 00304 if (value < 0) value = 1; 00305 if (value > 2) value = 2; 00306 mvme_write_value(mvme, base+V1729_FRQ_SAMPLING, value); 00307 mvme_set_dmode(mvme, cmode); 00308 }
int v1729_isTrigger | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 206 of file v1729.c.
Referenced by v1729_PedestalRun(), and v1729_TimeCalibrationRun().
00207 { 00208 int cmode, done; 00209 00210 mvme_get_dmode(mvme, &cmode); 00211 mvme_set_dmode(mvme, MVME_DMODE_D16); 00212 done = mvme_read_value(mvme, base+V1729_INTERRUPT_REG); 00213 mvme_set_dmode(mvme, cmode); 00214 return (done & 0xFF); 00215 }
int v1729_NColsGet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 264 of file v1729.c.
Referenced by v1729_OrderData(), and v1729_Status().
00265 { 00266 int cmode, value; 00267 00268 mvme_get_dmode(mvme, &cmode); 00269 mvme_set_dmode(mvme, MVME_DMODE_D16); 00270 value = mvme_read_value(mvme, base+V1729_N_COL); 00271 mvme_set_dmode(mvme, cmode); 00272 return (value & 0xFF); 00273 }
void v1729_NColsSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | value | |||
) |
Definition at line 253 of file v1729.c.
Referenced by v1729_Setup().
00254 { 00255 int cmode; 00256 00257 mvme_get_dmode(mvme, &cmode); 00258 mvme_set_dmode(mvme, MVME_DMODE_D16); 00259 mvme_write_value(mvme, base+V1729_N_COL, value & 0xFF); 00260 mvme_set_dmode(mvme, cmode); 00261 }
int v1729_OrderData | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD * | srce, | |||
int * | dest, | |||
int | nch, | |||
int | chan, | |||
int | npt | |||
) |
Re-order given channel from srce to dest len is for now frozen to V1729_MAX_CHANNEL_SIZE Does pedestal subtraction if enabled (ped_ok) Doesn't correct for timing.
NOTE: destination cell index[k] computed as 2560+j+end_cell instead of manual formula [2] page 13 (2560+j-end_cell).
Definition at line 595 of file v1729.c.
00596 { 00597 int i, j, k; 00598 WORD value, value1; 00599 int cmode, temp, rdlen; 00600 00601 if (get_ref) { 00602 // Set dmode to D16 00603 mvme_get_dmode(mvme, &cmode); 00604 mvme_set_dmode(mvme, MVME_DMODE_D16); 00605 00606 value = mvme_read_value(mvme, base+V1729_POSTTRIG_LSB); 00607 value1 = mvme_read_value(mvme, base+V1729_POSTTRIG_MSB); 00608 post_trig = ((value1 & 0xFF)<<8) | (value & 0xFF); 00609 ncol = v1729_NColsGet(mvme, base); 00610 Corr_vernier[3] = (float) (srce[4] - lMINVER) / (float) (lMAXVER - lMINVER); 00611 Corr_vernier[2] = (float) (srce[5] - lMINVER) / (float) (lMAXVER - lMINVER); 00612 Corr_vernier[1] = (float) (srce[6] - lMINVER) / (float) (lMAXVER - lMINVER); 00613 Corr_vernier[0] = (float) (srce[7] - lMINVER) / (float) (lMAXVER - lMINVER); 00614 trig_rec = mvme_read_value(mvme, base+V1729_TRIGREC_R); 00615 trig_rec &= 0xFF; 00616 //end_cell = (20 * ((post_trig + trig_rec) % ncol)); 00617 end_cell = (20 * ((post_trig + trig_rec) % 2560)); 00618 get_ref = 0; 00619 00620 //printf("posttrig %d, trigrec %d, endcell %d\n", post_trig, trig_rec, end_cell); 00621 } 00622 00623 if (nch>V1729_MAX_CHANNELS) nch = V1729_MAX_CHANNELS; 00624 if (npt>V1729_MAX_CHANNEL_SIZE) npt = V1729_MAX_CHANNEL_SIZE; 00625 rdlen = nch * (npt+3); 00626 00627 if (nch == 4) { // 0-1-2/3-4-5/6-7-8 start=9>2, 10>1, 11>0 00628 for (i=12+3-chan, j=0; i < rdlen; i+=nch, j++) { 00629 temp = ((int) srce[i] - pedestals[i]); 00630 k = (20*ncol + j + end_cell) % (20*ncol); 00631 dest[k] = temp; 00632 } 00633 } else if (nch == 3) { // 0-1-2/3-4-5/6-7-8 start=9>2, 10>1, 11>0 00634 for (i=9+2-chan, j=0; i < rdlen; i+=nch, j++) { 00635 temp = ((int) srce[i] - pedestals[i]); 00636 k = ((20*ncol) + j + end_cell) % (20*ncol); 00637 dest[k] = temp; 00638 } 00639 } else if (nch == 2) { // 0-1/2-3/4-5 start=6>1, 7>0 00640 for (i=6+1-chan, j=0; i < rdlen; i+=nch, j++) { 00641 temp = ((int) srce[i] - pedestals[i]); 00642 k = ((20*ncol) + j + end_cell) % (20*ncol); 00643 dest[k] = temp; 00644 } 00645 } else if (nch == 1) { // 0/1/2 start=3>0 00646 for (i=3-chan, j=0; i < rdlen; i+=nch, j++) { 00647 //temp = ((int) srce[i] - (ped_ok ? (int) ped[chan][3+j] : 0)); 00648 temp = ((int) srce[i] - pedestals[i]); 00649 k = ((20*ncol) + j + end_cell) % (20*ncol); 00650 dest[k] = temp; 00651 } 00652 } 00653 00654 /* 00655 if (debug) { 00656 for (i=0;i<V1729_MAX_CHANNEL_SIZE;i++) { 00657 printf("dest[%i] = %d\n", i, dest[i]); 00658 } 00659 } 00660 printf("First sample %d %d %d %d\n", srce[0], srce[1], srce[2], srce[3]); 00661 printf("Vernier %d %d %d %d\n", srce[4], srce[5], srce[6], srce[7]); 00662 printf("Reset Baseline %d %d %d %d\n", srce[8], srce[9], srce[10], srce[11]); 00663 printf("Value:%d Value1:%d\n", value, value1); 00664 printf("Post trig:%d - Trig rec:%d(C:%d) - End_cell:%d(%d)\n" 00665 , post_trig, trig_rec, 128-trig_rec, end_cell, end_cell/20); 00666 printf("Cvernier %f %f %f %f\n", Corr_vernier[0], Corr_vernier[1] 00667 , Corr_vernier[2], Corr_vernier[3]); 00668 */ 00669 00670 mvme_set_dmode(mvme, cmode); 00671 return 0; 00672 }
int v1729_PedestalRun | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | loop, | |||
int | flag | |||
) |
Pedestal extraction. Requires to module to be in setup mode 7 (soft trigger). Show major improvment in the WF reconstruction, but still has 20 bin periodic spikes.
Code not yet guarantee to be fully correct...
Definition at line 426 of file v1729.c.
00427 { 00428 int cmode; 00429 // int i_bar=0; 00430 // char bars[] = "|\\-/"; 00431 WORD data[V1729_RAM_SIZE]; 00432 int i, l; 00433 int xloop; 00434 int stuck_trig_rec = -1; 00435 FILE *fH=NULL; 00436 00437 memset(pedestals, 0, sizeof(pedestals)); 00438 00439 mvme_get_dmode(mvme, &cmode); 00440 mvme_set_dmode(mvme, MVME_DMODE_D16); 00441 00442 // Set Trigger type Soft trigger 00443 v1729_Setup(mvme, base, 7); 00444 00445 // give it time to settle... 00446 sleep(2); 00447 00448 if (flag) { 00449 fH = fopen("pedestals.txt", "w"); 00450 if (fH == NULL) { 00451 printf("File not open\n"); 00452 } 00453 printf("\npedestals.txt file opened\n"); 00454 } 00455 00456 for (xloop=0; xloop<2; xloop++) { 00457 // loop twice: first pass: accept all data, second pass: 00458 // reject data too far away from the mean 00459 int countWide = 0; 00460 00461 static double sum0[V1729_RAM_SIZE]; 00462 static double sum1[V1729_RAM_SIZE]; 00463 static double sum2[V1729_RAM_SIZE]; 00464 00465 memset(sum0, 0, sizeof(sum0)); 00466 memset(sum1, 0, sizeof(sum1)); 00467 memset(sum2, 0, sizeof(sum2)); 00468 00469 for (l=0;l<loop;l++) { 00470 // Start ACQ 00471 v1729_AcqStart(mvme, base); 00472 00473 usleep(20000); 00474 00475 // Generate soft Trigger 00476 v1729_SoftTrigger(mvme, base); 00477 00478 // Wait for trigger 00479 while(1) { 00480 00481 int t = v1729_isTrigger(mvme, base); 00482 //printf("trigger %d\n", t); 00483 if (t == 255) 00484 break; 00485 00486 usleep(10); 00487 }; 00488 00489 v1729_DataRead(mvme, base, data, 4, V1729_MAX_CHANNEL_SIZE); 00490 00491 { 00492 int oldi; 00493 int post_trig = (mvme_read_value(mvme, base+V1729_POSTTRIG_LSB) & 0xFF) 00494 | ((mvme_read_value(mvme, base+V1729_POSTTRIG_MSB) & 0xFF) << 8); 00495 int trig_rec = mvme_read_value(mvme, base+V1729_TRIGREC_R) & 0xFF; 00496 00497 int end_cell = 20*(post_trig - trig_rec) % 128; 00498 00499 if (stuck_trig_rec >= 0) 00500 if (trig_rec == stuck_trig_rec) 00501 fprintf(stderr,"v1729 at 0x%x: Warning: TRIG_REC is stuck at 0x%x\n", base, trig_rec); 00502 stuck_trig_rec = trig_rec; 00503 00504 if (flag) fprintf(fH, "Loop:%d posttrig %d, trigrec %d, endcell %d\n", l, post_trig, trig_rec, end_cell); 00505 00506 for (oldi=0; oldi<V1729_RAM_SIZE; oldi++) 00507 { 00508 int newi = (2560 + oldi - end_cell) % 2560; 00509 00510 //i = newi; 00511 i = oldi; 00512 newi = i; 00513 00514 if (flag) fprintf(fH, "Loop:%d data[%i] = %d\n", l, i, data[i]); 00515 00516 if ((xloop==0) || (fabs(data[i] - pedestals[newi]) < 2+5*pedestalsRms[newi])) 00517 { 00518 sum0[newi] += 1; 00519 sum1[newi] += data[i]; 00520 sum2[newi] += data[i]*data[i]; 00521 } 00522 } 00523 } 00524 } 00525 00526 for (i=0;i<V1729_RAM_SIZE;i++) { 00527 double mean = sum1[i]/sum0[i]; 00528 double var = sum2[i]/sum0[i] - mean*mean; 00529 double rms = 0; 00530 00531 if (sum0[i] < 3) { 00532 printf("Pedestal shifted, memory address %5d\n", i); 00533 mean = 0; 00534 var = 0; 00535 } 00536 00537 if (var > 0) 00538 rms = sqrt(var); 00539 pedestals[i] = mean; 00540 pedestalsRms[i] = rms; 00541 00542 if (rms > 20) { 00543 countWide ++; 00544 printf("Wide pedestals, memory address %5d, mean: %8.1f, rms: %6.1f\n", i, mean, rms); 00545 } 00546 00547 } 00548 00549 printf("Found %d wide pedestals\n", countWide); 00550 00551 if (flag) 00552 for (i=0;i<V1729_RAM_SIZE;i++) { 00553 fprintf(fH, "Loop:%d Pedestals[%i] = %f, rms: %f\n", l, i, pedestals[i], pedestalsRms[i]); 00554 } 00555 00556 //break; 00557 } 00558 00559 l = i = 0; 00560 while (i<V1729_RAM_SIZE ) { 00561 ped[3][l] = pedestals[i++]; 00562 ped[2][l] = pedestals[i++]; 00563 ped[1][l] = pedestals[i++]; 00564 ped[0][l] = pedestals[i++]; 00565 l++; 00566 } 00567 00568 // Pedestal evaluation done 00569 ped_ok = 1; 00570 00571 if (flag) 00572 for (i=0;i<2563;i++) { 00573 fprintf(fH, "Ped0,1,2,3[%i] = %f %f %f %f\n", i, ped[0][i], ped[1][i], ped[2][i], ped[3][i]); 00574 } 00575 if (flag) { 00576 fclose(fH); 00577 printf("File pedestals.txt closed\n"); 00578 } 00579 00580 mvme_set_dmode(mvme, cmode); 00581 return loop; 00582 }
void v1729_PostTrigSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | value | |||
) |
Definition at line 230 of file v1729.c.
Referenced by v1729_Setup().
00231 { 00232 int cmode; 00233 00234 mvme_get_dmode(mvme, &cmode); 00235 mvme_set_dmode(mvme, MVME_DMODE_D16); 00236 mvme_write_value(mvme, base+V1729_POSTTRIG_LSB, value&0xFF); 00237 mvme_write_value(mvme, base+V1729_POSTTRIG_MSB, (value>>8)&0xFF); 00238 mvme_set_dmode(mvme, cmode); 00239 }
void v1729_PreTrigSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | value | |||
) |
Definition at line 218 of file v1729.c.
Referenced by v1729_Setup().
00219 { 00220 int cmode; 00221 00222 mvme_get_dmode(mvme, &cmode); 00223 mvme_set_dmode(mvme, MVME_DMODE_D16); 00224 mvme_write_value(mvme, base+V1729_PRETRIG_LSB, value&0xFF); 00225 mvme_write_value(mvme, base+V1729_PRETRIG_MSB, (value>>8)&0xFF); 00226 mvme_set_dmode(mvme, cmode); 00227 }
void v1729_Reset | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 41 of file v1729.c.
00042 { 00043 int cmode; 00044 00045 mvme_get_dmode(mvme, &cmode); 00046 mvme_set_dmode(mvme, MVME_DMODE_D16); 00047 mvme_write_value(mvme, base+V1729_RESET_W, 0); 00048 mvme_set_dmode(mvme, cmode); 00049 }
int v1729_Setup | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | mode | |||
) |
Sets all the necessary paramters for a given configuration. The configuration is provided by the mode argument. Add your own configuration in the case statement. Let me know your setting if you want to include it in the distribution.
*mvme | VME structure | |
base | Module base address | |
mode | Configuration mode number | |
*nentry | number of entries requested and returned. |
Definition at line 63 of file v1729.c.
Referenced by v1729_PedestalRun(), and v1729_TimeCalibrationRun().
00064 { 00065 int cmode; 00066 00067 mvme_get_dmode(mvme, &cmode); 00068 mvme_set_dmode(mvme, MVME_DMODE_D16); 00069 00070 switch (mode) { 00071 case 0x1: 00072 printf("4 channels 1Gsps External Trigger(mode:%d)\n", mode); 00073 mvme_write_value(mvme, base+V1729_INTERRUPT_ENABLE, 0); 00074 v1729_PreTrigSet(mvme, base, 0x4000); 00075 v1729_PostTrigSet(mvme, base, 64); 00076 v1729_NColsSet(mvme, base, 64); 00077 v1729_TriggerTypeSet(mvme, base, 00078 V1729_EXTERNAL_TRIGGER | V1729_RISING_EDGE 00079 |V1729_INHIBIT_RANDOM | V1729_NORMAL_TRIGGER); 00080 // v1729_TriggerChannelSelect(mvme, base, 0x3); // V1729_ALL_FOUR); 00081 v1729_ChannelSelect(mvme, base, V1729_ALL_FOUR); 00082 v1729_FrqSamplingSet(mvme, base, V1729_1GSPS); 00083 break; 00084 case 0x2: 00085 printf("4 channels 2Gsps External Trigger(mode:%d)\n", mode); 00086 mvme_write_value(mvme, base+V1729_INTERRUPT_ENABLE, 0); 00087 v1729_PreTrigSet(mvme, base, 0x4000); 00088 v1729_PostTrigSet(mvme, base, 64); 00089 v1729_NColsSet(mvme, base, 64); 00090 v1729_TriggerTypeSet(mvme, base, 00091 V1729_EXTERNAL_TRIGGER | V1729_RISING_EDGE 00092 |V1729_INHIBIT_RANDOM | V1729_NORMAL_TRIGGER); 00093 v1729_ChannelSelect(mvme, base, V1729_ALL_FOUR); 00094 v1729_FrqSamplingSet(mvme, base, V1729_2GSPS); 00095 break; 00096 case 0x3: 00097 printf("4 channels 1Gsps External Trigger(mode:%d)\n", mode); 00098 mvme_write_value(mvme, base+V1729_INTERRUPT_ENABLE, 0); 00099 v1729_PreTrigSet(mvme, base, 0x4000); 00100 v1729_PostTrigSet(mvme, base, 32);//64 00101 v1729_NColsSet(mvme, base, 128); 00102 v1729_TriggerTypeSet(mvme, base, 00103 V1729_EXTERNAL_TRIGGER | V1729_RISING_EDGE 00104 |V1729_INHIBIT_RANDOM | V1729_NORMAL_TRIGGER); 00105 // v1729_TriggerChannelSelect(mvme, base, 0x3); // V1729_ALL_FOUR); 00106 v1729_ChannelSelect(mvme, base, V1729_ALL_FOUR); 00107 v1729_FrqSamplingSet(mvme, base, V1729_1GSPS); 00108 break; 00109 case 0x7: 00110 printf("4 channels 1Gsps Soft Trigger for Pedestals(mode:%d)\n", mode); 00111 v1729_PreTrigSet(mvme, base, 0x4000); 00112 v1729_PostTrigSet(mvme, base, 1 ); 00113 v1729_NColsSet(mvme, base, 128); 00114 v1729_TriggerTypeSet(mvme, base, 00115 V1729_SOFT_TRIGGER | V1729_RISING_EDGE 00116 | V1729_INHIBIT_RANDOM | V1729_NORMAL_TRIGGER); 00117 v1729_ChannelSelect(mvme, base, V1729_ALL_FOUR); 00118 v1729_FrqSamplingSet(mvme, base, V1729_1GSPS); 00119 break; 00120 case 0x8: 00121 printf("4 channels 1Gsps Random Trigger for Vernier time extraction(mode:%d)\n", mode); 00122 v1729_PreTrigSet(mvme, base, 1); 00123 v1729_PostTrigSet(mvme, base, 1); 00124 v1729_NColsSet(mvme, base, 0); 00125 v1729_TriggerTypeSet(mvme, base, V1729_AUTHORIZE_RANDOM); 00126 v1729_ChannelSelect(mvme, base, V1729_ALL_FOUR); 00127 v1729_FrqSamplingSet(mvme, base, V1729_1GSPS); 00128 break; 00129 default: 00130 printf("Unknown setup mode\n"); 00131 mvme_set_dmode(mvme, cmode); 00132 return -1; 00133 } 00134 mvme_set_dmode(mvme, cmode); 00135 return 0; 00136 }
void v1729_SoftTrigger | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 287 of file v1729.c.
Referenced by v1729_PedestalRun().
00288 { 00289 int cmode; 00290 00291 mvme_get_dmode(mvme, &cmode); 00292 mvme_set_dmode(mvme, MVME_DMODE_D16); 00293 mvme_write_value(mvme, base+V1729_SOFT_TRIGGER_W, 0x1); 00294 mvme_set_dmode(mvme, cmode); 00295 }
int v1729_Status | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 139 of file v1729.c.
00140 { 00141 WORD value, value1; 00142 int cmode, ncol; 00143 00144 mvme_get_dmode(mvme, &cmode); 00145 mvme_set_dmode(mvme, MVME_DMODE_D16); 00146 printf("--V1729---------------------------------\n"); 00147 value = mvme_read_value(mvme, base+V1729_VERSION_R); 00148 printf("Version : 0x%02x\n", value); 00149 value = mvme_read_value(mvme, base+V1729_FRQ_SAMPLING); 00150 printf("Frequency Sampling : %d[Gsps]\n", value==1 ? 2 : 1); 00151 value = mvme_read_value(mvme, base+V1729_CHANMASK); 00152 printf("Channel Mask : 0x%01x\n", value&0xf); 00153 value = mvme_read_value(mvme, base+V1729_TRIGCHAN); 00154 printf("Trigger Channel source(enable): 0x%01x\n", value&0xF); 00155 value = mvme_read_value(mvme, base+V1729_N_COL); 00156 ncol = v1729_NColsGet(mvme, base); 00157 printf("Number of Columns : %d\n", ncol); // value&0xFF); 00158 value = mvme_read_value(mvme, base+V1729_POSTTRIG_LSB); 00159 value1 = mvme_read_value(mvme, base+V1729_POSTTRIG_MSB); 00160 printf("PostTrigger delay : %d\n", ((value1&0xFF)<<8)|(value&0xFF)); 00161 value = mvme_read_value(mvme, base+V1729_PRETRIG_LSB); 00162 value1 = mvme_read_value(mvme, base+V1729_PRETRIG_MSB); 00163 printf("PreTrigger delay : %d\n", ((value1&0xFF)<<8)|(value&0xFF)); 00164 value = mvme_read_value(mvme, base+V1729_FAST_READ_MODES); 00165 printf("Fast read modes : %d\n", value & 3); 00166 value = mvme_read_value(mvme, base+V1729_TRIGTYPE); 00167 value &= 0x1F; 00168 if ((value&0x3)==0) printf("Software Trigger, "); 00169 if ((value&0x3)==1) printf("Trigger on Discr (fixed by DAC), "); 00170 if ((value&0x3)==2) printf("External Trigger, "); 00171 if ((value&0x3)==3) printf("Software Trigger OR Trigger on Discr, "); 00172 if (((value>>2)&0x1)==0) printf("on Rising Edge.\n"); 00173 if (((value>>2)&0x1)==1) printf("on Fallling Edge.\n"); 00174 if (((value>>3)&0x1)==0) printf("Inhibit random internal Trigger, "); 00175 if (((value>>3)&0x1)==1) printf("Authorize random internal Trigger, "); 00176 if (((value>>4)&0x1)==0) printf("Normal Trigger.\n"); 00177 if (((value>>4)&0x1)==1) printf("External Trigger without masking.\n"); 00178 mvme_set_dmode(mvme, cmode); 00179 return V1729_SUCCESS; 00180 }
int v1729_TimeCalibrationRun | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | flag | |||
) |
Does Time calibration of all 4 channels. Requires the module to be in random Vernier mode (setup 8). Trigger internally generated for the whole memory.
! Code not yet guarantee to be correct.
Definition at line 318 of file v1729.c.
00319 { 00320 int cmode; 00321 int vernier[4][16384]; 00322 int i_bar=0; 00323 int h[5000]; 00324 char bars[] = "|\\-/"; 00325 int i, k=0, j, toggle, save[4]; 00326 FILE *fH=NULL; 00327 00328 mvme_get_dmode(mvme, &cmode); 00329 mvme_set_dmode(mvme, MVME_DMODE_D16); 00330 00331 memset(vernier, 0, sizeof(vernier)); 00332 memset(h, 0, sizeof(h)); 00333 00334 // Set Vernier calibration 00335 v1729_Setup(mvme, base, 8); 00336 00337 // Start ACQ 00338 v1729_AcqStart(mvme, base); 00339 00340 usleep(10000); 00341 00342 if (flag) { 00343 fH = fopen("timecalibration.txt", "w"); 00344 if (fH == NULL) { 00345 printf("File not open\n"); 00346 } 00347 printf("\ntimecalibration.txt file opened\n"); 00348 } 00349 00350 00351 // Wait for trigger 00352 while(!v1729_isTrigger(mvme, base)) { 00353 00354 printf("...%c Waiting trigger\r", bars[i_bar++ % 4]); 00355 fflush(stdout); 00356 00357 usleep(10); 00358 }; 00359 00360 for (i=0;i<16384;i++) { 00361 vernier[3][i] = mvme_read_value(mvme, base+V1729_DATA_FIFO_R); 00362 vernier[2][i] = mvme_read_value(mvme, base+V1729_DATA_FIFO_R); 00363 vernier[1][i] = mvme_read_value(mvme, base+V1729_DATA_FIFO_R); 00364 vernier[0][i] = mvme_read_value(mvme, base+V1729_DATA_FIFO_R); 00365 } 00366 /* 00367 k = 1; 00368 for (l=0;l<16384;l++) { 00369 if (vernier[k][i] < 5000) 00370 h[vernier[k][l]] += 1; 00371 else 00372 printf("vernier:%d\n", vernier[k][i]); 00373 } 00374 */ 00375 // Vernier evaluation done 00376 vernier_ok = 1; 00377 00378 // Debugging code below... to display only the edges of the 00379 // time window. I expect to have only 1 edge above 2000. 00380 // Looking at the whole array, I've seen multiple group! 00381 00382 if (flag) 00383 for (i=0;i<5000;i++) { 00384 fprintf(fH, "Vernier[%i][%i] = %6d\n", k, i, vernier[k][i]); 00385 } 00386 00387 toggle=1; 00388 j=save[0]=save[1]=save[2]=save[3]=0; 00389 for (i=2000 ; i<4000 ; i++) { 00390 if (toggle && (h[i] != 0)) { 00391 save[j++] = i; 00392 toggle = 0; 00393 } 00394 if (!toggle && h[i] == 0) { 00395 save[j++] = i; 00396 toggle = 1; 00397 } 00398 00399 if (flag) 00400 fprintf(fH, "%i - h[%i] = %6d\n", k, i, h[ i]); 00401 } 00402 if (flag) fprintf(fH, "index lMINVERnier:%d lMAXVERnier:%d %d %d DiffMaxMin:%d\n" 00403 , save[0], save[1], save[2], save[3], save[1]-save[0]); 00404 00405 lMINVER = save[0]; 00406 lMAXVER = save[1]; 00407 00408 if (flag) { 00409 fclose(fH); 00410 printf("File timecalibration.txt closed\n"); 00411 } 00412 00413 mvme_set_dmode(mvme, cmode); 00414 return 0; 00415 }
void v1729_TriggerTypeSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | value | |||
) |
Definition at line 242 of file v1729.c.
Referenced by v1729_Setup().
00243 { 00244 int cmode; 00245 00246 mvme_get_dmode(mvme, &cmode); 00247 mvme_set_dmode(mvme, MVME_DMODE_D16); 00248 mvme_write_value(mvme, base+V1729_TRIGTYPE, value); 00249 mvme_set_dmode(mvme, cmode); 00250 }