06-28-2019 04:10 AM - edited 06-28-2019 04:12 AM
Hi,
I'm just trying to output a single sinwave (pulse) on AnalogOutput with nidaqmx in Python. For some reason, the pulse is always 1ms long, no matter how long the pulse is. Maybe I have an obvious error in reasoning. The code looks like to following:
import matplotlib.pyplot as plt
import numpy as np
import nidaqmx
import nidaqmx.system
system = nidaqmx.system.System.local()
system.driver_version
for device in system.devices:
print(device)
x = np.linspace(0, 2 * np.pi , num=100) #generate x values for sinwave
sinewave = np.sin(x)*10 #generate sinwave
plt.plot(x, sinewave) #plot sinewave
nidaqmx.constants.AcquisitionType.FINITE:10178 #set output to finite
with nidaqmx.Task() as task:
task.ao_channels.add_ao_voltage_chan('Dev2/ao0') #set device
task.timing.cfg_samp_clk_timing(1e6) #set rate
print('1 Channel N Samples Write: ') #print text
print(task.write(sinewave)) #print number of samples sent
task.start() #start task
task.wait_until_done(timeout=10.0) #wait till task is done
task.stop() #stop task
When I change the size of the sinewave, the final pulse will still be just 1ms.
x = np.linspace(0, 2 * np.pi , num=100) x = np.linspace(0, 4 * np.pi , num=100) x = np.linspace(0, 2 * np.pi , num=150)
All arrays x will lead to different looking pulses, but the pulses are all 1ms long. I bet it is sth. obvious I'm missing,... but I don't get it.
Thank you in advance for your help!
06-22-2020 05:21 AM
Hey,
it is probably to late for you, but in your code you have changed the freq of you sine.
The time of the signal is dependent on the number of points and the freq. of your device.
All the best
Ben