Skip to content

Iq capture 2ant

Function display_iq(iq0_capture, iq1_capture)

display_iq: The function of display_iq is to visualize the in-phase and quadrature (I/Q) components of two captured signals.

parameters: The parameters of this Function. · parameter1: iq0_capture - A complex array representing the I/Q data for the first receiver (rx0). · parameter2: iq1_capture - A complex array representing the I/Q data for the second receiver (rx1).

Code Description: The display_iq function creates a visual representation of the I/Q components of two signals captured from two different receivers. It utilizes Matplotlib for plotting.

The function begins by initializing a new figure for the plots with the command plt.figure(0), and it clears any existing content in that figure using fig_iq_capture.clf().

Next, it sets up the first subplot (ax_iq0) for the first receiver's I/Q data. The y-axis is labeled "I/Q", and the title is set to "rx0 I/Q". The real part of the iq0_capture data is plotted in blue, while the imaginary part is plotted in red. The y-axis limits are set to a range of -32767 to 32767 to ensure that the data is displayed within a defined scale.

The function then creates a second subplot (ax_iq1) for the second receiver's I/Q data. This subplot includes an x-axis label "sample", a y-axis label "I/Q", and a title "rx1 I/Q". Similar to the first subplot, the real part of the iq1_capture data is plotted in blue, and the imaginary part is plotted in red, with the same y-axis limits applied.

Finally, the command fig_iq_capture.canvas.flush_events() is called to update the figure and ensure that the plots are rendered immediately.

Note: It is important to ensure that the input parameters iq0_capture and iq1_capture are complex arrays, as the function relies on the real and imaginary parts for plotting. Additionally, the function assumes that Matplotlib is properly imported and configured in the environment where it is executed.

graph TD
    A[Start display_iq function] --> B[Create figure for IQ capture]
    B --> C[Clear figure]
    C --> D[Add subplot for iq0_capture]
    D --> E[Set ylabel for iq0_capture]
    E --> F[Set title for iq0_capture]
    F --> G[Plot real part of iq0_capture]
    G --> H[Plot imaginary part of iq0_capture]
    H --> I[Set y-axis limits for iq0_capture]
    I --> J[Add subplot for iq1_capture]
    J --> K[Set xlabel for iq1_capture]
    K --> L[Set ylabel for iq1_capture]
    L --> M[Set title for iq1_capture]
    M --> N[Plot real part of iq1_capture]
    N --> O[Plot imaginary part of iq1_capture]
    O --> P[Set y-axis limits for iq1_capture]
    P --> Q[Flush events on figure canvas]
    Q --> R[End display_iq function]

Function parse_iq(iq, iq_len)

parse_iq: The function of parse_iq is to process IQ (In-phase and Quadrature) data and extract timestamps and captured IQ samples.

parameters: The parameters of this Function. · parameter1: iq - A NumPy array containing the raw IQ data, which is expected to be in a specific format for processing. · parameter2: iq_len - An integer representing the length of the IQ data segments to be captured.

Code Description: The parse_iq function begins by calculating the number of DMA symbols per transaction, which is determined by adding one to the iq_len parameter. It then calculates the number of 16-bit integers per transaction, which is four times the number of DMA symbols. The total number of transactions is computed by dividing the length of the iq array by the number of integers per transaction and rounding the result.

Next, the function reshapes the iq array into a two-dimensional array where each row corresponds to a transaction. The first four columns of this reshaped array are used to compute a timestamp for each transaction. The timestamp is calculated by combining the values from these columns using powers of two to account for their respective bit positions.

The function then extracts the IQ samples for two channels (iq0 and iq1) from the reshaped iq array. The IQ samples are obtained by taking every fourth element starting from the fifth and sixth columns for iq0, and from the seventh and eighth columns for iq1. These samples are converted to complex numbers by combining the real and imaginary parts.

Finally, the function reshapes the captured IQ samples into one-dimensional arrays, where the total length is the product of the number of transactions and the iq_len parameter. The function returns three values: the computed timestamps, the reshaped iq0 samples, and the reshaped iq1 samples.

Note: It is important to ensure that the input iq array has a length that is compatible with the calculations performed in the function. The iq_len parameter should also be set appropriately to avoid errors during reshaping.

Output Example: A possible appearance of the code's return value could be: (timestamp_array, iq0_capture_array, iq1_capture_array) Where timestamp_array is a NumPy array of timestamps, iq0_capture_array is a NumPy array of IQ samples for channel 0, and iq1_capture_array is a NumPy array of IQ samples for channel 1. For instance: (array([1616161616, 1616161617]), array([1.0+2.0j, 3.0+4.0j]), array([5.0+6.0j, 7.0+8.0j]))

graph TD
    A[Start parse_iq function] --> B[Calculate num_dma_symbol_per_trans]
    B --> C[Calculate num_int16_per_trans]
    C --> D[Calculate num_trans]
    D --> E[Reshape iq array]
    E --> F[Calculate timestamp]
    F --> G[Capture iq0 data]
    G --> H[Capture iq1 data]
    H --> I[Reshape iq0_capture]
    I --> J[Reshape iq1_capture]
    J --> K[Return timestamp, iq0_capture, iq1_capture]
    K --> L[End parse_iq function]