07-24-2019 02:44 PM
Hello,
I am attempting to program a myDAQ device to generate continuous sign waves of various cycles using the nidaqmx library in Python.
I used below code for generation.
but when I execute code, it is worked just one time.
how can I modify this code to execute in specific time or controlled time?
amp = 4 # 1V (Amplitude)
f = 40000 # 40kHz (Frequency)
fs = 2000000 # 200kHz (Sample Rate)
T = 1/f
Ts = 1/fs
x = np.arange(fs)
y = [ amp*np.sin(2*np.pi*f * (i/fs)) for i in x]
y_new = np.tile(y,1)
x1 = x[:100]/2000000
y1 = y[:100]
test_Task = nidaqmx.Task()
test_Task.ao_channels.add_ao_voltage_chan('Dev1/ao0')
test_Task.timing.cfg_samp_clk_timing(rate= 2000000, sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS)
test_Writer = nidaqmx.stream_writers.AnalogSingleChannelWriter(test_Task.out_stream, auto_start=True)
samples = y_new
test_Writer.write_many_sample(samples)
test_Task.wait_until_done()
test_Task.stop()
test_Task.close()
07-25-2019 06:43 AM
You are sending a CONTINUOUS signal.
Therfore you can not use:
test_Task.wait_until_done()
import time and try replacing it with:
time.sleep(5)
to get a 5s impulse.