Reference phase rotations of set points and readbacks

Set points and readbacks are all relative to the rf reference.  The idea is that the host writes set points to the board whose phases are offset from the reference phase, and readbacks that are similarly relative to the reference phase.  This way, set points and readbacks are not sensitive to the startup phase of the quadrant clock, and electonic and cabling drifts in the system.  In Matlab, these phase offsets are implemented in the file rfboard.m for the Opal Kelly interface.

In general, the set points have the phase added, while the readbacks have the phase subtracted (including readbacks of set points).  The following quantities are what are rotated.

Signal vectorReference phase direction
ffImon
ffQmon
subtracted
rlImon
rlQmon
subtracted
dbImon
dbQmon
subtracted
cavImon
cavQmon
subtracted
fwdImon
fwdQmon
subtracted
revImon
revQmon
subtracted
refImon
refQmon
subtracted
fbImon
fbQmon
subtracted
diImon
diQmon
subtracted
fb_spI
fb_spQ
added
fb_spIGet
fb_spQGet
subtracted
ffSPTableadded
fbSPTableadded
Scope
subtracted
Circular buffer
subtracted (not implemented)

Note that the reference phase is also rotated by its own angle, which means that its I component is always positive and its Q component is always zero. When needed, the raw reference can still be fetched with the get function.

rawrefi = get(ifc, 54, update);
rawrefq = get(ifc, 55, update);

The scope buffer is filled with 4096 I, Q pairs in consecutive entries; Each I, Q pair in those seven channels is rotated so as to subtract the phase of the reference.

For the sake of speed, the sine and cosine values are calculated algebraically from the I and Q components and assembled into a 2x2 matrix used to rotate I/Q vectors as a matrix product.  So there are no trigonometric-function evaluations.  For readbacks, the reference-phase matrix is evaluated only when the update argument is true, although, because of its very small bandwidth, it need be evaluated much less frequently.

In principle, the I/Q vectors returned by the circular buffer should also be rotated.  But there are a couple of reasons why this is not expedient to do so.  The first is that this phase rotation is entangled with the wrapping of the buffer as data are recorded, and the unwrapping is not done in rfboard.m.  Instead it is done in CircBufFetch.m, which is where the rotations need to be implemented.  So rfboard.m cannot encapsulate completely reference phase rotations.  The second reason is that, because the size of the circular buffer is so large (224 words), the conversion from int16 to double data type, performing the rotation, and conversion back would badly degrade the speed at which CircBufPlot and CircBufSpect can render graphs.