ZHDU136 June 2026
以下 python 脚本示例可用于直接控制电路板,而无需 GUI。技术参考手册中提供了更多命令。
# pip install pyvisa pyvisa-py
import pyvisa
import time
rm = pyvisa.ResourceManager()
matches = [r for r in rm.list_resources() if '2E8A' in r]
if not matches:
raise RuntimeError('TSG06D00EVM not found - check 12V power and USB cable')
sg = rm.open_resource(matches[0])
sg.timeout = 5000
print(sg.query('*IDN?'))
assert sg.query('*TST?').strip() == 'PASS', 'Self-test failed'
sg.write('SYST:ERR:CLEAR')
# Set 10 MHz Reference to Internal
sg.write('ROSC:SOUR INT')
print(f"Reference Mode: {sg.query('ROSC:SOUR?')}")
# Configure CH A - 1 GHz, -5 dBm, 0° Phase
sg.write('INST:NSEL 1')
sg.write('FREQ 1e9')
sg.write('POW -5')
sg.write('PHAS 0.0')
sg.write('OUTP 1')
time.sleep(0.1)
# Readback State of CH A
freq_a =float(sg.query('FREQ?'))
power_a =float(sg.query('POW?'))
phase_a =float(sg.query('PHAS?'))
output_a =float(sg.query('OUTP?'))
print(f"Channel A:")
print(f" Frequency: {freq_a/1e9:.4f} GHz")
print(f" Power: {power_a:.2f} dBm")
print(f" Phase: {phase_a} deg")
print(f" Output: {'ON'if output_a else'OFF'}")
# Configure CH B - 2.4 GHz, -10 dBm, +90° Phase
sg.write('INST:NSEL 2')
sg.write('FREQ 2.4e9')
sg.write('POW -10')
sg.write('PHAS 90.0')
sg.write('OUTP 1')
time.sleep(0.1)
# Readback State of CH B
freq_b =float(sg.query('FREQ?'))
power_b =float(sg.query('POW?'))
phase_b =float(sg.query('PHAS?'))
output_b =float(sg.query('OUTP?'))
print(f"Channel B:")
print(f" Frequency: {freq_b/1e9:.4f} GHz")
print(f" Power: {power_b:.2f} dBm")
print(f" Phase: {phase_b} deg")
print(f" Output: {'ON'if output_b else'OFF'}")
# Check for Errors
if int(sg.query('SYST:ERR:COUNT?')) >0:
print('Error:', sg.query('SYST:ERR:NEXT?'))
# Uncomment lines below to disable both channels when done
# sg.write('INST:NSEL 1')
# sg.write('OUTP 0')
# sg.write('INST:NSEL 2')
# sg.write('OUTP 0')
# sg.close()