Remote Spectrum Monitor : Programming with SCPI : I/Q Capture Block Mode
 
I/Q Capture Block Mode
This mode captures a single block of IQ data. I/Q data is first stored to high speed DDR2 SDRAM buffer memory and then it can be saved to flash memory or sent to a remote user via Ethernet. The capture length (duration) is limited by the size of the buffer memory (256 Mbytes) and I/Q data rate, which is determined by the capture bandwidth.
The IQ capture bandwidth must be set to one of the available values listed in the table below. For each selectable bandwidth, the output data rate for a single I/Q data pair is listed in Table: IQ Capture Bandwidth Values. The output data rate does not change, regardless of bit resolution.
IQ Capture Bandwidth Values
I/Q Bandwidth
Output Data Rate MSPS
IQ Sample Pairs/Sec
20 MHz
76.25 / 3
25416666.67
13.3 MHz
76.25 / 4
19062500
6.67 MHz
76.25 / 8
9531250
2.67 MHz
76.25 / 20
3812500
1.33 MHz
76.25 / 40
1906250
667 kHz
76.25 / 80
953125
267 kHz
76.25 / 200
381250
133 kHz
76.25 / 400
190625
66.7 kHz
76.25 / 800
95312.5
26.7 kHz
76.25 / 2000
38125
13.3 kHz
76.25 / 4000
19062.5
The maximum capture length is limited by memory, capture bandwidth and bit resolution. Table: Maximum I/Q Block Capture Length shows the maximum capture length.
 
Maximum I/Q Block Capture Length
I/Q Bandwidth
24 bits
16 bits
10 bits
8 bits
20 MHz1
1.3
s
2.5
s
3.8
s
5.0
s
13.3 MHz
1.7
s
3.4
s
5.0
s
6.7
s
6.67 MHz
3.4
s
6.7
s
10.1
s
13.4
s
2.67 MHz
8.4
s
16.8
s
25.2
s
33.6
s
1.33 MHz
16.8
s
33.6
s
50.4
s
1.12
min
667 kHz
33.6
s
1.12
min
1.68
min
2.24
min
267 kHz
1.40
min
2.80
min
4.20
min
5.60
min
133 kHz
2.80
min
5.60
min
8.39
min
11.19
min
66.7 kHz
5.60
min
11.19
min
16.79
min
22.38
min
26.7 kHz
13.99
min
27.98
min
41.97
min
55.96
min
13.3 kHz
27.98
min
55.96
min
1.40
hr
1.87
hr
6.67 kHz
55.96
min
1.87
hr
2.80
hr
3.73
hr
2.67 kHz
2.33
hr
4.66
hr
6.99
hr
9.33
hr
1.33 kHz
4.66
hr
9.33
hr
13.99
hr
18.65
hr

1 For 20 MHz capture bandwidth, when IQ bit resolution is set to 32 bits, the lower 8 bits are zeros. Therefore the maximum effective bit resolution is 24 bits for 20 MHz bandwidth.

I/Q Block Capture via SCPI
SENS:FREQ:CENTER 100 MHz
SENS:FREQ:SPAN 20 MHz
SWEEP:MODE FFT
//Set RBW 30 kHz
BANDWIDTH 30 KHz
//Set Reference Level to -30 dBm
DISP:WIND:TRAC:Y:SCAL:RLEV -30
//Set to single sweep
INIT:CONT OFF
//abort any sweep in progress
:ABORT
 
//Set Capture bandwidth. Not same as RBW.
IQ:BANDWIDTH 20 MHz
 
//Set 16 bit resolution
IQ:BITS 16
 
//Set to I/Q block capture mode
IQ:MODE SINGLE
//enable time stamp
SENS:IQ:TIME 1
 
//Set capture length to 5 msec
IQ:LENGTH 5 ms
 
//Start IQ Capture. Triggers single capture. Data is saved to DDR2 SDRAM memory.
MEAS:IQ:CAPT
 
//Check if capture is completed normally
STATus:OPERation?
 
