06-07-2022 12:55 AM
I want to create the python software using NI-DAQmx,
I am using nidaqmx library, But i can't read the DAQ voltage data at Higer sample rate.
Using the same DAQ and Labview it can be read 5MHz.
what is the reson for that, please give me a hint.
It would be really helpful
06-07-2022 12:57 AM
what is the reson for that, please give me a hint.
Clearly, it is your python code which was not implemented properly for continuous capture. What have you tried so far? please share your python code.
I would suggest looking at the example test programs to see where you missed in your implementation.
06-07-2022 01:18 AM
import time,threading
import nidaqmx
import matplotlib.pyplot as plt
task = nidaqmx.Task()
task.ai_channels.add_ai_voltage_chan("Dev2/ai0")
task.start()
data = []
class TimerClass(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()
self.count = 0
def run(self):
while self.count<200 and not self.event.is_set():
r = task.read()
data.append(float(r))
self.count += 1
self.event.wait(0.0001)
def getCount(self):
self.gtcount = self.count
self.count = 0
return self.gtcount
def stop(self):
self.event.set()
tmr = TimerClass()
tmr.start()
time.sleep(1)
tmr.stop()
plt.plot(data)
print("Counter Read = ",tmr.getCount())
plt.show()
____________________________
Output>>>>
Counter Read = 100
____________________________
this is the simple code for read the higher sampling rate
but the thing is it can't reach the higher sampling rate.