*REVISED 11 * PROPOSAL FOR CAMAC FUNCTIONS OF THE CAMAC 192 MODULE W. MARSH 5-AUG-1986 VERSION 11 DIFFERENCES 1. Add a negate data bit to F19A13,F1A6. 2. Add read/write memory CAMAC functions (F19A4, F19A5, F1A14). DESCRIPTION The module will digitize up to 4 multiwire chambers of up to 64 wires each. It will be able to take up to 16 scans (profiles) for each data taking cycle (defined to be the time between two successive "clear" clock events. The scans can be triggered either externally through external input, through a clock event, or at internally defined times. Furthermore, a "prepulse" (noise) scan can be taken on a clock event and subtracted from each scan. The prepulse scan will be stored in a separate buffer. Also the mean and sigma of each scan be calculated via Peter Lucas's iterative algorithm. The data is double buffered. It is acquired in the Data Collection Buffer and calculations are done on that buffer. This buffer is readable during data collection so that one can read out the scans as they come in. At clear time or when the calculations are done the Data Collection Buffer becomes the Previous Cycle Buffer and the last Previous Cycle Buffer becomes the Data Collection Buffer (ie.--the two buffers are switched). The data is thus frozen in the Previous Cycle Buffer until the next clear allowing an entire cycle for the host to read the data. The calculated data is stored both in the data buffers and in a special Calculated Data Buffer. The Calculated Data Buffer is readable at any time and will contain the latest values An average profile for each channel of a number of scans along with the means and sigmas can also be obtained. There are two buffers for the average buffer--a Read and a Sum buffer. MODULE CONTROL F9A0 Reset Module F19A1 Write clock decoder configuration--same as 191 Source 1: Clear trigger Source 2: Trigger Scan Source 3: Prepulse trigger F19A4 Write memory address for read/write memory (F1A14,F19A5) F19A5 Write into memory at address given by F19A4 F19A8 Set MUX address, channel, and flag of single ADC read (F1A15) Bits 0-5: MUX address Bits 8-9: channel Bit 15: If set then the MUX will be incremented for the next read (F1A15) F19A9 Write Number of Scans, Number of Channels, LAM select, Prepulse Scan Select, Buffer Switch Select, and Data Acquisition Buffer No Q Select. Bits 0-3: Number of Scans Bits 4-5: Number of Channels Bits 6-8: LAM Select 0: No LAMS 1: LAM on Data Collection Buffer Bits (LAM Mask Register .and. Data Collection Buffer Bits (F0A10). 2: LAM on Data Collection Buffer Calculation Bits (LAM Mask Register .and. Data Collection Buffer Calculation Bits (F0A11). 3: LAM on Buffer Switch. Bits 9-11: Prepulse Scan Selection 0: No prepulse 1: Take prepusle and subtract from data. 2: Take prepulse but only subtract from data when doing calculations. (Raw data remains the same) 3: Take prepulse but do no subtraction Bits 12-13: Buffer Switch Select 0: Switch on Clear or calculations done with all scans 1: Switch on Clear only 2: Do not switch--Previous Cycle Buffer disabled--Average Sum Buffer is still switched with the Average Read buffer on a Clear. Bits 14-15: Data Acquisition Buffer No Q Selection 0: No Q if no data for a particular Scan 1: No Q if calculations are not done for a particular scan 2: No Q only if reach the end of Scan 15 F19A10 Write Number of Wires for a certain Channel Bits 0-6: Number of Wires Bits 13,14: Channel F19A11 Write Trigger delay word F19A12 Write Data sample period (for internal timer) F19A13 Write limit on number of iterations of calculation and the Multiplexor address of wire 1 Bits 0-6: Limit on number of iterations Bit 7: Set if after reaching limit all calculated values are to be set to 0. Reset if after reaching limit calculated values are to reflect the last iteration Bits 8-14: Multiplexor address of wire 1 Bit 15: If set then the data (ADC values) are negated. F19A14 Write Beginning/Ending Scan numbers of Average Bits 0-3: Beginning Scan Number Bits 8-11: Ending Scan Number Bit 15: Set to turn on averaging F19A15 Write Clear, Trigger, and Prepulse source selection control word Bits 0-2: Clear source (enable triggers--clear data--reset Scan Number to 0 0: No operation 1: Manual Clear immediately--Trigger and Prepulse Source (Bits 8-10,12-14) must be 0. 2: Clear on clock decoder source 3: Clear on external source 4: Clear on clock decoder source but take only one cycle 5: Clear on external source but take only one cycle 6: Go to Manual 7: Cancel data acquisition Bits 8-10: Trigger Source (take data) Note: Values 3-6 take effect on next Clear Trigger. 0: No operation 1: Manual Trigger immediately taking scans on internal timer--Clear and prepulse Source (Bits 0-2,12-14) must be 0. 2: Manual Trigger immediately--one scan. Clear and prepulse Source (Bits 0-2, 12-14) must be 0. 3: Trigger sample collection on clock taking scans on internal timer 4: Trigger sample collection on clock-- one scan at a time 5: Trigger sample collection on external source taking scans on internal timer 6: Trigger sample collection on external source--one scan at a time 7: Go to Manual Bits 12-14: Prepulse source selection 0: No operation 1: Trigger prepulse on Tev clock 2: Trigger prepulse on external source 3: Go to manual 4: Manual prepulse trigger--Clear and trigger source (Bits 0-2,8-10) must be 0. MODULE CONFIGURATION F1A2 Read Number of Scans, Number of Channels, LAM select, Prepulse Scan Select, Buffer Switch Select, and Data Acquisition Buffer No Q Select and reset channel pointer for F1A3 Bits 0-3: number of scans Bits 4-5: Number of channels Bits 6-8: LAM Select (see F19A9) Bits 9-11: Prepulse Scan Select (see F19A9) Bits 12-13: Buffer Switch Select (see F19A9) Bits 14-15: DAQ Buffer No Q Select (see F19A9) F1A3 Read number of wires Bits 0-6: Number of wires Bits 13-14: Channel F1A4 Read Trigger Delay F1A5 Read Data Sample Period F1A6 Read Maximum number of iterations of mean, sigma calculations and the multiplexor address of wire 1 and the data negation bit (see F19A13). F1A7 Read Beginning/Ending Scan Number of Average (F19A14) F1A8 Read of Mux address, channel and flag for single ADC read (F1A15,F19A8). Bits 0-5: MUX address Bits 8-9: Channel Bit 15: If set then the MUX is incremented at the next read (F1A15). F1A14 Read memory address given by F19A4. F1A15 Read of single ADC channel--MUX and channel set up by F19A8 F6A0 Read Module ID F6A1 Read Firmware Version F6A2 Read Module Configuration Word. Bit 14: Debugger installed Bit 15: Module supports FOP codes F6A5 Read Clear/Trigger/Prepulse source selection Setup Word F6A6 Read number of Tev Clock events for Clear/Trigger and reset F6A7 pointers F6A7 Read Tev Clock events for Clear/Trigger F6A8 Read of the number of Tev clock events for Prepulse trigger. F6A9 Read Tev clock events for Prepulse trigger DATA COLLECTION F16A0 Set Channel, Scan Number, and Offset of read (F0A0) of Previous Cycle Data Buffer Bits 0-6: Offset (words) Bits 7-8: Channel Bits 9-12: Scan Number F16A1 Set Channel, Scan Number, and Offset of read (F0A1) of Data Collection Buffer Bits 0-6: Offset (words) Bits 7-8: Channel Bits 9-12: Scan Number F16A2 Set Channel, Scan Number, and Offset of read (F0A2) of Calculation Data Buffer Bits 0-2: Offset (words) Bits 7-8: Channel Bits 9-12: Scan Number F16A6 Set Channel and Offset of read (F0A6) of the Average Read Buffer Bits 0-6: Offset (words) Bits 7-8: Channel F16A13 Set Channel and Offset of read (F0A13) of the previos cycle prepulse buffer Bits 0-6: Offset (words) Bits 7-8: Channel F16A14 Set Channel and Offset of read (F0A14) of the Data collection prepulse buffer Bits 0-6: Offset Bits 7-8: Channel F0A0 Read Previous Cycle Buffer and increment pointer to next word-->will go through all scans of a particular channel-->F16A0 must be done before the first F0A0. F0A1 Read Data Collection Buffer and increment pointer-->operates similar to F0A0 except operates on Data Collection Buffer and set pointer function is F16A1. F0A2 Read calculated data item pointed to by F16A2 Note: only 1 F0 per F16 is allowed except in reading the sum (area) in which two are allowed. F0A3 Read calculated data item pointed to by F16A2 only if profile is vertical. F0A4 Read calculated data item pointed to by F16A2 only if profile is horizontal. F0A5 Read calculated data item pointed to by F16A2 only if profile is out. F0A6 Read the Average Read Buffer. Pointer set up by F16A6. F0A7 Previous Cycle Buffer Data Collection Status Bits Bits 0-15 corresponds to each scan--set when scan has been taken F0A8 Previous Cycle Buffer Calculation Bits Bits 0-15 corresponds to each scan--set when calculation has been performed on the scan. F0A9 Previous Cycle Buffer Cycle Number F0A10 Data Collection Buffer Status bits Bits 0-15 corresponds to each scan--set when scan is collected F0A11 Data Collection Buffer Calculation Bits Bits 0-15 corresponds to each scan--set when calculation is finished for the scan. F0A12 Data Collection Buffer Cycle Number F0A13 Read Previous Cycle Prepulse buffer and increment pointer to next word-->F16A13 must be done before first F0A13. F0A14 Read of the Data Collection Prepulse buffer and increment pointer to next word-->F16A14 must be done before first F0A14. F0A15 Read of the hardware vertical/horizontal/out status input port LAM FUNCTIONS F1A0 Read LAM source Register F1A1 Read LAM Mask Register F8A0 Test LAM F19A0 Write LAM Mask Register F24A0 Disable LAM F26A0 Enable LAM DATA BUFFER Word 0: Descriptor word Bits 13-15: Buffer type 0: Data buffer--ie. this buffer 1: Average Buffer--(see Profile Average Buffer) 2: Prepulse Buffer Bits 9-12: Scan Number Bits 7-8: Channel Bits 0-6: Number of Wires Word 1: Status Bit 15: Data Good--calculation and data are correlated. Bit is set if uncorrelated. Bits 12-14: The Prepulse Selection parameter (F19A9) Bits 9-11: Horizontal/Vertical/Out Bits 0-3: Cycle Number Word 2: Mean*10 Word 3: Sigma*10 Word 4: Area (low) Word 5: Area (high) Word 6: Maximum ADC value (with zero adjustment added) Word 7: Chi squared per degree of freedom * 10 Word 8: Zero adjustment--amount added to each ADC value during calculation so that all values are greater than or equal to 0. Note: all calculated values reflect this addition--but the data in the buffer does not. Words 9-72 Data Bit 0: Set if calculation has determined this wire to be missing Bit 1: Set if calculation has determined this wire to be noisy Bits 4-15: ADC value CALCULATION BUFFER Word 0: Mean*10 Word 1: Sigma*10 Word 2: Area (low) Word 3: Area (high) Word 4: Maximum ADC value Word 5: Chi squared per degree of freedom * 10 Word 6: Zero adjustment Word 7: Out/Horizontal/Vertical PROFILE AVERAGE BUFFER Word 0: Descriptor Word 1 Bits 0-6: Number of Wires Bits 7-8: Channel Bits 13-15: Buffer type 0: Data Buffer--(see Data Buffer) 1: Profile Average Buffer--this buffer 2: Prepulse Buffer Word 1: Status Word Bits 0-3: Cycle Number Bits 9-11: Horizontal/Vertical/Out Bits 12-14: Prepulse Selection Number Bit 15: Set if Average Calculation not finished Word 2: Descriptor Word 2 Average Scan Mask Bits 0-15: Bit set if corresponding scan in average Word 3: Mean*10 Word 4 Sigma*10 Word 5: Area (low order) Word 6: Area (high order) Word 7: Maximum ADC value Word 8: Chi squared per degree of freedom * 10 Word 9: Zero Adjustment Words 10-73 Data PREPULSE BUFFER Word 0: Descriptor word Bits 13-15: Buffer type 0: Data Buffer 1: Average Buffer 2: Prepulse Buffer Bits 7-8: Channel Bits 0-6: Number of wires Word 1: Status Bit 15: Bit is set if prepulse was not taken Bits 12-14: The prepulse selection parameter (F19A9) Bits 9-11: Horizontal/Vertical/Out Bits 0-3: Cycle Number Words 2-8 Zero--not used Words 9-72 Data OPERATING SCENARIO 1. Clear Time a. Buffers switched if appropriate. If no buffer switch is specified then the Data Collection Status Registers are copied into the Last Cycle status registers. b. Any calculations in progress (internal Calculation Scan Number for any channel not equal to the number of scans plus 1) is stopped just in case no buffer switch was specified). c. Data Collection Buffer Status and Calculation Bits are zeroed d. Data Collection Buffer cycle number is incremented e. Write pointer set to Scan 0. f. Next DAQ Scan Number Word for all channels is set to 0 to indicate no scans to calculate on. g. Average Sums are zeroed 2. Buffer Switch a. Internal pointers are switched. Data Collection Buffer becomes Previous Cycle Buffer and vise versa. The Average Sum Buffer is switched with the Average Read Buffer b. Data Collection Buffer Status Registers (F0A10,F0A11,F0A12) are copied into the Previous Cycle Buffer Status Registers (F0A7,F0A8, F0A9). c. Any read of the Previous Cycle Buffer is aborted. F0A0 no-Q'ed until an F16A0 is done. d. Calculations on the Data collection buffer if still in progress are aborted. e. LAM set if appropriate. 3. Trigger a. Data is taken and put into proper place with subtraction if wanted. Write pointer is updated to next scan. b. If all scans have been taken then trigger is ignored. c. Internal Next Scan Received Word for all channels is updated with new scan number. d. Scan Status word updated to show no correlation. e. Data Collection Buffer Status bit for that scan set. f. LAM set if appropriate. g. Scan Cycle number in Buffer is updated. h. If no Buffer Switch is specified then the Last Cycle Data Collection bit (F0A7) is modified to say no data for that scan. i. Average Sums are accumulated 4. Calculations a. Calculations are done in the background at noninterupt level. b. Calculation works in a loop as follows: 1. If comparison between Next Scan Received Word and Calculation Scan Number for any channel indicates that there is a scan to do then start calculating it. 2. Checks abort flag in various places. If abort is set then stop calculating and set Calculation Scan number to 0. Reset Abort Flag. 3. At end of calculation the calculated variables, the status word in the data buffer, the Calculation Scan Number, and the Data Collection Status word (F0A1) are updated. If it is the last scan both the Next Scan Received Word and the Calculation Scan Number are set to Number of Scans plus 1 for that channel. 4. Go back to 1. c. The appropriate Data Collection Calculation bit is set when each calculation finishes. d. The status word in the buffer is set to data correlated as each calculation finishes. e. If no Buffer Switch is specified then the Last Cycle Calculation bit for that scan is reset (F0A8). 4. Profile Average Calculation a. Averages are always double buffered into a Sum Buffer and a Read Buffer. b. At Clear Time the Present Sum Buffer is zeroed and the status and desciptor words are set up c. At each Trigger the Sums are accumulated d. After all the mean and sigma calculations are done for all scans and all channels the average profile is calculated along with its mean and sigma. e. At Buffer Switch time or at the Clear the Read and Sum Buffers are switched. Reading the Data in Double Buffer Mode a. Reading calculated data for the parameter page display can be done on a repetative basis after the first cycle by doing an F16A2, F0A2 combination. Only one F0 is allowed for each F16 except for read of the area in which 2 are allowed. The data will change asynchronously as it is calculated. A change in the data inbetween the two F0's of the area will cause no-Q's. If it is desired to make sure the chambers are vertical, horizontal, or out then F0A3, F0A4, or F0A5 are used instead of F0A2. One may also use the F16A0,F0A0 combination to read the calculated data. However on a buffer switch the F0 will be No-Q'ed. b. Reading scans of data from the Previous Cycle Buffer can be done at any time by first setting the pointer with F16A0 and then doing repetative F0A0's until the data is collected. When the end of all scans of a particular channel is reached then the F0 is no-Q'ed. If a buffer switch happens in the middle of the read then the F0's are no-Q'ed until another F16 is done. c. The Data Collection Buffer may be read by doing F16A1,F0A1 combinations. Depending on the type of read mode specified (F19A12), no-Q'ing may happen if one tries to read a nonexistant scan, a scan whose calculations are not done, or a scan who was overwritten in the middle of a read. Reading the Data in Single Buffer Mode a. F16A0 is ignored and F0A0 is no-Q'ed. ie.-- the Read Buffer is non existant. b. As above the Data Collection Buffer is read via F16A1,F0A1 combinations with the same caveats. In addition the Last Cycle status registers are available to tell which scans are still good from the last cycle. These can be read via the same function codes as the Previous Cycle Buffer Status Registers which they replace (F0A7, F0A8, and F0A9). Note that the calculation status registers (F0A8,F0A11) are for all channels so that the Last Cycle bit is reset upon beginning the calculation of the first channel while the Data Collection Buffer bit is only set after the last channel's calculation is completed. c. The calculated data for the parameter page display can be read by the F16A2,F0A2 combination.