commit 76b0ebe25aede6d5711c4cdbbd0a0e2dd68fdb5d parent e75cd2ede43e7c31b9220f870932c98da4dce107 Author: Martin Klöckner <mjkloeckner@gmail.com> Date: Fri, 21 Aug 2026 15:48:56 -0300 Actualizar `tp/scripts/*` Diffstat:
21 files changed, 236 insertions(+), 2926 deletions(-) diff --git a/tp/scripts/owon_hds25s_bode/main.m b/tp/scripts/owon_hds25s_bode/bode_plot.m diff --git a/tp/scripts/owon_hds25s_bode/bode_plot.py b/tp/scripts/owon_hds25s_bode/bode_plot.py @@ -1,225 +0,0 @@ -import pyvisa -import time -import numpy as np - -# List of all valid timebases supported by OWON HDS2* series -TIMEBASES = [ - (2e-9, "2.0ns"), (5e-9, "5.0ns"), (10e-9, "10.0ns"), (20e-9, "20.0ns"), - (50e-9, "50.0ns"), (100e-9, "100ns"), (200e-9, "200ns"), (500e-9, "500ns"), - (1e-6, "1.0us"), (2e-6, "2.0us"), (5e-6, "5.0us"), (10e-6, "10us"), - (20e-6, "20us"), (50e-6, "50us"), (100e-6, "100us"), (200e-6, "200us"), - (500e-6, "500us"), (1e-3, "1.0ms"), (2e-3, "2.0ms"), (5e-3, "5.0ms"), - (10e-3, "10ms"), (20e-3, "20ms"), (50e-3, "50ms"), (100e-3, "100ms"), - (200e-3, "200ms"), (500e-3, "500ms"), (1.0, "1.0s"), (2.0, "2.0s"), - (5.0, "5.0s"), (10.0, "10s"), (20.0, "20s"), (50.0, "50s"), - (100.0, "100s"), (200.0, "200s"), (500.0, "500s"), (1000.0, "1000s") -] - -# Supported scale tables according to probe attenuation -VOLT_SCALES = { - "1X": [ - (0.010, "10.0mV"), (0.020, "20.0mV"), (0.050, "50.0mV"), - (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V") - ], - "10X": [ - (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V") - ], - "100X": [ - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), - (1000.0, "1.00kV") - ], - "1000X": [ - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), - (1000.0, "1.00kV"),(2000.0, "2.00kV"),(5000.0, "5.00kV"), - (10000.0, "10.0kV") - ] -} - -LOG_ENABLE = False -PROBE = "1X" -GEN_PEAK = 0.10 # 2*GEN_PEAK peak to peak voltage -FREQS_COUNT = 50 -MEAN_SAMPLE_COUNT = 3 -curr_scale_idx = 2 # 500 mV startup vertical height -scales = VOLT_SCALES.get(PROBE) - -def LOG(msg): - if LOG_ENABLE: - print(f"[LOG] {msg}") - -def LOG_LOC(loc, msg): - if LOG_ENABLE: - print(f"[LOG]{loc} {msg}") - -def set_best_timebase(frequency): - period = 1.0 / frequency - target_scale = period / 2.0 # Display width is roughly 10 divisions - - # Pick the closest supported value in the list - best_match = min(TIMEBASES, key=lambda x: abs(x[0] - target_scale)) - LOG(f"HORizontal:SCALe {best_match[1]}") - time.sleep(0.1) - scope.write(f":HORizontal:SCALe {best_match[1]}") - -def set_best_vert_scale(): - global curr_scale_idx - - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - LOG_LOC("[set_best_vert_scale]", f"read_val_str == {read_val_str}") - - while read_val_str.startswith(">"): - LOG_LOC("[set_best_vert_scale]['>']", f"startswith('>')") - if curr_scale_idx <= 9: - curr_scale_idx = curr_scale_idx + 1 - new_scale = scales[curr_scale_idx][1] - LOG_LOC("[set_best_vert_scale]['>']", f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - - # Read again with new scale - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - LOG_LOC("[set_best_vert_scale]['>'][read again]", f"read_val_str == {read_val_str}") - else: - read_val_str.lstrip(">") - - while read_val_str.startswith("<"): - LOG_LOC("[set_best_vert_scale]['<']", f"startswith('<')") - if curr_scale_idx > 0: - curr_scale_idx = curr_scale_idx - 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - - # Read again with new scale - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - LOG_LOC("[set_best_vert_scale]['<']", f"read_val_str == {read_val_str}") - else: - read_val_str.lstrip("<") - - read_val = float(read_val_str) - LOG_LOC("[set_best_vert_scale]", f"read_val == {read_val_str}") - - if curr_scale_idx > 0 and read_val < 2*scales[curr_scale_idx - 1][0]: - curr_scale_idx = curr_scale_idx - 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - if freq < 10: - # Roll mode - time.sleep(10) - - # Read again with new scale - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - LOG_LOC("[set_best_vert_scale][read_val < 2*next_scale", f"read_val_str == {read_val_str}") - - while read_val_str.startswith(">") or read_val_str.startswith("<"): - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - - read_val = float(read_val_str) - -# example: 5 decades (10^0 to 10^5) at 5 points/decade -> 5 * 5 + 1 = 26 points -# freqs = np.concatenate((np.array([1]), np.logspace(4, 5, num=FREQS_COUNT))) -freqs = np.logspace(0, 5, num=FREQS_COUNT) -freqs = np.unique([int(f) for f in freqs]) -print(freqs) -amps = [] - -rm = pyvisa.ResourceManager('@py') - -try: - scope = rm.open_resource("ASRL/dev/ttyUSB0::INSTR") -except: - print("[ERROR] Device not found") - exit(0) - -try: - data = scope.read_raw() - print("Pending:", data) -except pyvisa.errors.VisaIOError as e: - print("No data") - -print("Identification: ", scope.query("*IDN?"), end="") - -# Configure scope -scope.write(f":CH1:SCALe {scales[curr_scale_idx][1]}") -scope.write(":CH1:COUPling AC") -scope.write(f":CH1:PROBE {PROBE}") -scope.write(f":FUNCtion:AMPLitude {GEN_PEAK*2}") -scope.write(":FUNCtion SINE") - -print(f"Generator set to function SINE") -# print(" freq, amp/peak") - -for freq in freqs: - # print(f"Probing {freq:2.2f} Hz") - scope.write(f":FUNCtion:FREQuency {freq:2.2f}") - - # print(scope.query(":FUNCtion:FREQuency?")) - set_best_timebase(freq) - - # Roll mode - if freq < 10: - scope.write(":CH1:COUPling DC") - time.sleep(10) - else: - scope.write(":CH1:COUPling AC") - time.sleep(0.5) - - amp_arr = [] - for i in range(MEAN_SAMPLE_COUNT): - set_best_vert_scale() - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - LOG_LOC(f"[main_loop]", f"read_val_str == {read_val_str}") - - while read_val_str.startswith(">") or read_val_str.startswith("<"): - set_best_vert_scale() - read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() - LOG_LOC(f"[main_loop]", f"read_val_str == {read_val_str}") - - read_val = float(read_val_str) - - # print(f"{read_val:<3.3f}") - amp_arr.append(read_val) - - time.sleep(0.5) # time between mean samples - - amp_mean = (sum(amp_arr) / MEAN_SAMPLE_COUNT) - amp_mean = 0.001 if amp_mean < 0.001 else amp_mean - - amp_norm = amp_mean / GEN_PEAK - amps.append(amp_norm) - - print(f"{freq:>8}, {amp_norm:<3.3f}") - -scope.close() - -# print(f"freqs = [{' '.join(map(str, freqs))}]") -# print(f"amps = [{' '.join(map(str, amps))}]") - -data = np.column_stack((freqs, amps)) -np.savetxt("bode_10k_plus.csv", - data, - delimiter=",", - header="Frequency,Amplitude", - comments="", - fmt=["%d", "%.3f"]) diff --git a/tp/scripts/owon_hds25s_bode/bode_plot_orig.py b/tp/scripts/owon_hds25s_bode/bode_plot_orig.py @@ -1,214 +0,0 @@ -import pyvisa -import time -import numpy as np - -PROBE = "1X" -GEN_PEAK = 0.10 # 2*GEN_PEAK peak to peak voltage -FREQS_COUNT = 50 # 600 samples - -# List of all valid timebases supported by OWON HDS2* series -TIMEBASES = [ - (2e-9, "2.0ns"), (5e-9, "5.0ns"), (10e-9, "10.0ns"), (20e-9, "20.0ns"), - (50e-9, "50.0ns"), (100e-9, "100ns"), (200e-9, "200ns"), (500e-9, "500ns"), - (1e-6, "1.0us"), (2e-6, "2.0us"), (5e-6, "5.0us"), (10e-6, "10us"), - (20e-6, "20us"), (50e-6, "50us"), (100e-6, "100us"), (200e-6, "200us"), - (500e-6, "500us"), (1e-3, "1.0ms"), (2e-3, "2.0ms"), (5e-3, "5.0ms"), - (10e-3, "10ms"), (20e-3, "20ms"), (50e-3, "50ms"), (100e-3, "100ms"), - (200e-3, "200ms"), (500e-3, "500ms"), (1.0, "1.0s"), (2.0, "2.0s"), - (5.0, "5.0s"), (10.0, "10s"), (20.0, "20s"), (50.0, "50s"), - (100.0, "100s"), (200.0, "200s"), (500.0, "500s"), (1000.0, "1000s") -] - -# Supported scale tables according to probe attenuation -VOLT_SCALES = { - "1X": [ - (0.010, "10.0mV"), (0.020, "20.0mV"), (0.050, "50.0mV"), - (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V") - ], - "10X": [ - (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V") - ], - "100X": [ - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), - (1000.0, "1.00kV") - ], - "1000X": [ - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), - (1000.0, "1.00kV"),(2000.0, "2.00kV"),(5000.0, "5.00kV"), - (10000.0, "10.0kV") - ] -} - -def set_best_timebase(frequency): - period = 1.0 / frequency - target_scale = period / 2.0 # Display width is roughly 10 divisions - - # Pick the closest supported value in the list - best_match = min(TIMEBASES, key=lambda x: abs(x[0] - target_scale)) - # print(f":HORizontal:SCALe {best_match[1]}") - scope.write(f":HORizontal:SCALe {best_match[1]}") - -def set_best_vert_scale(read_val, ch=1): - pass - -# example: 5 decades (10^0 to 10^5) at 5 points/decade -> 5 * 5 + 1 = 26 points -freqs = np.concatenate((np.array([1]), np.logspace(1, 5, num=FREQS_COUNT))) -freqs = np.unique([int(f) for f in freqs]) -print(freqs) -amps = [] - -rm = pyvisa.ResourceManager('@py') - -scope = rm.open_resource("ASRL/dev/ttyUSB0::INSTR") -print("Identification: ", scope.query("*IDN?"), end="") - -# Configure scope -scales = VOLT_SCALES.get(PROBE) -curr_scale_idx = 2 # 500 mV startup vertical height -scope.write(f":CH1:SCALe {scales[curr_scale_idx][1]}") -scope.write(":CH1:COUPling DC") -scope.write(f":CH1:PROBE {PROBE}") -scope.write(f":FUNCtion:AMPLitude {GEN_PEAK*2}") -scope.write(":FUNCtion SINE") - -print(f"Generator set to function SINE") -print(" freq, amp/peak") - -for freq in freqs: - scope.write(f":FUNCtion:FREQuency {freq}") - set_best_timebase(freq) - - # Roll mode - if freq < 10: - time.sleep(10) - - # amp = float(scope.query(":MEASurement:CH1:MAX?").strip()) - - amp_arr = [] - amp_arr_mean_sample_count = 3 - for i in range(amp_arr_mean_sample_count): - set_best_vert_scale(read_val, ch=1) - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - - read_val = scope.query(":MEASurement:CH1:MAX?").strip() - read_val = float(read_val) - - while read_val.startswith(">"): - curr_scale_idx = curr_scale_idx + 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - # Read again with new scale - read_val = scope.query(":MEASurement:CH1:MAX?").strip() - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - - while read_val.startswith("<"): - if curr_scale_idx > 0: - curr_scale_idx = curr_scale_idx - 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - # Read again with new scale - read_val = scope.query(":MEASurement:CH1:MAX?").strip() - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - else: - read_val.lstrip("<") - - - if curr_scale_idx > 0 and read_val < 3*scales[curr_scale_idx - 1][0]: - curr_scale_idx = curr_scale_idx - 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - if freq < 10: - # Roll mode - time.sleep(10) - - # Read again with new scale - read_val = scope.query(":MEASurement:CH1:MAX?").strip() - - while read_val.startswith(">"): - curr_scale_idx = curr_scale_idx + 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - # Read again with new scale - read_val = scope.query(":MEASurement:CH1:MAX?").strip() - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - - while read_val.startswith("<"): - if curr_scale_idx > 0: - curr_scale_idx = curr_scale_idx - 1 - new_scale = scales[curr_scale_idx][1] - # print(f"Changing vertical scale to {new_scale}") - scope.write(f":CH1:SCALe {new_scale}") - - # Read again with new scale - read_val = scope.query(":MEASurement:CH1:MAX?").strip() - - if freq < 10: - # Roll mode - time.sleep(10) - else: - time.sleep(1) - else: - read_val.lstrip("<") - - read_val = float(read_val) - - time.sleep(1) - # print(f"{read_val:<3.3f}") - amp_arr.append(read_val) - - amp_mean = (sum(amp_arr) / amp_arr_mean_sample_count) - amp_mean = 0.001 if amp_mean < 0.001 else amp_mean - - amp_norm = amp_mean / GEN_PEAK - amps.append(amp_norm) - - print(f"{freq:>8}, {amp_norm:<3.3f}") - -scope.close() - -# print(f"freqs = [{' '.join(map(str, freqs))}]") -# print(f"amps = [{' '.join(map(str, amps))}]") - -data = np.column_stack((freqs, amps)) -np.savetxt("bode_data.csv", - data, - delimiter=",", - header="Frequency,Amplitude", - comments="", - fmt=["%d", "%.3f"]) diff --git a/tp/scripts/owon_hds25s_bode/bode_scpi_data.py b/tp/scripts/owon_hds25s_bode/bode_scpi_data.py @@ -0,0 +1,226 @@ +import pyvisa +import time +import numpy as np + +# List of all valid timebases supported by OWON HDS2* series +TIMEBASES = [ + (2e-9, "2.0ns"), (5e-9, "5.0ns"), (10e-9, "10.0ns"), (20e-9, "20.0ns"), + (50e-9, "50.0ns"), (100e-9, "100ns"), (200e-9, "200ns"), (500e-9, "500ns"), + (1e-6, "1.0us"), (2e-6, "2.0us"), (5e-6, "5.0us"), (10e-6, "10us"), + (20e-6, "20us"), (50e-6, "50us"), (100e-6, "100us"), (200e-6, "200us"), + (500e-6, "500us"), (1e-3, "1.0ms"), (2e-3, "2.0ms"), (5e-3, "5.0ms"), + (10e-3, "10ms"), (20e-3, "20ms"), (50e-3, "50ms"), (100e-3, "100ms"), + (200e-3, "200ms"), (500e-3, "500ms"), (1.0, "1.0s"), (2.0, "2.0s"), + (5.0, "5.0s"), (10.0, "10s"), (20.0, "20s"), (50.0, "50s"), + (100.0, "100s"), (200.0, "200s"), (500.0, "500s"), (1000.0, "1000s") +] + +# Supported scale tables according to probe attenuation +VOLT_SCALES = { + "1X": [ + (0.010, "10.0mV"), (0.020, "20.0mV"), (0.050, "50.0mV"), + (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), + (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), + (10.00, "10.0V") + ], + "10X": [ + (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), + (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), + (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), + (100.0, "100V") + ], + "100X": [ + (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), + (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), + (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), + (1000.0, "1.00kV") + ], + "1000X": [ + (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), + (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), + (1000.0, "1.00kV"),(2000.0, "2.00kV"),(5000.0, "5.00kV"), + (10000.0, "10.0kV") + ] +} + +CSV_FILEPATH = "csv/bode_data.csv" +LOG_ENABLE = False +PROBE = "1X" +GEN_PEAK = 0.10 # 2*GEN_PEAK peak to peak voltage +FREQS_COUNT = 10 +MEAN_SAMPLE_COUNT = 3 +curr_scale_idx = 2 # 500 mV startup vertical height +scales = VOLT_SCALES.get(PROBE) + +def LOG(msg): + if LOG_ENABLE: + print(f"[LOG] {msg}") + +def LOG_LOC(loc, msg): + if LOG_ENABLE: + print(f"[LOG]{loc} {msg}") + +def set_best_timebase(frequency): + period = 1.0 / frequency + target_scale = period / 2.0 # Display width is roughly 10 divisions + + # Pick the closest supported value in the list + best_match = min(TIMEBASES, key=lambda x: abs(x[0] - target_scale)) + LOG(f"HORizontal:SCALe {best_match[1]}") + time.sleep(0.1) + scope.write(f":HORizontal:SCALe {best_match[1]}") + +def set_best_vert_scale(): + global curr_scale_idx + + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + LOG_LOC("[set_best_vert_scale]", f"read_val_str == {read_val_str}") + + while read_val_str.startswith(">"): + LOG_LOC("[set_best_vert_scale]['>']", f"startswith('>')") + if curr_scale_idx <= 9: + curr_scale_idx = curr_scale_idx + 1 + new_scale = scales[curr_scale_idx][1] + LOG_LOC("[set_best_vert_scale]['>']", f"Changing vertical scale to {new_scale}") + scope.write(f":CH1:SCALe {new_scale}") + + if freq < 10: + # Roll mode + time.sleep(10) + else: + time.sleep(1) + + # Read again with new scale + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + LOG_LOC("[set_best_vert_scale]['>'][read again]", f"read_val_str == {read_val_str}") + else: + read_val_str.lstrip(">") + + while read_val_str.startswith("<"): + LOG_LOC("[set_best_vert_scale]['<']", f"startswith('<')") + if curr_scale_idx > 0: + curr_scale_idx = curr_scale_idx - 1 + new_scale = scales[curr_scale_idx][1] + # print(f"Changing vertical scale to {new_scale}") + scope.write(f":CH1:SCALe {new_scale}") + + if freq < 10: + # Roll mode + time.sleep(10) + else: + time.sleep(1) + + # Read again with new scale + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + LOG_LOC("[set_best_vert_scale]['<']", f"read_val_str == {read_val_str}") + else: + read_val_str.lstrip("<") + + read_val = float(read_val_str) + LOG_LOC("[set_best_vert_scale]", f"read_val == {read_val_str}") + + if curr_scale_idx > 0 and read_val < 2*scales[curr_scale_idx - 1][0]: + curr_scale_idx = curr_scale_idx - 1 + new_scale = scales[curr_scale_idx][1] + # print(f"Changing vertical scale to {new_scale}") + scope.write(f":CH1:SCALe {new_scale}") + + if freq < 10: + # Roll mode + time.sleep(10) + + # Read again with new scale + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + LOG_LOC("[set_best_vert_scale][read_val < 2*next_scale", f"read_val_str == {read_val_str}") + + while read_val_str.startswith(">") or read_val_str.startswith("<"): + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + + read_val = float(read_val_str) + +# example: 5 decades (10^0 to 10^5) at 5 points/decade -> 5 * 5 + 1 = 26 points +# freqs = np.concatenate((np.array([1]), np.logspace(4, 5, num=FREQS_COUNT))) +freqs = np.logspace(0, 5, num=FREQS_COUNT) +freqs = np.unique([int(f) for f in freqs]) +print(freqs) +amps = [] + +rm = pyvisa.ResourceManager('@py') + +try: + scope = rm.open_resource("ASRL/dev/ttyUSB0::INSTR") +except: + print("[ERROR] Device not found") + exit(0) + +try: + data = scope.read_raw() + print("Pending:", data) +except pyvisa.errors.VisaIOError as e: + print("No pending SCPI data") + +print("Identification: ", scope.query("*IDN?"), end="") + +# Configure scope +scope.write(f":CH1:SCALe {scales[curr_scale_idx][1]}") +scope.write(":CH1:COUPling AC") +scope.write(f":CH1:PROBE {PROBE}") +scope.write(f":FUNCtion:AMPLitude {GEN_PEAK*2}") +scope.write(":FUNCtion SINE") + +print(f"Generator set to function SINE") +# print(" freq, amp/peak") + +for freq in freqs: + # print(f"Probing {freq:2.2f} Hz") + scope.write(f":FUNCtion:FREQuency {freq:2.2f}") + + # print(scope.query(":FUNCtion:FREQuency?")) + set_best_timebase(freq) + + # Roll mode + if freq < 10: + scope.write(":CH1:COUPling DC") + time.sleep(10) + else: + scope.write(":CH1:COUPling AC") + time.sleep(0.5) + + amp_arr = [] + for i in range(MEAN_SAMPLE_COUNT): + set_best_vert_scale() + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + LOG_LOC(f"[main_loop]", f"read_val_str == {read_val_str}") + + while read_val_str.startswith(">") or read_val_str.startswith("<"): + set_best_vert_scale() + read_val_str = scope.query(":MEASurement:CH1:MAX?").strip() + LOG_LOC(f"[main_loop]", f"read_val_str == {read_val_str}") + + read_val = float(read_val_str) + + # print(f"{read_val:<3.3f}") + amp_arr.append(read_val) + + time.sleep(0.5) # time between mean samples + + amp_mean = (sum(amp_arr) / MEAN_SAMPLE_COUNT) + amp_mean = 0.001 if amp_mean < 0.001 else amp_mean + + amp_norm = amp_mean / GEN_PEAK + amps.append(amp_norm) + + print(f"{freq:>8}, {amp_norm:<3.3f}") + +scope.close() + +# print(f"freqs = [{' '.join(map(str, freqs))}]") +# print(f"amps = [{' '.join(map(str, amps))}]") + +data = np.column_stack((freqs, amps)) +np.savetxt(f"{CSV_FILEPATH}", + data, + delimiter=",", + header="Frequency,Amplitude", + comments="", + fmt=["%d", "%.3f"]) diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_data.csv b/tp/scripts/owon_hds25s_bode/csv/bode_data.csv @@ -1,52 +1,11 @@ Frequency,Amplitude -1,5.733 -10,5.840 -12,5.947 -14,6.160 -17,6.400 -21,6.560 -25,6.667 -30,6.880 -37,7.280 -44,7.573 -54,8.107 -65,8.667 -79,9.400 -95,9.600 -115,10.333 -138,10.800 -167,11.533 -202,12.000 -244,12.533 -294,13.333 -355,15.000 -429,17.467 -517,20.933 -625,24.667 -754,19.200 -910,11.200 -1098,5.400 -1325,3.333 -1599,2.587 -1930,1.360 -2329,0.847 -2811,0.780 -3393,0.256 -4094,0.357 -4941,0.211 -5963,0.047 -7196,0.010 -8685,0.229 -10481,0.037 -12648,0.060 -15264,0.135 -18420,0.010 -22229,0.031 -26826,0.053 -32374,0.010 -39069,0.156 -47148,0.027 -56898,0.010 -68664,0.010 -82864,0.010 -100000,0.123 +1,1.000 +3,1.000 +12,1.000 +46,0.980 +166,0.980 +599,0.980 +2154,0.980 +7742,0.980 +27825,0.980 +100000,0.980 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_plain.csv b/tp/scripts/owon_hds25s_bode/csv/bode_plain.csv @@ -1,53 +0,0 @@ -Frequency,Amplitude -1,0.98 -5,1.02 -10,1.03 -12,1.00 -14,1.00 -17,1.00 -21,1.00 -25,1.00 -30,1.02 -37,1.02 -44,1.00 -54,1.01 -65,0.99 -79,1.00 -95,1.00 -115,1.00 -138,1.00 -167,1.01 -202,1.01 -244,1.01 -294,1.00 -355,1.00 -429,0.99 -517,1.00 -625,1.00 -754,1.00 -910,1.02 -1098,1.01 -1325,0.99 -1599,1.00 -1930,1.00 -2329,1.01 -2811,1.01 -3393,1.01 -4094,1.00 -4941,0.99 -5963,1.02 -7196,1.00 -8685,1.01 -10481,1.01 -12648,1.00 -15264,1.01 -18420,1.01 -22229,1.00 -26826,1.01 -32374,1.01 -39069,1.02 -47148,1.02 -56898,1.02 -68664,1.02 -82864,1.02 -100000,1.02 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_rc_highpass.csv b/tp/scripts/owon_hds25s_bode/csv/bode_rc_highpass.csv @@ -1,53 +0,0 @@ -Frequency,Amplitude -1,0.04 -5,0.06 -10,0.06 -12,0.06 -14,0.06 -17,0.06 -21,0.06 -25,0.06 -30,0.06 -37,0.06 -44,0.06 -54,0.06 -65,0.06 -79,0.06 -95,0.06 -115,0.06 -138,0.06 -167,0.06 -202,0.06 -244,0.06 -294,0.06 -355,0.06 -429,0.06 -517,0.06 -625,0.06 -754,0.06 -910,0.06 -1098,0.06 -1325,0.06 -1599,0.24 -1930,0.94 -2329,0.96 -2811,0.94 -3393,0.96 -4094,0.96 -4941,0.96 -5963,0.96 -7196,0.96 -8685,0.96 -10481,0.96 -12648,0.96 -15264,0.96 -18420,0.96 -22229,0.96 -26826,0.96 -32374,0.96 -39069,0.96 -47148,0.96 -56898,0.96 -68664,0.96 -82864,0.96 -100000,0.96 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_1000_pts.csv b/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_1000_pts.csv @@ -1,998 +0,0 @@ -Frequency,Amplitude -1,0.53 -5,0.96 -10,0.98 -20,1.01 -40,1.01 -80,1.01 -100,1.00 -101,1.00 -102,1.00 -103,1.00 -104,1.00 -105,1.00 -106,1.00 -107,1.00 -108,1.00 -109,1.00 -110,1.00 -111,1.00 -112,1.00 -113,1.00 -114,1.00 -115,1.00 -116,1.00 -117,1.00 -118,1.00 -119,1.00 -120,0.99 -121,1.00 -122,1.00 -123,0.99 -124,0.99 -125,0.99 -126,0.99 -127,0.99 -128,0.99 -129,0.99 -130,0.99 -131,0.99 -132,0.99 -133,0.99 -134,0.99 -135,0.99 -136,0.99 -137,0.99 -138,0.99 -139,0.99 -140,0.99 -141,0.99 -142,0.99 -143,0.99 -144,0.99 -145,0.99 -146,0.99 -147,0.99 -148,0.99 -149,0.99 -150,0.99 -151,0.99 -152,0.99 -153,0.99 -154,0.99 -155,0.99 -156,0.99 -157,0.99 -158,0.99 -160,0.99 -161,0.99 -162,0.99 -163,0.99 -164,0.99 -165,0.99 -166,0.99 -167,0.99 -169,0.99 -170,0.99 -171,0.99 -172,0.99 -173,0.99 -175,0.99 -176,0.99 -177,0.99 -178,0.99 -179,0.99 -181,0.99 -182,0.99 -183,0.99 -185,0.99 -186,0.99 -187,0.99 -188,0.99 -190,0.99 -191,0.99 -192,0.99 -194,0.99 -195,0.99 -196,0.99 -198,0.98 -199,0.98 -201,0.98 -202,0.98 -203,0.98 -205,0.97 -206,0.97 -208,0.97 -209,0.97 -211,0.97 -212,0.97 -213,0.97 -215,0.97 -216,0.97 -218,0.97 -219,0.97 -221,0.97 -223,0.97 -224,0.97 -226,0.97 -227,0.96 -229,0.96 -230,0.96 -232,0.96 -234,0.96 -235,0.96 -237,0.96 -238,0.96 -240,0.96 -242,0.96 -243,0.95 -245,0.95 -247,0.95 -249,0.95 -250,0.95 -252,0.95 -254,0.95 -256,0.95 -257,0.95 -259,0.95 -261,0.95 -263,0.95 -265,0.95 -266,0.95 -268,0.95 -270,0.95 -272,0.95 -274,0.95 -276,0.95 -278,0.95 -280,0.95 -282,0.94 -284,0.94 -286,0.93 -288,0.93 -290,0.93 -292,0.92 -294,0.92 -296,0.92 -298,0.92 -300,0.92 -302,0.92 -304,0.92 -306,0.92 -308,0.92 -310,0.92 -312,0.92 -315,0.92 -317,0.92 -319,0.91 -321,0.91 -323,0.91 -326,0.91 -328,0.91 -330,0.91 -333,0.91 -335,0.90 -337,0.90 -340,0.89 -342,0.89 -344,0.89 -347,0.89 -349,0.89 -352,0.89 -354,0.89 -356,0.89 -359,0.89 -361,0.89 -364,0.88 -366,0.88 -369,0.88 -372,0.88 -374,0.88 -377,0.88 -379,0.88 -382,0.88 -385,0.88 -387,0.88 -390,0.88 -393,0.88 -395,0.88 -398,0.88 -401,0.88 -404,0.88 -407,0.88 -409,0.87 -412,0.87 -415,0.87 -418,0.87 -421,0.86 -424,0.86 -427,0.85 -430,0.85 -433,0.85 -436,0.85 -439,0.85 -442,0.85 -445,0.85 -448,0.85 -451,0.85 -454,0.85 -457,0.84 -460,0.84 -464,0.84 -467,0.84 -470,0.84 -473,0.84 -477,0.83 -480,0.83 -483,0.83 -487,0.83 -490,0.82 -493,0.82 -497,0.81 -500,0.81 -504,0.81 -507,0.80 -511,0.80 -514,0.80 -518,0.80 -522,0.80 -525,0.80 -529,0.80 -532,0.80 -536,0.80 -540,0.80 -544,0.79 -547,0.79 -551,0.79 -555,0.79 -559,0.79 -563,0.78 -567,0.77 -571,0.77 -575,0.77 -579,0.77 -583,0.77 -587,0.77 -591,0.77 -595,0.76 -599,0.76 -603,0.76 -607,0.76 -612,0.76 -616,0.76 -620,0.76 -624,0.76 -629,0.75 -633,0.75 -637,0.75 -642,0.75 -646,0.75 -651,0.74 -655,0.74 -660,0.73 -665,0.73 -669,0.73 -674,0.72 -678,0.72 -683,0.72 -688,0.72 -693,0.71 -697,0.71 -702,0.71 -707,0.71 -712,0.71 -717,0.71 -722,0.70 -727,0.70 -732,0.69 -737,0.69 -742,0.69 -747,0.68 -753,0.68 -758,0.68 -763,0.68 -768,0.68 -774,0.67 -779,0.67 -785,0.67 -790,0.67 -795,0.65 -801,0.65 -807,0.65 -812,0.65 -818,0.65 -823,0.65 -829,0.65 -835,0.65 -841,0.65 -847,0.64 -852,0.64 -858,0.64 -864,0.64 -870,0.64 -876,0.64 -882,0.63 -889,0.63 -895,0.63 -901,0.62 -907,0.61 -914,0.61 -920,0.61 -926,0.61 -933,0.61 -939,0.61 -946,0.60 -952,0.60 -959,0.60 -966,0.60 -972,0.60 -979,0.59 -986,0.59 -993,0.59 -1000,0.59 -1006,0.58 -1013,0.57 -1020,0.56 -1028,0.56 -1035,0.56 -1042,0.56 -1049,0.56 -1056,0.56 -1064,0.56 -1071,0.55 -1079,0.55 -1086,0.55 -1094,0.55 -1101,0.55 -1109,0.55 -1116,0.55 -1124,0.55 -1132,0.54 -1140,0.53 -1148,0.53 -1156,0.53 -1164,0.52 -1172,0.52 -1180,0.52 -1188,0.52 -1196,0.52 -1205,0.52 -1213,0.51 -1222,0.51 -1230,0.51 -1239,0.51 -1247,0.50 -1256,0.49 -1265,0.49 -1273,0.49 -1282,0.49 -1291,0.49 -1300,0.48 -1309,0.48 -1318,0.48 -1327,0.48 -1336,0.47 -1346,0.47 -1355,0.47 -1365,0.47 -1374,0.47 -1384,0.47 -1393,0.46 -1403,0.46 -1413,0.45 -1422,0.45 -1432,0.45 -1442,0.44 -1452,0.44 -1462,0.44 -1472,0.44 -1483,0.44 -1493,0.44 -1503,0.44 -1514,0.44 -1524,0.43 -1535,0.43 -1545,0.43 -1556,0.43 -1567,0.43 -1578,0.43 -1589,0.43 -1600,0.43 -1611,0.42 -1622,0.41 -1633,0.41 -1645,0.41 -1656,0.41 -1668,0.41 -1679,0.40 -1691,0.40 -1703,0.40 -1714,0.40 -1726,0.39 -1738,0.39 -1750,0.39 -1762,0.38 -1775,0.38 -1787,0.37 -1799,0.37 -1812,0.37 -1824,0.37 -1837,0.37 -1850,0.37 -1863,0.37 -1876,0.37 -1889,0.36 -1902,0.36 -1915,0.36 -1928,0.36 -1942,0.35 -1955,0.35 -1969,0.35 -1982,0.35 -1996,0.35 -2010,0.35 -2024,0.35 -2038,0.34 -2052,0.34 -2066,0.33 -2081,0.33 -2095,0.33 -2110,0.32 -2124,0.32 -2139,0.32 -2154,0.32 -2169,0.32 -2184,0.32 -2199,0.32 -2214,0.32 -2230,0.32 -2245,0.32 -2261,0.32 -2276,0.32 -2292,0.32 -2308,0.31 -2324,0.31 -2340,0.31 -2357,0.31 -2373,0.31 -2389,0.31 -2406,0.30 -2423,0.30 -2439,0.29 -2456,0.29 -2473,0.29 -2491,0.29 -2508,0.29 -2525,0.28 -2543,0.28 -2560,0.28 -2578,0.28 -2596,0.28 -2614,0.28 -2632,0.28 -2651,0.28 -2669,0.27 -2688,0.27 -2706,0.27 -2725,0.27 -2744,0.27 -2763,0.27 -2782,0.26 -2801,0.26 -2821,0.25 -2840,0.25 -2860,0.25 -2880,0.25 -2900,0.25 -2920,0.25 -2940,0.24 -2961,0.25 -2981,0.24 -3002,0.24 -3023,0.24 -3044,0.24 -3065,0.24 -3086,0.24 -3108,0.23 -3129,0.23 -3151,0.23 -3173,0.23 -3195,0.23 -3217,0.23 -3239,0.23 -3262,0.23 -3284,0.23 -3307,0.23 -3330,0.23 -3353,0.23 -3376,0.22 -3400,0.22 -3424,0.21 -3447,0.21 -3471,0.21 -3495,0.21 -3520,0.21 -3544,0.21 -3569,0.21 -3593,0.21 -3618,0.21 -3643,0.21 -3669,0.21 -3694,0.21 -3720,0.21 -3746,0.21 -3772,0.20 -3798,0.21 -3824,0.21 -3851,0.20 -3877,0.20 -3904,0.20 -3931,0.20 -3959,0.20 -3986,0.20 -4014,0.20 -4042,0.20 -4070,0.20 -4098,0.19 -4126,0.19 -4155,0.19 -4184,0.19 -4213,0.19 -4242,0.19 -4271,0.19 -4301,0.19 -4331,0.19 -4361,0.19 -4391,0.19 -4422,0.19 -4452,0.18 -4483,0.18 -4514,0.17 -4546,0.17 -4577,0.17 -4609,0.17 -4641,0.17 -4673,0.16 -4706,0.16 -4738,0.16 -4771,0.16 -4804,0.16 -4838,0.16 -4871,0.16 -4905,0.16 -4939,0.16 -4973,0.16 -5008,0.16 -5043,0.16 -5078,0.16 -5113,0.15 -5148,0.15 -5184,0.15 -5220,0.15 -5256,0.15 -5293,0.15 -5329,0.15 -5366,0.15 -5404,0.15 -5441,0.14 -5479,0.14 -5517,0.14 -5555,0.14 -5594,0.13 -5633,0.13 -5672,0.13 -5711,0.13 -5751,0.13 -5791,0.13 -5831,0.13 -5871,0.13 -5912,0.13 -5953,0.13 -5994,0.13 -6036,0.13 -6078,0.13 -6120,0.13 -6162,0.13 -6205,0.13 -6248,0.13 -6292,0.12 -6335,0.12 -6379,0.12 -6424,0.12 -6468,0.12 -6513,0.12 -6558,0.12 -6604,0.12 -6650,0.12 -6696,0.12 -6742,0.12 -6789,0.12 -6836,0.12 -6883,0.12 -6931,0.12 -6979,0.11 -7028,0.11 -7077,0.11 -7126,0.11 -7175,0.11 -7225,0.11 -7275,0.11 -7325,0.11 -7376,0.11 -7427,0.11 -7479,0.11 -7531,0.11 -7583,0.11 -7636,0.11 -7689,0.11 -7742,0.11 -7796,0.11 -7850,0.11 -7904,0.11 -7959,0.11 -8015,0.11 -8070,0.11 -8126,0.11 -8183,0.11 -8239,0.11 -8296,0.11 -8354,0.11 -8412,0.11 -8470,0.11 -8529,0.11 -8588,0.11 -8648,0.11 -8708,0.11 -8768,0.11 -8829,0.11 -8890,0.11 -8952,0.09 -9014,0.09 -9077,0.09 -9140,0.09 -9203,0.09 -9267,0.09 -9331,0.09 -9396,0.12 -9461,0.06 -9527,0.09 -9593,0.09 -9660,0.09 -9727,0.09 -9794,0.09 -9862,0.09 -9931,0.09 -10000,0.09 -10069,0.09 -10139,0.09 -10209,0.09 -10280,0.09 -10351,0.09 -10423,0.09 -10495,0.08 -10568,0.08 -10642,0.08 -10715,0.08 -10790,0.08 -10865,0.08 -10940,0.08 -11016,0.08 -11092,0.08 -11169,0.08 -11247,0.08 -11325,0.08 -11403,0.08 -11483,0.07 -11562,0.07 -11643,0.07 -11723,0.07 -11805,0.07 -11887,0.07 -11969,0.07 -12052,0.07 -12136,0.07 -12220,0.07 -12305,0.07 -12390,0.07 -12476,0.07 -12563,0.07 -12650,0.07 -12738,0.07 -12826,0.07 -12915,0.07 -13005,0.07 -13095,0.07 -13186,0.07 -13277,0.07 -13369,0.07 -13462,0.07 -13556,0.06 -13650,0.06 -13744,0.06 -13840,0.06 -13936,0.06 -14032,0.06 -14130,0.06 -14228,0.06 -14327,0.06 -14426,0.06 -14526,0.06 -14627,0.06 -14728,0.05 -14831,0.06 -14933,0.06 -15037,0.06 -15141,0.06 -15246,0.06 -15352,0.06 -15459,0.06 -15566,0.06 -15674,0.05 -15783,0.06 -15892,0.05 -16003,0.05 -16114,0.05 -16225,0.05 -16338,0.05 -16451,0.05 -16566,0.05 -16681,0.05 -16796,0.05 -16913,0.05 -17030,0.05 -17148,0.05 -17267,0.05 -17387,0.05 -17508,0.05 -17629,0.05 -17752,0.05 -17875,0.05 -17999,0.05 -18124,0.05 -18249,0.05 -18376,0.05 -18504,0.05 -18632,0.05 -18761,0.05 -18891,0.05 -19023,0.05 -19155,0.05 -19287,0.04 -19421,0.05 -19556,0.05 -19692,0.05 -19828,0.05 -19966,0.04 -20104,0.05 -20244,0.05 -20384,0.05 -20526,0.05 -20668,0.04 -20812,0.05 -20956,0.04 -21102,0.05 -21248,0.04 -21395,0.04 -21544,0.04 -21693,0.04 -21844,0.04 -21995,0.04 -22148,0.04 -22302,0.04 -22456,0.04 -22612,0.04 -22769,0.04 -22927,0.04 -23086,0.04 -23246,0.04 -23408,0.04 -23570,0.04 -23734,0.04 -23898,0.04 -24064,0.04 -24231,0.04 -24399,0.04 -24569,0.04 -24739,0.04 -24911,0.03 -25084,0.03 -25258,0.04 -25433,0.04 -25609,0.03 -25787,0.04 -25966,0.04 -26146,0.04 -26328,0.03 -26510,0.03 -26694,0.04 -26880,0.03 -27066,0.03 -27254,0.04 -27443,0.04 -27633,0.04 -27825,0.04 -28018,0.04 -28213,0.04 -28408,0.03 -28605,0.04 -28804,0.04 -29004,0.03 -29205,0.04 -29408,0.04 -29612,0.04 -29817,0.04 -30024,0.04 -30232,0.04 -30442,0.04 -30653,0.04 -30866,0.04 -31080,0.04 -31296,0.04 -31513,0.04 -31732,0.04 -31952,0.03 -32174,0.04 -32397,0.04 -32622,0.04 -32848,0.04 -33076,0.04 -33306,0.04 -33537,0.03 -33769,0.02 -34004,0.04 -34240,0.02 -34477,0.04 -34716,0.04 -34957,0.04 -35200,0.02 -35444,0.02 -35690,0.04 -35938,0.04 -36187,0.04 -36438,0.04 -36691,0.02 -36946,0.02 -37202,0.04 -37460,0.02 -37720,0.04 -37982,0.04 -38245,0.04 -38511,0.04 -38778,0.02 -39047,0.04 -39318,0.04 -39591,0.04 -39865,0.04 -40142,0.04 -40420,0.04 -40701,0.04 -40983,0.03 -41268,0.02 -41554,0.04 -41842,0.02 -42133,0.04 -42425,0.04 -42719,0.02 -43016,0.04 -43314,0.04 -43615,0.04 -43918,0.04 -44222,0.04 -44529,0.04 -44838,0.04 -45149,0.04 -45462,0.03 -45778,0.02 -46096,0.03 -46415,0.02 -46737,0.03 -47062,0.03 -47388,0.02 -47717,0.03 -48048,0.02 -48382,0.03 -48717,0.02 -49055,0.03 -49396,0.03 -49738,0.03 -50084,0.02 -50431,0.02 -50781,0.03 -51133,0.03 -51488,0.02 -51845,0.03 -52205,0.03 -52567,0.03 -52932,0.03 -53299,0.03 -53669,0.03 -54042,0.03 -54417,0.03 -54794,0.03 -55174,0.02 -55557,0.03 -55943,0.03 -56331,0.03 -56722,0.03 -57115,0.03 -57512,0.02 -57911,0.03 -58313,0.03 -58717,0.03 -59125,0.03 -59535,0.02 -59948,0.03 -60364,0.02 -60783,0.03 -61204,0.03 -61629,0.03 -62057,0.03 -62487,0.03 -62921,0.03 -63358,0.03 -63797,0.03 -64240,0.03 -64686,0.02 -65134,0.03 -65586,0.03 -66041,0.03 -66500,0.03 -66961,0.03 -67426,0.03 -67894,0.03 -68365,0.03 -68839,0.03 -69317,0.03 -69798,0.03 -70282,0.03 -70770,0.03 -71261,0.03 -71755,0.03 -72253,0.03 -72754,0.03 -73259,0.03 -73767,0.03 -74279,0.03 -74795,0.03 -75314,0.03 -75836,0.03 -76362,0.03 -76892,0.03 -77426,0.03 -77963,0.03 -78504,0.03 -79049,0.03 -79597,0.03 -80150,0.03 -80706,0.03 -81266,0.03 -81830,0.03 -82397,0.03 -82969,0.03 -83545,0.03 -84124,0.03 -84708,0.03 -85296,0.03 -85888,0.03 -86484,0.03 -87084,0.03 -87688,0.03 -88296,0.03 -88909,0.03 -89526,0.03 -90147,0.03 -90773,0.03 -91403,0.03 -92037,0.03 -92675,0.03 -93318,0.03 -93966,0.03 -94618,0.03 -95275,0.03 -95936,0.03 -96601,0.03 -97272,0.03 -97946,0.03 -98626,0.03 -99310,0.03 -100000,0.03 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_100_points.csv b/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_100_points.csv @@ -1,104 +0,0 @@ -Frequency,Amplitude -1,1.02 -5,1.03 -10,1.04 -10,1.04 -12,1.04 -13,1.04 -14,1.04 -15,1.04 -17,1.04 -19,1.04 -20,1.04 -22,1.04 -25,1.04 -27,1.04 -30,1.04 -33,1.04 -36,1.04 -39,1.04 -43,1.04 -47,1.04 -52,1.04 -57,1.04 -63,1.04 -69,1.04 -75,1.04 -83,1.04 -91,1.04 -100,1.04 -109,1.04 -120,1.04 -131,1.04 -144,1.04 -158,1.04 -173,1.04 -190,1.04 -208,1.04 -229,1.04 -251,1.04 -275,1.04 -301,1.04 -331,1.04 -363,1.04 -398,1.04 -436,1.04 -478,1.04 -524,1.04 -575,1.04 -630,1.04 -691,1.04 -758,1.04 -831,1.04 -912,1.04 -1000,1.04 -1096,1.04 -1202,1.04 -1318,1.04 -1445,0.86 -1584,0.14 -1737,0.11 -1905,0.08 -2089,0.06 -2290,0.07 -2511,0.09 -2754,0.06 -3019,0.08 -3311,0.06 -3630,0.04 -3981,0.03 -4365,0.04 -4786,0.04 -5248,0.02 -5754,0.03 -6309,0.02 -6918,0.02 -7585,0.02 -8317,0.02 -9120,0.02 -10000,0.02 -10964,0.02 -12022,0.02 -13182,0.02 -14454,0.01 -15848,0.00 -17378,0.00 -19054,0.01 -20892,0.00 -22908,0.01 -25118,0.01 -27542,0.00 -30199,0.00 -33113,0.01 -36307,0.01 -39810,0.00 -43651,0.02 -47863,0.01 -52480,0.02 -57543,0.01 -63095,0.02 -69183,0.02 -75857,0.02 -83176,0.01 -91201,0.02 -100000,0.01 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_200_pts.csv b/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_200_pts.csv @@ -1,204 +0,0 @@ -Frequency,Amplitude -1,1.00 -5,1.02 -10,1.02 -10,1.02 -10,1.02 -11,1.02 -12,1.02 -12,1.02 -13,1.02 -13,1.02 -14,1.02 -15,1.02 -15,1.02 -16,1.02 -17,1.02 -18,1.02 -19,1.02 -19,1.02 -20,1.02 -21,1.02 -22,1.02 -23,1.02 -25,1.02 -26,1.02 -27,1.02 -28,1.02 -30,1.02 -31,1.02 -33,1.02 -34,1.02 -36,1.02 -38,1.02 -39,1.02 -41,1.02 -43,1.02 -45,1.02 -47,1.02 -50,1.02 -52,1.02 -54,1.02 -57,1.02 -60,1.02 -63,1.02 -66,1.02 -69,1.02 -72,1.02 -75,1.02 -79,1.02 -83,1.02 -87,1.02 -91,1.02 -95,1.02 -100,1.02 -104,1.02 -109,1.02 -114,1.02 -120,1.02 -125,1.02 -131,1.02 -138,1.02 -144,1.02 -151,1.02 -158,1.02 -165,1.02 -173,1.02 -181,1.02 -190,1.02 -199,1.02 -208,1.02 -218,1.02 -229,1.02 -239,1.02 -251,1.02 -263,1.02 -275,1.02 -288,1.02 -301,1.02 -316,1.02 -331,1.02 -346,1.02 -363,1.02 -380,1.02 -398,1.02 -416,1.02 -436,1.02 -457,1.02 -478,1.02 -501,1.02 -524,1.02 -549,1.02 -575,1.02 -602,1.02 -630,1.02 -660,1.02 -691,1.02 -724,1.02 -758,1.02 -794,1.02 -831,1.02 -870,1.02 -912,1.02 -954,1.02 -1000,1.02 -1047,1.02 -1096,1.02 -1148,1.02 -1202,1.02 -1258,1.02 -1318,1.02 -1380,1.02 -1445,0.84 -1513,0.11 -1584,0.14 -1659,0.12 -1737,0.12 -1819,0.12 -1905,0.10 -1995,0.09 -2089,0.06 -2187,0.07 -2290,0.09 -2398,0.07 -2511,0.10 -2630,0.07 -2754,0.04 -2884,0.04 -3019,0.06 -3162,0.08 -3311,0.06 -3467,0.06 -3630,0.05 -3801,0.04 -3981,0.05 -4168,0.02 -4365,0.02 -4570,0.03 -4786,0.04 -5011,0.06 -5248,0.04 -5495,0.02 -5754,0.02 -6025,0.02 -6309,0.01 -6606,0.02 -6918,0.04 -7244,0.02 -7585,0.02 -7943,0.02 -8317,0.01 -8709,0.03 -9120,0.02 -9549,0.02 -10000,0.02 -10471,0.02 -10964,0.02 -11481,0.02 -12022,0.02 -12589,0.01 -13182,0.02 -13803,0.02 -14454,0.02 -15135,0.00 -15848,0.01 -16595,0.02 -17378,0.01 -18197,0.01 -19054,0.01 -19952,0.00 -20892,0.00 -21877,0.01 -22908,0.01 -23988,0.01 -25118,0.00 -26302,0.01 -27542,0.01 -28840,0.01 -30199,0.00 -31622,0.01 -33113,0.01 -34673,0.01 -36307,0.01 -38018,0.00 -39810,0.00 -41686,0.01 -43651,0.01 -45708,0.00 -47863,0.01 -50118,0.01 -52480,0.01 -54954,0.01 -57543,0.01 -60255,0.00 -63095,0.02 -66069,0.01 -69183,0.01 -72443,0.01 -75857,0.02 -79432,0.02 -83176,0.01 -87096,0.02 -91201,0.02 -95499,0.02 -100000,0.00 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_300_pts.csv b/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_300_pts.csv @@ -1,307 +0,0 @@ -Frequency,Amplitude -1,1.00 -5,1.03 -10,1.04 -20,1.04 -40,1.04 -80,1.04 -100,1.04 -102,1.04 -104,1.04 -107,1.04 -109,1.04 -112,1.04 -114,1.04 -117,1.04 -120,1.04 -123,1.04 -125,1.04 -128,1.04 -131,1.04 -135,1.04 -138,1.04 -141,1.04 -144,1.04 -148,1.04 -151,1.04 -155,1.04 -158,1.04 -162,1.04 -166,1.04 -170,1.04 -174,1.04 -178,1.04 -182,1.04 -186,1.04 -190,1.04 -195,1.04 -199,1.04 -204,1.04 -209,1.04 -214,1.04 -219,1.04 -224,1.04 -229,1.04 -235,1.04 -240,1.04 -246,1.04 -251,1.04 -257,1.04 -263,1.04 -270,1.04 -276,1.04 -282,1.04 -289,1.04 -296,1.04 -303,1.04 -310,1.04 -317,1.04 -324,1.04 -332,1.04 -340,1.04 -348,1.04 -356,1.04 -364,1.04 -373,1.04 -381,1.04 -390,1.04 -399,1.04 -409,1.04 -418,1.04 -428,1.04 -438,1.04 -448,1.04 -459,1.04 -470,1.04 -481,1.04 -492,1.04 -503,1.04 -515,1.04 -527,1.04 -540,1.04 -552,1.04 -565,1.04 -578,1.04 -592,1.04 -606,1.04 -620,1.04 -634,1.04 -649,1.04 -664,1.04 -680,1.04 -696,1.04 -712,1.04 -729,1.04 -746,1.04 -763,1.04 -781,1.04 -799,1.04 -818,1.04 -837,1.04 -857,1.04 -877,1.04 -897,1.04 -918,1.04 -940,1.04 -962,1.04 -984,1.04 -1007,1.04 -1031,1.04 -1055,1.04 -1080,1.04 -1105,1.04 -1131,1.04 -1157,1.04 -1184,1.04 -1212,1.04 -1240,1.04 -1269,1.04 -1299,1.04 -1329,1.04 -1360,1.04 -1392,1.04 -1425,1.04 -1458,0.86 -1492,0.13 -1527,0.11 -1563,0.13 -1599,0.10 -1636,0.08 -1675,0.08 -1714,0.09 -1754,0.11 -1795,0.08 -1837,0.09 -1880,0.11 -1924,0.08 -1969,0.06 -2015,0.06 -2062,0.07 -2110,0.12 -2159,0.09 -2210,0.06 -2262,0.06 -2314,0.07 -2369,0.09 -2424,0.06 -2481,0.05 -2539,0.08 -2598,0.09 -2659,0.04 -2721,0.06 -2784,0.07 -2850,0.04 -2916,0.04 -2984,0.04 -3054,0.06 -3125,0.04 -3199,0.04 -3273,0.04 -3350,0.06 -3428,0.05 -3508,0.05 -3590,0.04 -3674,0.05 -3760,0.05 -3848,0.06 -3938,0.04 -4030,0.04 -4124,0.04 -4221,0.04 -4319,0.03 -4420,0.04 -4523,0.04 -4629,0.03 -4737,0.04 -4848,0.04 -4961,0.02 -5077,0.04 -5196,0.05 -5318,0.03 -5442,0.04 -5569,0.04 -5699,0.02 -5832,0.04 -5969,0.03 -6108,0.04 -6251,0.04 -6397,0.02 -6547,0.02 -6700,0.04 -6856,0.03 -7017,0.03 -7181,0.04 -7348,0.04 -7520,0.02 -7696,0.02 -7876,0.02 -8060,0.02 -8248,0.02 -8441,0.02 -8638,0.02 -8840,0.03 -9047,0.02 -9258,0.02 -9475,0.02 -9696,0.03 -9923,0.02 -10155,0.01 -10392,0.03 -10635,0.03 -10884,0.02 -11138,0.01 -11398,0.02 -11665,0.03 -11937,0.01 -12216,0.02 -12502,0.04 -12794,0.02 -13093,0.02 -13399,0.02 -13712,0.01 -14033,0.02 -14361,0.02 -14696,0.01 -15040,0.02 -15391,0.01 -15751,0.00 -16119,0.00 -16496,0.01 -16882,0.02 -17276,0.02 -17680,0.01 -18093,0.02 -18516,0.01 -18949,0.02 -19392,0.00 -19845,0.01 -20309,0.01 -20783,0.01 -21269,0.01 -21766,0.02 -22275,0.01 -22796,0.01 -23328,0.01 -23874,0.01 -24432,0.01 -25003,0.00 -25587,0.01 -26185,0.01 -26797,0.00 -27423,0.01 -28064,0.01 -28720,0.01 -29391,0.01 -30078,0.00 -30781,0.01 -31501,0.01 -32237,0.01 -32990,0.01 -33761,0.01 -34551,0.01 -35358,0.01 -36184,0.02 -37030,0.02 -37896,0.02 -38781,0.01 -39688,0.02 -40615,0.01 -41565,0.01 -42536,0.02 -43530,0.01 -44548,0.02 -45589,0.01 -46654,0.00 -47745,0.01 -48861,0.01 -50003,0.01 -51171,0.02 -52367,0.01 -53591,0.01 -54844,0.00 -56125,0.02 -57437,0.02 -58780,0.02 -60153,0.01 -61559,0.01 -62998,0.00 -64471,0.02 -65977,0.01 -67519,0.02 -69097,0.02 -70712,0.01 -72365,0.01 -74056,0.01 -75787,0.03 -77558,0.01 -79371,0.02 -81226,0.02 -83125,0.01 -85067,0.01 -87056,0.01 -89090,0.02 -91172,0.02 -93303,0.01 -95484,0.01 -97716,0.01 -100000,0.01 diff --git a/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_600_pts.csv b/tp/scripts/owon_hds25s_bode/csv/bode_rc_lowpass_600_pts.csv @@ -1,607 +0,0 @@ -Frequency,Amplitude -1,1.00 -5,1.01 -10,1.02 -20,1.03 -40,1.02 -80,1.01 -100,1.01 -101,1.00 -102,1.00 -103,1.01 -104,1.00 -105,1.00 -107,1.00 -108,1.00 -109,1.00 -110,1.00 -112,1.00 -113,1.00 -114,1.00 -116,1.00 -117,1.00 -118,1.00 -120,1.00 -121,1.00 -123,1.00 -124,1.00 -125,1.00 -127,1.00 -128,1.00 -130,1.00 -131,1.00 -133,1.00 -134,1.00 -136,0.99 -138,0.99 -139,0.99 -141,0.99 -142,0.99 -144,0.99 -146,0.99 -148,0.99 -149,0.99 -151,0.99 -153,0.99 -154,0.99 -156,0.99 -158,0.99 -160,0.99 -162,0.99 -164,0.99 -166,0.99 -168,0.99 -169,0.99 -171,0.99 -173,0.99 -175,0.99 -177,0.99 -180,0.99 -182,0.99 -184,0.99 -186,0.99 -188,0.99 -190,0.99 -192,0.99 -195,0.99 -197,0.99 -199,0.99 -202,0.99 -204,0.99 -206,0.99 -209,0.98 -211,0.97 -214,0.98 -216,0.97 -219,0.97 -221,0.97 -224,0.97 -226,0.97 -229,0.97 -232,0.97 -234,0.96 -237,0.96 -240,0.96 -243,0.96 -245,0.96 -248,0.96 -251,0.95 -254,0.95 -257,0.95 -260,0.95 -263,0.95 -266,0.95 -269,0.95 -272,0.95 -275,0.95 -279,0.95 -282,0.95 -285,0.95 -288,0.94 -292,0.93 -295,0.93 -299,0.93 -302,0.92 -306,0.92 -309,0.92 -313,0.92 -316,0.92 -320,0.92 -324,0.92 -327,0.91 -331,0.91 -335,0.91 -339,0.91 -343,0.89 -347,0.89 -351,0.89 -355,0.89 -359,0.89 -363,0.89 -368,0.89 -372,0.89 -376,0.88 -381,0.88 -385,0.88 -389,0.88 -394,0.88 -399,0.88 -403,0.88 -408,0.88 -413,0.87 -417,0.88 -422,0.87 -427,0.87 -432,0.85 -437,0.85 -442,0.85 -447,0.85 -452,0.85 -458,0.85 -463,0.84 -468,0.84 -474,0.84 -479,0.84 -485,0.83 -491,0.83 -496,0.82 -502,0.82 -508,0.81 -514,0.80 -520,0.80 -526,0.80 -532,0.80 -538,0.80 -544,0.80 -551,0.79 -557,0.79 -563,0.79 -570,0.78 -577,0.77 -583,0.77 -590,0.77 -597,0.77 -604,0.76 -611,0.76 -618,0.76 -625,0.76 -632,0.76 -640,0.75 -647,0.75 -655,0.75 -662,0.73 -670,0.73 -678,0.73 -686,0.72 -694,0.72 -702,0.71 -710,0.71 -718,0.71 -726,0.70 -735,0.70 -743,0.69 -752,0.68 -761,0.68 -769,0.68 -778,0.68 -787,0.67 -797,0.66 -806,0.66 -815,0.65 -825,0.65 -834,0.65 -844,0.65 -854,0.65 -864,0.64 -874,0.64 -884,0.64 -894,0.63 -904,0.63 -915,0.62 -926,0.61 -936,0.61 -947,0.61 -958,0.60 -969,0.60 -980,0.60 -992,0.59 -1003,0.59 -1015,0.58 -1027,0.57 -1039,0.56 -1051,0.56 -1063,0.56 -1075,0.56 -1088,0.55 -1100,0.55 -1113,0.55 -1126,0.55 -1139,0.55 -1152,0.54 -1166,0.52 -1179,0.52 -1193,0.52 -1207,0.52 -1221,0.51 -1235,0.51 -1249,0.51 -1264,0.49 -1278,0.49 -1293,0.49 -1308,0.48 -1323,0.48 -1339,0.47 -1354,0.47 -1370,0.47 -1386,0.47 -1402,0.47 -1418,0.46 -1435,0.45 -1451,0.44 -1468,0.44 -1485,0.44 -1503,0.44 -1520,0.44 -1538,0.44 -1555,0.43 -1573,0.43 -1592,0.43 -1610,0.43 -1629,0.42 -1648,0.41 -1667,0.41 -1686,0.41 -1706,0.40 -1726,0.31 -1746,0.39 -1766,0.38 -1786,0.38 -1807,0.37 -1828,0.37 -1849,0.36 -1871,0.36 -1892,0.36 -1914,0.35 -1937,0.35 -1959,0.35 -1982,0.35 -2005,0.34 -2028,0.34 -2052,0.34 -2075,0.33 -2099,0.33 -2124,0.32 -2148,0.32 -2173,0.32 -2199,0.32 -2224,0.31 -2250,0.31 -2276,0.31 -2302,0.31 -2329,0.30 -2356,0.30 -2383,0.30 -2411,0.30 -2439,0.29 -2467,0.29 -2496,0.28 -2525,0.28 -2554,0.28 -2584,0.28 -2614,0.27 -2644,0.27 -2675,0.27 -2706,0.26 -2737,0.26 -2769,0.26 -2801,0.26 -2834,0.26 -2867,0.25 -2900,0.25 -2933,0.25 -2967,0.25 -3002,0.25 -3037,0.24 -3072,0.24 -3108,0.24 -3144,0.23 -3180,0.23 -3217,0.23 -3254,0.22 -3292,0.22 -3330,0.22 -3369,0.22 -3408,0.22 -3447,0.22 -3487,0.22 -3528,0.21 -3569,0.21 -3610,0.21 -3652,0.20 -3694,0.20 -3737,0.20 -3781,0.16 -3825,0.19 -3869,0.19 -3914,0.19 -3959,0.19 -4005,0.19 -4052,0.18 -4099,0.18 -4146,0.18 -4194,0.18 -4243,0.18 -4292,0.17 -4342,0.17 -4392,0.17 -4443,0.17 -4495,0.17 -4547,0.17 -4600,0.16 -4653,0.16 -4707,0.16 -4762,0.16 -4817,0.16 -4873,0.16 -4929,0.15 -4986,0.15 -5044,0.15 -5103,0.15 -5162,0.15 -5222,0.15 -5282,0.15 -5344,0.14 -5406,0.14 -5468,0.14 -5532,0.14 -5596,0.14 -5661,0.14 -5727,0.14 -5793,0.13 -5860,0.13 -5928,0.13 -5997,0.13 -6066,0.13 -6137,0.13 -6208,0.13 -6280,0.13 -6353,0.12 -6427,0.12 -6501,0.12 -6577,0.12 -6653,0.12 -6730,0.12 -6808,0.12 -6887,0.12 -6967,0.11 -7048,0.11 -7129,0.11 -7212,0.11 -7296,0.11 -7380,0.11 -7466,0.11 -7553,0.10 -7640,0.10 -7729,0.10 -7819,0.10 -7909,0.10 -8001,0.10 -8094,0.10 -8188,0.10 -8283,0.10 -8379,0.10 -8476,0.10 -8574,0.10 -8674,0.09 -8774,0.09 -8876,0.09 -8979,0.09 -9083,0.09 -9189,0.09 -9295,0.09 -9403,0.09 -9512,0.09 -9622,0.09 -9734,0.09 -9847,0.08 -9961,0.08 -10077,0.08 -10194,0.08 -10312,0.08 -10431,0.08 -10552,0.08 -10675,0.08 -10799,0.08 -10924,0.08 -11051,0.08 -11179,0.08 -11308,0.08 -11440,0.07 -11572,0.07 -11707,0.07 -11842,0.07 -11980,0.07 -12119,0.07 -12259,0.07 -12401,0.07 -12545,0.07 -12691,0.07 -12838,0.07 -12987,0.07 -13138,0.07 -13290,0.07 -13444,0.07 -13600,0.07 -13758,0.05 -13917,0.06 -14079,0.06 -14242,0.06 -14407,0.06 -14574,0.06 -14743,0.06 -14914,0.06 -15087,0.06 -15262,0.06 -15440,0.06 -15619,0.06 -15800,0.06 -15983,0.05 -16168,0.06 -16356,0.06 -16546,0.05 -16738,0.05 -16932,0.05 -17128,0.04 -17327,0.05 -17528,0.05 -17731,0.05 -17937,0.05 -18145,0.05 -18355,0.05 -18568,0.05 -18784,0.05 -19001,0.05 -19222,0.05 -19445,0.05 -19670,0.05 -19899,0.05 -20129,0.04 -20363,0.04 -20599,0.05 -20838,0.04 -21080,0.05 -21324,0.05 -21571,0.05 -21822,0.05 -22075,0.05 -22331,0.04 -22590,0.04 -22852,0.04 -23117,0.04 -23385,0.04 -23656,0.04 -23931,0.04 -24208,0.04 -24489,0.04 -24773,0.04 -25060,0.04 -25351,0.04 -25645,0.04 -25943,0.04 -26244,0.04 -26548,0.04 -26856,0.04 -27167,0.04 -27483,0.04 -27801,0.04 -28124,0.04 -28450,0.04 -28780,0.04 -29114,0.03 -29452,0.03 -29793,0.04 -30139,0.04 -30488,0.04 -30842,0.03 -31200,0.04 -31562,0.03 -31928,0.04 -32298,0.04 -32673,0.03 -33052,0.04 -33435,0.04 -33823,0.04 -34215,0.04 -34612,0.03 -35013,0.03 -35420,0.03 -35830,0.03 -36246,0.03 -36666,0.03 -37092,0.03 -37522,0.03 -37957,0.03 -38397,0.03 -38843,0.03 -39293,0.03 -39749,0.03 -40210,0.03 -40676,0.03 -41148,0.03 -41626,0.03 -42108,0.03 -42597,0.03 -43091,0.03 -43591,0.03 -44096,0.03 -44608,0.03 -45125,0.03 -45649,0.03 -46178,0.03 -46714,0.03 -47256,0.03 -47804,0.03 -48358,0.03 -48919,0.03 -49486,0.03 -50060,0.03 -50641,0.03 -51228,0.03 -51823,0.03 -52424,0.03 -53032,0.03 -53647,0.03 -54269,0.03 -54899,0.03 -55535,0.03 -56180,0.03 -56831,0.03 -57490,0.03 -58157,0.03 -58832,0.03 -59514,0.03 -60205,0.03 -60903,0.03 -61609,0.03 -62324,0.03 -63047,0.03 -63778,0.03 -64518,0.03 -65266,0.03 -66023,0.03 -66789,0.03 -67564,0.03 -68347,0.03 -69140,0.03 -69942,0.03 -70753,0.03 -71574,0.03 -72404,0.03 -73244,0.03 -74093,0.03 -74953,0.03 -75822,0.03 -76702,0.03 -77591,0.03 -78491,0.03 -79402,0.03 -80323,0.03 -81254,0.03 -82197,0.03 -83150,0.03 -84115,0.03 -85090,0.03 -86077,0.03 -87076,0.03 -88086,0.02 -89107,0.02 -90141,0.02 -91187,0.03 -92244,0.03 -93314,0.02 -94397,0.03 -95491,0.03 -96599,0.03 -97719,0.02 -98853,0.02 -100000,0.02 diff --git a/tp/scripts/owon_hds25s_bode/main.py b/tp/scripts/owon_hds25s_bode/main.py @@ -1,110 +0,0 @@ -import pyvisa -import time -import numpy as np - -PROBE = "1X" - -# List of all valid timebases supported by OWON HDS2* series -TIMEBASES = [ - (2e-9, "2.0ns"), (5e-9, "5.0ns"), (10e-9, "10.0ns"), (20e-9, "20.0ns"), - (50e-9, "50.0ns"), (100e-9, "100ns"), (200e-9, "200ns"), (500e-9, "500ns"), - (1e-6, "1.0us"), (2e-6, "2.0us"), (5e-6, "5.0us"), (10e-6, "10us"), - (20e-6, "20us"), (50e-6, "50us"), (100e-6, "100us"), (200e-6, "200us"), - (500e-6, "500us"), (1e-3, "1.0ms"), (2e-3, "2.0ms"), (5e-3, "5.0ms"), - (10e-3, "10ms"), (20e-3, "20ms"), (50e-3, "50ms"), (100e-3, "100ms"), - (200e-3, "200ms"), (500e-3, "500ms"), (1.0, "1.0s"), (2.0, "2.0s"), - (5.0, "5.0s"), (10.0, "10s"), (20.0, "20s"), (50.0, "50s"), - (100.0, "100s"), (200.0, "200s"), (500.0, "500s"), (1000.0, "1000s") -] - -# Supported scale tables according to probe attenuation -VOLT_SCALES = { - "1X": [ - (0.010, "10.0mV"), (0.020, "20.0mV"), (0.050, "50.0mV"), - (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), (10.00, "10.0V") - ], - "10X": [ - (0.100, "100mV"), (0.200, "200mV"), (0.500, "500mV"), - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), (100.0, "100V") - ], - "100X": [ - (1.000, "1.00V"), (2.000, "2.00V"), (5.000, "5.00V"), - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), (1000.0, "1.00kV") - ], - "1000X": [ - (10.00, "10.0V"), (20.00, "20.0V"), (50.00, "50.0V"), - (100.0, "100V"), (200.0, "200V"), (500.0, "500V"), - (1000.0, "1.00kV"),(2000.0, "2.00kV"),(5000.0, "5.00kV"),(10000.0, "10.0kV") - ] -} - -def get_best_timebase(frequency): - period = 1.0 / frequency - target_scale = period / 2.0 # Display width is roughly 10 divisions - - # Pick the closest supported value in the list - best_match = min(TIMEBASES, key=lambda x: abs(x[0] - target_scale)) - return best_match[1] - -rm = pyvisa.ResourceManager('@py') - -scope = rm.open_resource("ASRL/dev/ttyUSB0::INSTR") -print("Identification: ", scope.query("*IDN?")) - -# Configure scope -scope.write(":CH1:COUPling AC") -scope.write(":CH1:SCALe 500mV") - -scales = VOLT_SCALES.get(PROBE) -curr_scale_idx = next(i for i, (val, label) in enumerate(scales) if label == "500mV") - -scope.write(":HORizontal:SCALe 50ms") -scope.write(f":CH1:PROBE {PROBE}") -scope.write(f":FUNCtion:AMPLitude 2") - -scope.write(":FUNCtion SINE") -print("AG Func:", scope.query(":FUNCtion:FREQuency?"), end="") - -# freqs = [10, 100, 1000, 10000] - -# 5 decades (10^0 to 10^5) at 5 points/decade -> 5 * 5 + 1 = 26 points -freqs = np.concatenate((np.array([1, 5]), np.logspace(1, 5, num=50))) -freqs = [int(f) for f in freqs] -amps = [] - -for freq in freqs: - scope.write(f":FUNCtion:FREQuency {freq}") - tb_str = get_best_timebase(freq) - scope.write(f":HORizontal:SCALe {tb_str}") - - time.sleep(1.5) - - val = float(scope.query(":MEASurement:CH1:MAX?").strip()) - amps.append(val) - - # if val < scales[curr_scale_idx][0] and curr_scale_idx > 0: - # curr_scale_idx = (curr_scale_idx - 1) - # scope.write(f":CH1:SCALe {scales[curr_scale_idx][1]}") - -# print("AG Freq:", scope.query(":FUNCtion:FREQuency?"), end="") -# print("CH1 MAX:", scope.query(":MEASurement:CH1:MAX?"), end="") - -# print(f"[{' '.join(map(str, freqs))}]") -# print(f"[{' '.join(map(str, amps))}]") - -scope.write(":CH1:SCALe 500mV") -scope.write(":HORizontal:SCALe 500us") -scope.write(f":FUNCtion:FREQuency 1000") - -scope.close() - -data = np.column_stack((freqs, amps)) -np.savetxt("data.csv", - data, - delimiter=",", - header="Frequency,Amplitude", - comments="", - fmt=["%d", "%.2f"]) diff --git a/tp/scripts/owon_hds25s_bode/png/HDS2XX.png b/tp/scripts/owon_hds25s_bode/png/HDS2XX.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_plain.png b/tp/scripts/owon_hds25s_bode/png/bode_plain.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_rc_highpass.png b/tp/scripts/owon_hds25s_bode/png/bode_rc_highpass.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_1000_pts.png b/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_1000_pts.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_100_points.png b/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_100_points.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_200_pts.png b/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_200_pts.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_300_pts.png b/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_300_pts.png Binary files differ. diff --git a/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_600_pts.png b/tp/scripts/owon_hds25s_bode/png/bode_rc_lowpass_600_pts.png Binary files differ.