//The STATus:OPERation? query responds with a integer. Convert this integer to binary.
//Bit 9 is set to 1 when the MEAS:IQ:CAPT command is issued.
//Bit 9 is set to 0 when the capture is completed normally in block mode.
IQ Capture Data to Absolute Power Level
This is a sample Matlab/Octave program that shows how Raw IQ capture data can be related to an Absolute power level.
%Copy data into captureData array
%Separate the data and build the complex IQ vector.
%First column contains Q and the second I
quadphase = captureData(:,1);
inphase = captureData(:,2);
IQData = (inphase+1i*quadphase);
%Send SCPI Command [:SENSe]:iQ:SAMPle:CALibration:CONFiguration?
%and get absolute reference offset
absolute_ref_offset = -2.007958;
fs = 13.3e6;%Sampling frequency
n = 1024; %number of samples
%Perform fft
y = abs(fft(IQData, n));
y = fftshift(y);
%Scale fft output
y = y/n;
%To power
y = 20 * log10(y);
%To Absolute power level
y = y + absolute_ref_offset;
%Peak Value
peak = max(y);
f = fs*(-n/2:n/2-1)/n;
plot(f, y);
xlabel("Frequency in Hz"); % x-axis label
ylabel("Power in dBm"); % y-axis label
 
I/Q 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 I/Q 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 I/Q 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 I/Q capture was triggered.
\n is a single byte newline delimiter marking the end of the GPS location component and start of the I/Q data. The I/Q data is in binary format and is described below.
I/Q Frame Structure
I/Q data is organized into two levels: frame and extended frame. The lowest level is a 64 bit frame. which may contain one to four I/Q sample pairs depending on the selected I/Q bit resolution. The second level is an extended frame which can be used for the stamp information.
 
The 64 bit frame contains one to four I/Q sample pairs depending on the selected I/Q bit resolution.
I/Q Bit Resolution
IQ Sample Pairs per 64 Bit Frame
24
1
16
2
10
3
8
4
24 Bit Resolution
 
16 Bit Resolution
 
10 Bit Resolution
 
8 Bit Resolution
 
Note 
The frame structure will be modified slightly when there is a time stamp. This will be described in a later section.
I/Q Extended Frame
An extended frame consists of 64 frames.When time stamp information isused, each frame contains one bit ofa 64 bit time stamp data. An extended frame is 64 frames that contain a time stamp.
 
I/Q Time Stamp
This section describes how the time stamp is embedded into the I/Q data. Within each super frame, only the first four extended frames contain time stamp information. Refer to Super Frame diagram. The time stamp contains 64 bits.
 
The GPS seconds is the time in seconds from Jan 1, 1970. The tick counter counts at a rate of 114.375 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 this formula:
To insert the time stamp without interrupting the I/Q 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.
 
I/Q Frame Structure with Time Stamp
Embedding the time stamp requires using two bits from each frame, which requires modifying the I/Q frame structure.
I/Q Bit Resolution = 24
 
Each frame contains only 1 I/Q sample pair (one I and one Q). All the frames will have 24 bits each for I and Q. Each I and Q sample is followed by 7 zeros, then the mark or time stamp bit. Only the first four extended frames will have time stamping.
The remaining extended frames will have zero valued mark and time stamp bit.
I/Q Bit Resolution = 16
 
Each frame contains two I/Q 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 time stamp bit.
I/Q Bit Resolution = 10
 
Each frame contains three I/Q sample pairs (three I and three Q). All 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. Only the first four extended frames will have time stamping.
The remaining extended frames will have zero valued mark and time stamp bit.
I/Q Bit Resolution = 8
 
