ps7106.c File Reference

Go to the source code of this file.

Defines

#define READ_MASK_7106   0
#define READ_LATCH_7106   0
#define READ_THRESH_7106   1
#define READ_STATUS_7106   1
#define WRITE_MASK_7106   16
#define WRITE_THRESH_7106   17
#define START_ADC_7106   17
#define SET_LOCAL_7106   24
#define TEST_DISC_7106   25
#define SET_REMOTE_7106   26
#define TEST_REMOTE_7106   27

Functions

int ps7106_set (int crate, int slot, double thresh_value)


Define Documentation

#define READ_LATCH_7106   0

Definition at line 29 of file ps7106.c.

#define READ_MASK_7106   0

Definition at line 28 of file ps7106.c.

#define READ_STATUS_7106   1

Definition at line 31 of file ps7106.c.

#define READ_THRESH_7106   1

Definition at line 30 of file ps7106.c.

Referenced by ps7106_set().

#define SET_LOCAL_7106   24

Definition at line 35 of file ps7106.c.

#define SET_REMOTE_7106   26

Definition at line 37 of file ps7106.c.

Referenced by ps7106_set().

#define START_ADC_7106   17

Definition at line 34 of file ps7106.c.

Referenced by ps7106_set().

#define TEST_DISC_7106   25

Definition at line 36 of file ps7106.c.

#define TEST_REMOTE_7106   27

Definition at line 38 of file ps7106.c.

Referenced by ps7106_set().

#define WRITE_MASK_7106   16

Definition at line 32 of file ps7106.c.

#define WRITE_THRESH_7106   17

Definition at line 33 of file ps7106.c.

Referenced by ps7106_set().


Function Documentation

int ps7106_set ( int  crate,
int  slot,
double  thresh_value 
)

Definition at line 42 of file ps7106.c.

00047 {
00048    INT q;
00049    WORD data, threshold;
00050 
00051    // Convert threshold value to register value
00052    if (thresh_value > 1033)
00053       thresh_value = 1033;
00054    if (thresh_value < 10)
00055       thresh_value = 10;
00056    threshold = (unsigned int) (thresh_value - 10);
00057 
00058    /* Set remote mode */
00059    camo(crate, slot, 0, SET_REMOTE_7106, 0);
00060 
00061    /* Verify Remote mode */
00062    camc_q(crate, slot, 0, TEST_REMOTE_7106, &q);
00063    if (!q) {
00064       cm_msg(MERROR, "ps7106_set", "Error setting remote mode on crate %d, slot %d.\n",
00065              crate, slot);
00066 //    printf("Error setting remote mode on crate %d, slot %d.\n", crate, slot);
00067       return -1;
00068    }
00069 
00070    /* unmask all channels */
00071    camo(crate, slot, 0, 16, 0xFFFF);
00072 
00073    /* Write threshold */
00074    camo(crate, slot, 0, WRITE_THRESH_7106, threshold);
00075    ss_sleep(10);
00076 
00077    /* Verify threshold */
00078    cami(crate, slot, 0, READ_THRESH_7106, &data);
00079    data = data & 0x3FF;
00080    if (data != threshold) {
00081       cm_msg(MERROR, "ps7106_set", "Error setting threshold:\
00082  requested %d (%4.0f mV), read %d", threshold, thresh_value, data);
00083 //    printf("Error setting threshold:\
00084 // requested %d (%4.0f mV), read %d", threshold, thresh_value, data);
00085       return -1;
00086    }
00087 
00088    /* Measure threshold */
00089    camo(crate, slot, 1, START_ADC_7106, threshold);
00090    ss_sleep(10);
00091 
00092    cami(crate, slot, 1, READ_THRESH_7106, &data);
00093    data = data & 0x3FF;
00094 
00095    if (fabs((double) data - thresh_value) > 2.0) {
00096       cm_msg(MERROR, "ps7106_set", "Error setting threshold on crate %d, slot %d:\
00097  requested %1.0lfmV, measured %dmV", crate, slot, thresh_value, data);
00098 //    printf("Error setting threshold on crate %d, slot %d:\
00099 // requested %1.0lfmV, measured %dmV", crate, slot, thresh_value, data);
00100    }
00101 
00102    return 0;
00103 }


Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk