48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import usbtmc
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from matplotlib.ticker import EngFormatter
|
|
|
|
from ssa3032tmc import SSA3023
|
|
|
|
def main():
|
|
|
|
ssa = SSA3023()
|
|
|
|
fig = plt.figure()
|
|
ax = fig.add_subplot(111)
|
|
|
|
|
|
while True:
|
|
ax.clear()
|
|
start_freq = ssa.get_start_freq()
|
|
stop_freq = ssa.get_stop_freq()
|
|
norm_level = ssa.get_norm_ref_level()
|
|
|
|
formatterHz = EngFormatter(unit='Hz')
|
|
ax.xaxis.set_major_formatter(formatterHz)
|
|
|
|
ax.set_xlim(start_freq, stop_freq)
|
|
ax.grid()
|
|
|
|
min_level = norm_level
|
|
|
|
for i in [1,2,3,4]:
|
|
if ssa.is_displayed_trace(i):
|
|
samples = np.array(ssa.get_trace(i))
|
|
min_level = min(np.min(samples), min_level)
|
|
freqs = np.linspace(start_freq, stop_freq, len(samples))
|
|
ax.plot(freqs, samples, label="Trace %d" % i)
|
|
|
|
ax.set_ylim(min_level - 10, norm_level)
|
|
ax.legend()
|
|
|
|
plt.pause(0.250)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|