It is necessary to calibrate the I&Q modulators and demodulators in order to obtain the desired accuracy. The calibration could be done in hardware, but, it would be done with analog circuits, which need calibrarion themselves. Doing the calibration in software involves:
We are using the '1428 digitizer. This is an 8-bit machine. The specification in Append. A of the manual lists the following:
The input to the IOC for the I&Q modulator will consist of the desired phase, at the rate of one point for each 4ns bucket. The correction for the modulator will consist of adding a station phase value to each point and using the resultant value to access a table for the I value and a table for the Q value. The array of 512 I values will be input to the I AFG and the array of 512 Q values will be input to the Q AFG. This requires one 12-bit table for I, or 4096 words, and one 12-bit table for Q, or, 4096 words. This is a total of 8K words or 16KB.
The raw I&Q values from the I&Q detectors, via the digitizer, are 8-bit values, located in the high byte of a 16-bit word. The correction algorithm requires looking up the proper I value from an I calibration table and looking up the proper Q value from a Q calibration table. The precision of the input from the digitizer is 8-bits. We cannot generate precision by math. Therefore, the I and Q calibration tables are 8-bit tables. However, the I&Q calibration requires the translation and rotation of axis, so, the table is accessed with a 16-bit word formed by concatenating the I byte and the Q byte. This requires a 64KB table for I and a 64KB table for Q, or 128KB total. There are 8 I&Q pairs for each IOC, so this is a total of 1024MB for I&Q detector calibration tables.
It may be possible to do this calibration in a lookup table. The data from the digitizer is 8-bit data. It is actually read fastest as 16-bit integers. These integers could be converted to 8-bits with V>>8 and still retain precision. These I and Q values could be used to access a look-up table to get the corrected output values.Then, one could apply the scaling values to i and q to obtain volts, if desired.
It may be possible that the calibration maybe done without interruption to beam. The nlcta beam code happens at 60Hz. The beam nominally occurs at 1 or 10Hz. There are gaps in the trigger opportunity window where a trigger may be obtained at 1/60 second intervals after every beam pulse.
Selecting, say, the second one of these would allow the calibration to selectively happen between every beam pulse. Then, the waveform cylic collection algorithm could be:
MuxDataSettings contains the mux settings for each waveform.
DigDataSettings contains the digitizer settings for each waveform.
DigDataLocation contains a pointer to the location to store the I and Q data for each waveform.
MuxCalibrateSettings contains the mux settings for each calibration waveform.
DigcalibrateSettings contains the digitizer settings for each calibration waveform.
DigCalibrateLocation contains a pointer to the location to store the I and Q data for each calibration waveform.
DetectorCalibration contains the calibration values, e1..e6 for each detector.
Then, the calibrate flag could be set for a selected demodulator and 33.33msec after the next beam pulse, a calibration waveform could be captured and the proper calibration constants retained for future use.
One side effect may be that if the calibration process takes too much time, we may not capture the next beam pulse.