Remote Spectrum Monitor™ MS27201A User Guide : IQ Capture/Streaming (Option 124/125 and 126/127) : IQ Data Format
 
IQ Data Format
The TRAC:IQ:DATA? query returns a modified version of the SCPI standard (IEEE 488.2) block data format. The header contains three fields with a newline delimiter separating the header from the IQ binary data:
#AXL\n
A is a single ASCII digit specifying the number of digits in X.
X is one or more ASCII digits specifying the number of bytes of binary IQ data and ASCII GPS location coordinates.
L is the ASCII string containing the GPS location in the form 'latitude, longitude' in decimal degrees. The coordinates record where the IQ capture was triggered.
\n is a single byte newline delimiter marking the end of the GPS location component and start of the IQ data.
The IQ data is in binary format and is described below.
IQ Frame Structure
IQ data is organized into two levels: frame and extended frame. The lowest level is a 64 bit frame. which may contain one to four IQ sample pairs depending on the selected IQ bit resolution. The second level is an extended frame which can be used for the stamp information. The first column of the IQ vector contains I and the second column contains Q.
 
The 64 bit frame contains one to four IQ sample pairs depending on the selected IQ bit resolution.
IQ Frame Structure
IQ Bit Resolution
Sample Pairs Per Frame
IQ Frame Structure
32
1
16
2
10
3
8
4
Note 
The frame structure will be modified slightly when there is a time stamp as described in IQ Timestamps.
IQ Extended Frame
An extended frame consists of 64 frames. When time stamp information is used, each frame contains one bit of a 64 bit time stamp data. An extended frame is 64 frames that contain a time stamp.
 
IQ Timestamps
IQ timestamps are available for IQ capture. This section describes how the time stamp is embedded into the IQ data. Within each 64-bit frame, only the first four extended frames contain time stamp information (see the 64-bit time stamp frame diagram below).
 
The GPS seconds is the time in seconds from January 1, 1970. The tick counter counts at a rate of 270 MHz and it is reset to 0 on every second, triggered by the GPS PPS signal. The time stamp records the time at the beginning of each extended frame. The elapsed time between each frame is calculated with the following formula:
To insert the time stamp without interrupting the IQ data sequence, the 64 bit time stamp is rotated and inserted into the extended frame by using bit 64 from each frame. To indicate the beginning of an extended frame with a time stamp, a mark bit is set to ‘1’ for the first frame and ‘0’ for the remaining 63 frames. The mark bit uses bit 32 of each frame.
 
Embedding the time stamp requires using two bits from each frame, which requires modifying the IQ frame structure as shown below:
IQ Frame Structure with Time Stamps
IQ Bit Resolution
IQ Frame Structure
32
Each frame contains only one IQ sample pair (one I and one Q). The first column of the IQ vector contains I and the second column contains Q. All the frames will have 32 bits each for I and Q. Each I and Q sample is followed the mark or time stamp bit. Within each super frame, only the first four extended frames contain time stamp information. The remaining extended frames will have a zero valued mark and a time stamp bit.
16
Each frame contains two IQ sample pairs (two I and two Q). The first I and first Q sample in the frame will always have 16 bits; the second I and second Q sample will have 15 bits followed by the mark and a time stamp bit.
10
Each frame contains three IQ sample pairs (three I and three Q). All of the frames will have 10 bits each for I and Q. Each I and Q sample is followed by one zero, then the mark or time stamp bit. Within each super frame, only the first four extended frames contain time stamp information. The remaining extended frames will have a zero valued mark and a time stamp bit.
8
Each frame contains four IQ sample pairs (four I and four Q). The first three I and first three Q samples in the frame will always have eight bits. The fourth I and fourth Q sample will have seven bits if the frame is in the first four extended frames, which uses one bit for mark and one bit for the time stamp. Having only seven effective bits instead of eight bits on every fourth sample will slightly increase the noise floor.
Sometimes, the first mark bit does not always begin at the start of the IQ capture. There could be a number of IQ samples recorded before the first time the mark bit is set to one. In the example below, there are five frames before the first timestamp, which doesn't start until the sixth frame. The first column of the IQ vector contains Q and the second column contains I.
IQ Frame Structure with Time Stamps
N
Frame Data (one I and one Q sample per frame)
0
1
2
3
4
5
6
7
8
[ I-------TQ-------0 ]
[ I-------TQ-------0 ]
[ I-------TQ-------0 ]
[ I-------TQ-------0 ]
[ I-------TQ-------0 ]
[ I-------TQ-------0 ] <- first mark bit, 'T' is the MSB of the timestamp
[ I-------TQ-------0 ] <- 'T' is MSB - 1 bit of the timestamp
[ I-------TQ-------0 ] <- 'T' is MSB - 2 bit of the timestamp
[ I-------TQ-------0 ] <- etc.
To get the timestamp for frames N=0 though N=4, you must extrapolate the timestamp from frame five backward. To get the timestamps for frames 6 through 68, you must extrapolate the timestamp forward. The time between each frame is equal to (1/Output Data Rate) x (Number of I or Q samples per frame).
IQ Bit Resolution
Time Between Each Frame
32
1/(Output Data Rate)
16
2/(Output Data Rate)
10
3/(Output Data Rate)
8
4/(Output Data Rate)
Once the 64 bits of timestamp is put together, you get a number that looks like:
[ S-------T-----0000]
Where 'S-------' is 32 bits specifying the timestamp in seconds since 1970 (time_t), 'T-----' is 28 bits specifying the offset from that second (in clock ticks at 270 MHz), and '0000' are four unused bits.
Note 
There could be some frames at the very end of the capture that have an incomplete timestamp because the capture stops before there is a complete group of 64 frames to make an extended frame. In that case you would extrapolate from the previous timestamp.