improve script for demo

master
Ondřej Hruška 7 years ago
parent fb7da03429
commit d7c43310a3
  1. 24
      main.py

@ -7,6 +7,12 @@ from matplotlib import pyplot as plt
import gex import gex
import time import time
# Two presets defined for demoing the plotter with a high-pass and low-pass RC filter
# made of 1 kOhm and 100 nF
#demo = 'HP'
demo = 'LP'
class ADG: class ADG:
def __init__(self, client:gex.Client): def __init__(self, client:gex.Client):
self.client = client self.client = client
@ -54,17 +60,16 @@ with gex.Client(gex.TrxSerialThread('/dev/ttyACM0')) as client:
allowed_shift_compensation = -4.5 allowed_shift_compensation = -4.5
if False: if demo == 'HP':
# highpass filter example (corner 340 Hz) # highpass filter example (corner 340 Hz)
settling_time_s = (4700*100e-9)*10 settling_time_s = (4700*100e-9)*10
max_allowed_shift_db = 5 max_allowed_shift_db = 5.6
allowed_shift_compensation = -4.5 allowed_shift_compensation = -5
if demo == 'LP':
if True:
# lowpass filter example (corner 340 Hz) # lowpass filter example (corner 340 Hz)
settling_time_s = (4700*100e-9)*10 settling_time_s = (4700*100e-9)*10
max_allowed_shift_db = 1 max_allowed_shift_db = .5
allowed_shift_compensation = 2 allowed_shift_compensation = 2
@ -90,7 +95,7 @@ with gex.Client(gex.TrxSerialThread('/dev/ttyACM0')) as client:
# =============================================== # ===============================================
allowed_shift_compensation /= (f_1 - f_0) / f_step #allowed_shift_compensation /= (f_1 - f_0) / f_step
adc = gex.ADC(client, 'adc') adc = gex.ADC(client, 'adc')
@ -103,6 +108,7 @@ with gex.Client(gex.TrxSerialThread('/dev/ttyACM0')) as client:
last_db = None last_db = None
f = f_0 f = f_0
first = True first = True
begin_allowedshift = max_allowed_shift_db
while f <= f_1: while f <= f_1:
if not first: if not first:
f_step = round(f_step_begin + ((f - f_0) / (f_1 - f_0)) * (f_step_end - f_step_begin)) f_step = round(f_step_begin + ((f - f_0) / (f_1 - f_0)) * (f_step_end - f_step_begin))
@ -112,7 +118,7 @@ with gex.Client(gex.TrxSerialThread('/dev/ttyACM0')) as client:
#dac.set_frequency(1, f) #dac.set_frequency(1, f)
gen.set_frequency(f) gen.set_frequency(f)
max_allowed_shift_db += allowed_shift_compensation max_allowed_shift_db = begin_allowedshift + allowed_shift_compensation * ((f - f_0) / (f_1 - f_0))
# Adjust measurement parameters # Adjust measurement parameters
while True: while True:

Loading…
Cancel
Save