checking if amplitude is the same form input to output
This commit is contained in:
parent
06f5a6ae46
commit
a9be09dc06
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user