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