Multifunction DAQ

取消
显示结果 
搜索替代 
您的意思是: 

Python reading Input task from simulated device not working

Hi! I have been trying the python library that allows to use NI hardware and work in a similar way blocks on labview do.

 

The thing is i want to read a certain task input (configured from a virtual device on NI MAX). This, of course, works perfectly on Labview, but when trying to get it done on python, it feels like python is not getting my task config from NI, at all. It has not a constant freq, even though i get a sine, it is not always the same, and python does not notice my max and min range from NI MAX. No matter what ranges i pick on NI MAX, i always get a 10V amplitude sine on python.

 

Some help would be very welcome! 

 

Thanks in advance.

 

import time
import matplotlib.pyplot as plt
import nidaqmx
import nidaqmx.system
data = nidaqmx.system.system.System.local()
taskss=data.tasks.task_names
task= nidaqmx.system.storage.persisted_task.PersistedTask('MyVoltageTask22')
task1= nidaqmx.system.storage.persisted_task.PersistedTask(data.tasks.task_names[0])
tasks=task.load()

t = []
tiempos = []

tasks.start()
lee=tasks.read(number_of_samples_per_channel=100)
tiempo=time.perf_counter()
t.append(lee)
tiempos.append(tiempo)


tasks.close()
print(t)
x = [k for k in range(0,100)]
plt.figure(3)
plt.plot(x,lee)

tasks.close()

0 项奖励
1 条消息(共 3 条)
1,446 次查看

I tried your code and I am able to get the simulated sine wave with the configured min and max range. 

What hardware are you simulating? Your simulated device might only have one input range of +/- 10 V. 

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
2 条消息(共 3 条)
1,428 次查看

Thanks for your answer!

 

One virtual device, I don't really remember which one - i will check it - but that shouldn't be the problem since I get the ranges right on LabVIEW, using that same device, even same task.

 

But which one are you using? You get the ranges set on NI MAX on your Python plot, right? It might be worth checking cause I don't know what else could be the reason for that problem. 

 

 

 

Thanks again!

0 项奖励
3 条消息(共 3 条)
1,416 次查看