Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

python nidaqmx continous sampling rate

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

0 Kudos
Message 1 of 3
(863 Views)

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.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 3
(862 Views)

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.

 

 

 

0 Kudos
Message 3 of 3
(854 Views)