From a9be09dc0685f8bee776111a24274ae159d41074 Mon Sep 17 00:00:00 2001 From: wendtalexander Date: Wed, 25 Sep 2024 17:04:53 +0200 Subject: [PATCH] checking if amplitude is the same form input to output --- pyrelacs/repros/calbi.py | 57 +++++++++------------------------------- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/pyrelacs/repros/calbi.py b/pyrelacs/repros/calbi.py index ef7af46..937eea1 100644 --- a/pyrelacs/repros/calbi.py +++ b/pyrelacs/repros/calbi.py @@ -19,60 +19,29 @@ class Calibration(MccDac): def __init__(self) -> None: super().__init__() - def run_calibration(self): - # Stimulus - t = np.arange(0, DURATION, 1 / SAMPLERATE) - data = AMPLITUDE * np.sin(2 * np.pi * SINFREQ * t) - # sending stimulus - - self.write_analog( - data, [0, 0], SAMPLERATE, ScanOption=uldaq.ScanOption.EXTTRIGGER - ) - - # read_data = self.read_analog_daq( - # [0, 1], DURATION, SAMPLERATE, ScanOption=uldaq.ScanOption.EXTTRIGGER - # ) - - self.diggital_trigger() - try: - self.ao_device.scan_wait(uldaq.WaitType.WAIT_UNTIL_DONE, 15) - except uldaq.ul_exception.ULException: - log.debug("Operation timed out") - # reset the diggital trigger - self.write_bit(channel=0, bit=0) - time.sleep(1) - self.set_analog_to_zero() - def check_amplitude(self): + self.set_attenuation_level(db_channel1=0.0, db_channel2=0.0) # write to ananlog 1 t = np.arange(0, DURATION, 1 / SAMPLERATE) data = AMPLITUDE * np.sin(2 * np.pi * SINFREQ * t) + data_channels = np.zeros(2 * len(data)) + # c = [(i,for i,j in zip(data, data)] - # sending stimulus - log.debug(f"{data}, {data.shape}") - # self.set_attenuation_level(db_channel1=0.0, db_channel2=0.0) - # self.set_analog_to_zero() - # time.sleep(1) - log.debug(self.ao_device) - embed() - exit() - - self.write_analog( + stim = self.write_analog( data, - [1, 1], + [0, 0], SAMPLERATE, ScanOption=uldaq.ScanOption.EXTTRIGGER, ) - # data_channel_one = self.read_analog( - # [0, 0], DURATION, SAMPLERATE, ScanOption=uldaq.ScanOption.EXTTRIGGER - # ) - log.debug(self.ao_device) + data_channel_one = self.read_analog( + [0, 0], DURATION, SAMPLERATE, ScanOption=uldaq.ScanOption.EXTTRIGGER + ) time.sleep(1) self.diggital_trigger() try: - self.ao_device.scan_wait(uldaq.WaitType.WAIT_UNTIL_DONE, 15) + self.ai_device.scan_wait(uldaq.WaitType.WAIT_UNTIL_DONE, 15) self.write_bit(channel=0, bit=0) time.sleep(1) self.set_analog_to_zero() @@ -90,9 +59,9 @@ class Calibration(MccDac): if __name__ == "__main__": SAMPLERATE = 40_000.0 DURATION = 5 - AMPLITUDE = 1 + AMPLITUDE = 0.5 SINFREQ = 10 - daq_input = Calibration() - # daq_input.run_calibration() - daq_input.check_attenuator() + cal = Calibration() + # cal.ccheck_attenuator() + cal.check_amplitude()