docs: readme update
This commit is contained in:
@@ -8,7 +8,7 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import os
|
||||
|
||||
GEN_CH = 2 # generator chan to cal
|
||||
GEN_CH = 1 # generator chan to cal
|
||||
OSC_CH = 1 # scope chan
|
||||
|
||||
# VISA resource strs
|
||||
@@ -263,4 +263,63 @@ input_hex = f"cal_hfflat{GEN_CH}.hex"
|
||||
output_hex = f"cal_hfflat{GEN_CH}_mod.hex"
|
||||
generate_final_hex(input_hex, output_hex, meas_data)
|
||||
|
||||
# %% [markdown]
|
||||
# Push the generated `cal_hfflat{gen_ch}_mod.hex` to the device.
|
||||
#
|
||||
# I.e. `adb push cal_hfflat1_mod.hex /rigol/data/cal_hfflat1.hex`, reboot, then do the verification sweep if needed.
|
||||
|
||||
# %%
|
||||
def check_final_flatness(controller, gen_ch, osc_ch):
|
||||
print("=" * 32)
|
||||
print(f"Verification sweep: Channel {gen_ch}")
|
||||
print("=" * 32)
|
||||
|
||||
new_meas_data = run_calibration_sweeps(controller, gen_ch, osc_ch)
|
||||
_fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(10, 14))
|
||||
|
||||
plot_cfg = [
|
||||
{"key": "rng1", "title": "Range 1 (Mid: 1.26V)", "freq": FREQ_FULL},
|
||||
{"key": "rng2", "title": "Range 2 (High: 5.0V)", "freq": FREQ_HIGH_VOLT},
|
||||
{"key": "rng3", "title": "Range 3 (Low: 0.63V)", "freq": FREQ_FULL},
|
||||
]
|
||||
|
||||
for i, cfg in enumerate(plot_cfg):
|
||||
key = cfg["key"]
|
||||
freqs_mhz = cfg["freq"] / 1e6
|
||||
vals = new_meas_data[key]
|
||||
|
||||
# flatness ratio = V_meas / V_ref (at 200kHz)
|
||||
ref_val = vals[0]
|
||||
normalized = vals / ref_val
|
||||
|
||||
# peak deviation
|
||||
max_dev = np.max(np.abs(normalized - 1.0)) * 100
|
||||
|
||||
ax = axes[i]
|
||||
ax.plot(freqs_mhz, normalized, "b.-", linewidth=2, label="Measured Response")
|
||||
|
||||
ax.axhline(
|
||||
1.0, color="k", linestyle="-", alpha=0.8, linewidth=1, label="Target (1.0)"
|
||||
)
|
||||
ax.axhline(
|
||||
1.01, color="g", linestyle="--", alpha=0.5, label=r"$\pm 1\%$ Tolerance"
|
||||
)
|
||||
ax.axhline(0.99, color="g", linestyle="--", alpha=0.5)
|
||||
|
||||
ax.set_title(f"{cfg['title']} - Max Deviation: {max_dev:.2f}%")
|
||||
ax.set_ylabel("Normalized Gain ($V_{out} / V_{ref}$)")
|
||||
ax.set_xlabel("Frequency (MHz)")
|
||||
|
||||
if max_dev < 5.0:
|
||||
ax.set_ylim(0.95, 1.05)
|
||||
|
||||
ax.legend(loc="upper right")
|
||||
ax.grid(True, which="both", alpha=0.3)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
|
||||
|
||||
check_final_flatness(instr, GEN_CH, OSC_CH)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user