Feature: Added Documentation in
This commit is contained in:
@@ -4,8 +4,7 @@ import argparse
|
||||
import fn_gen.errors as fg_err
|
||||
from common import close_output, get_preamplified
|
||||
from fn_gen import DG2052
|
||||
from fn_gen.enums import SweepSignalType, SweepSpacing, SweepTriggerSource
|
||||
|
||||
from fn_gen.enums import SweepSignalType, SweepSpacing
|
||||
|
||||
def sweep_over_signal(
|
||||
signal: str,
|
||||
@@ -22,49 +21,30 @@ def sweep_over_signal(
|
||||
v_min = get_preamplified(13.0, v_min)
|
||||
v_max = get_preamplified(13.0, v_max)
|
||||
channel = 2
|
||||
signal_type = SweepSignalType.SINE
|
||||
match signal:
|
||||
case "sine":
|
||||
signal_type = SweepSignalType.SINE
|
||||
case "square":
|
||||
signal_type = SweepSignalType.SQUARE
|
||||
case "ramp":
|
||||
signal_type = SweepSignalType.RAMP
|
||||
spacing_type = SweepSpacing.LOG
|
||||
match spacing:
|
||||
case "lin":
|
||||
spacing_type = SweepSpacing.LIN
|
||||
case "log":
|
||||
spacing_type = SweepSpacing.LOG
|
||||
try:
|
||||
print(fg.whoami())
|
||||
print(f"\nOutput{channel} Impedance: {fg.get_output_impedance(channel)} Ohm")
|
||||
print(f"Output{channel} Load: {fg.get_output_load(channel)} Ohm")
|
||||
print(f"Output{channel} Voltage Limits: {fg.get_output_volt_limits(channel)} V")
|
||||
fg.set_sweep(
|
||||
channel,
|
||||
amp=(v_max + v_min)/2,
|
||||
offset=0,
|
||||
phase=phase,
|
||||
signal_type=signal_type,
|
||||
freq_start=freq_start,
|
||||
freq_stop=freq_stop,
|
||||
spacing=spacing_type,
|
||||
trigger_source=SweepTriggerSource.MANUAL,
|
||||
time=duration,
|
||||
)
|
||||
print(
|
||||
f"Output{channel}: {fg.get_output_signal(channel)} | {fg.get_output_state(channel)}"
|
||||
)
|
||||
fg.set_output(channel, True)
|
||||
time.sleep(delay)
|
||||
fg.trigger_sweep(channel)
|
||||
t0 = time.time()
|
||||
t1 = time.time()
|
||||
while (t1 - t0) < duration:
|
||||
print(f"Current Frequency: {fg.get_output_signal(channel)}")
|
||||
t1 = time.time()
|
||||
print(f"Output{channel} State: {fg.get_output_state(channel)}")
|
||||
curr_freq = freq_start
|
||||
df = 1
|
||||
dt = 0.001
|
||||
match signal:
|
||||
case "sine":
|
||||
fg.set_sine_wave(channel, curr_freq, v_min)
|
||||
case "square":
|
||||
fg.set_square_wave(channel, curr_freq, v_min)
|
||||
case "ramp":
|
||||
fg.set_ramp(channel, curr_freq, v_min)
|
||||
while curr_freq < freq_stop:
|
||||
match spacing:
|
||||
case "lin":
|
||||
curr_freq += df
|
||||
fg.set_frequency(channel, curr_freq)
|
||||
case "log":
|
||||
pass # TODO: setup log sweep
|
||||
time.sleep(dt)
|
||||
close_output(fg, channel)
|
||||
except fg_err.ValueOutOfBoundsError as err:
|
||||
print(err)
|
||||
except fg_err.UndefinedValueError as err:
|
||||
|
||||
Reference in New Issue
Block a user