Each frame contains four I/Q sample pairs (four I and four Q). The first three I and first three Q samples in the frame will always have 8 bits. The fourth I and fourth Q sample will have 7 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 7 effective bits instead of 8 bits on every fourth sample will slightly increase the noise floor.
Time Stamp Boundary Conditions
Note 
Sometimes, the first mark bit does not always begin with at the start of the I/Q capture. There could be a number of I/Q samples recorded before the first time the mark bit is set to 1. In the example below, there are 5 frames before the first timestamp, which doesn't start until the sixth frame.
N Frame Data (one I, one Q sample per frame)
0 [ I-------0Q-------T ]
1 [ I-------0Q-------T ]
2 [ I-------0Q-------T ]
3 [ I-------0Q-------T ]
4 [ I-------0Q-------T ]
5 [ I-------1Q-------T ] <- The first mark bit is here. This is where you start to build the first timestamp;
this 'T' is the MSB of the timestamp
6 [ I-------0Q-------T ] <- 'T' is MSB - 1 bit of the timestamp
7 [ I-------0Q-------T ] <- 'T' is MSB - 2 bit of the timestamp
8 [ I-------0Q-------T ] <- etc.
...
To get the timestamp for frames N=0 though N=4, you must extrapolate the timestamp from frame 5 backwards. To get the timestamps for frames 6-68, you must extrapolate the timestamp forwards. The time between each frame is equal to (1/Output Data Rate)x(Number of I or Q samples per frame).
I/Q Bit Resolution
Time Between Each Frame
24
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 114.375MHz), and '0000' are 4 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 could extrapolate from the previous timestamp.
I/Q Capture Streaming Mode
Data Capture to Buffer Memory
In streaming, the I/Q data uses the same frame, extended frame structure as in block mode.
I/Q data is captured to high speed DDR2 SDRAM memory, configured as a ring buffer. The buffer memory is 256 MB (256 x 10242 bytes) and it is divided into 1024 partitions. Each partition is 262,144 bytes, which holds 32,768 I/Q frames. I/Q data fills each partition in sequence. The data stream rate to memory is determined by the selected I/Q bandwidth. When the buffer is full, new I/Q data is stored from the first partition again.
 
Data Transmission to Remote User
When the I/Q is sent out from the memory to the remote user, the data flow rate has to be managed. The simplest way to manage the data flow is to send out one partition and wait for a read command from the remote user before sending another partition. The user may not be able to receive all the partitions if the read command for each partition is delayed due to latency in the CPU, OS, network, and user application. The I/Q data is continuously filling the memory partitions at a rate proportional to the selected I/Q capture bandwidth. If the read command arrives after the start of a partition, that partition is skipped and will not be sent. The next partition will be sent instead.
 
I/Q Streaming Capture via SCPI
SENS:FREQ:CENTER 100 MHz
SENS:FREQ:SPAN 20 MHz
SWEEP:MODE FFT
//Set RBW 30 kHz
BANDWIDTH 30 KHz
//Set Reference Level to -30 dBm
DISP:WIND:TRAC:Y:SCAL:RLEV -30
//Set to single sweep
INIT:CONT OFF
//abort any sweep in progress
:ABORT
 
//Set Capture bandwidth. Not same as RBW.
IQ:BANDWIDTH 20 MHz
 
//Set 16 bit resolution
IQ:BITS 16
 
//streaming block capture
IQ:MODE STREAM
//enable time stamp
SENS:IQ:TIME 1
 
//Start IQ Capture. Triggers streaming capture. Data is continuously saved to DDR2 memory in a ring buffer.
 
MEAS:IQ:CAPT
 
//Use loop to continuously send command to retrieve I/Q data partitions and parse data as it is being received.
 
LOOP BEGIN
//Get most recent I/Q partition from memory.
TRAC:IQ:DATA?
 
//Check if capture is aborted.
STATus:OPERation?
 
//If capture is not aborted, parse data and decode time stamp for the received data
LOOP END
To read the I/Q data, use the TRAC:IQ:DATA? SCPI command. This returns the partition with the most recently captured I/Q data. During streaming, the client has to continuously send TRAC:IQ:DATA? SCPI command to another partition’s I/Q data.
The capture of I/Q data and filling of partitions will continue until it is aborted with the :ABORT command or other commands that change frequency or attenuation settings. To determine if the capture was aborted, check the output of STATus:OPERation?.
The STATus:OPERation? query responds with a integer. Convert this integer to binary.
Bit 9 is set to 1 when the MEAS:IQ:CAPT command is issued.
Bit 9 is set to 0 if the capture is aborted by :ABORT command or other command which invalidates the capture.
 
Error Conditions: Overpower or Overheat
The I/Q capture will be paused if the instrument detects an overpower or overheat condition. In this situation, any pending TRAC:IQ:DATA? query will immediately return #0 and a device-specific error will be added to the SCPI error queue. When the condition is rectified, the capture will automatically restart. For example, if there was an overpower event, remove the overpower source and close the overpower relay. If there was an overheat event, wait for the instrument to cool down.
 
Error Condition: Timing Reference Source Change
If the instrument detects any of the four conditions below, a device-specific error will be added to the SCPI error queue. In either block or streaming mode, the instrument will not abort a capture that is already in progress.
1. Loss of GPS
2. Newly acquired GPS lock
3. Disconnect/Connect External Reference
4. Large timing drift during GPS Hi-Accuracy Mode