Signal Hound Spike API – SA series (USB-SA44B) Problem reading power at specific frequency

I’m conducting a test of RF modules using the SA series API for Python, but I’m encountering some unexpected results and have some doubts about the configuration. To better understand the issue, I’ll first describe my setup: I have an RFID module connected to a 40dB attenuator, which is then connected to a USB-SA44B spectrum analyzer, with the analyzer connected to a PC. The API I’m using is the one provided by Signal Hound, which includes sa_api.py and sa_api.dll, located in signal_hound_sdkdevice_apissa_seriesexamplespython.

Here is the code:

# -*- coding: utf-8 -*-

from sadevice.sa_api import *
import time
import matplotlib.pyplot as plt
import numpy as np

# Frequency configuration for the 3 channels with a ±200Hz margin
frequencies = [(916300e3, 400), (917500e3, 400), (918700e3, 400)]#,

 
def configure_device(handle, center_freq, span):
    # Set center frequency and span
    sa_config_center_span(handle, center_freq, span)
    sa_config_level(handle, -30.0) 
    sa_config_sweep_coupling(handle, 10e3, 10e3, 0) 
    sa_config_acquisition(handle, SA_MIN_MAX, SA_LOG_SCALE)
    sa_initiate(handle, SA_SWEEPING, 0)


def get_power_for_frequency(handle, center_freq, span):
    query = sa_query_sweep_info(handle)
    sweep_length = query["sweep_length"]
    start_freq = query["start_freq"]
    bin_size = query["bin_size"]

  
    sweep_max = sa_get_sweep_32f(handle)["max"]
    freqs = [start_freq + i * bin_size for i in range(sweep_length)]

    power_values = [(freq, power) for freq, power in zip(freqs, sweep_max)
                    if center_freq - span / 2 <= freq <= center_freq + span / 2] #
    
    return power_values


def print_debug_info(data, elapsed_time):
    print(f"n=== Debug Info at {elapsed_time:.1f} seconds ===")
    for freq in data:
        times = data[freq]["times"]
        powers = data[freq]["powers"]
        print(f"Frequency: {freq}")
        print(f"Times: {times}")
        print(f"Powers: {powers}n")
        print(len(powers))


def collect_and_plot_data():
    # Open device
    handle = sa_open_device()["handle"]
    
    data = {f"{freq[0] / 1e6:.3f} MHz": {"times": [], "powers": []} for freq in frequencies}
    last_debug_time = 0 

    # Collect data for 1 minute
    start_time = time.time()
    while time.time() - start_time < 30:
        elapsed_time = time.time() - start_time 
        for center_freq, span in frequencies:
            configure_device(handle, center_freq, span)
            power_values = get_power_for_frequency(handle, center_freq, span)
            

            for _, power in power_values:
                data[f"{center_freq / 1e6:.3f} MHz"]["times"].append(elapsed_time)
                data[f"{center_freq / 1e6:.3f} MHz"]["powers"].append(power)

        # Debugging output every 10 seconds
        '''
        if int(elapsed_time) % 10 == 0 and elapsed_time > last_debug_time:
            print_debug_info(data, elapsed_time)
            last_debug_time = elapsed_time  # Update the last debug time
        '''
    # Close the device
    sa_close_device(handle)

    # Plot the data
    plt.figure(figsize=(10, 6))
    
    for freq in data:
        if data[freq]["times"]:
            plt.plot(data[freq]["times"], data[freq]["powers"], label=freq, marker='o', linestyle='-')
        
        p = data[freq]["powers"]
        print((data[freq]["powers"]))
        print(np.max(p))

    plt.title("Power vs Time for Different Frequencies")
    plt.xlabel("Time (s)")
    plt.ylabel("Power (dBm)")
    plt.legend(title="Frequency")
    plt.grid(True)
    plt.show()

if __name__ == "__main__":
    collect_and_plot_data()`

I performed a simple 30-second test, reading across 3 channels (with only 1 carrier on) at 2 different power outputs, but the results were not as expected.

Power set Spike UI python
31.5 dBm -8.72 dBm -27.67 dBm
20 dBm -20.28 dBm -75.17 dBm

Since I have a 40dB attenuator the spike results are close to the output power, but the python values are not even 11.5 dBm separated.

31.5 dBm plot:

31.5_dbm

20 dBm plot:

20 dBm

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật