Forum: PC-Programmierung Python LabView myDaq


von Cris (Gast)


Lesenswert?

Hallo Zusammen,

ich will die myDAQ Boxen von LabView mit Pyhton ansprechen. Jedoch 
erreiche ich nicht die maximale Samplerate von 200kS/s sondern nur 3kS/s 
mit diesem Code:
1
import nidaqmx
2
import time
3
4
def TicTocGenerator():
5
    # Generator that returns time differences
6
    ti = 0           # initial time
7
    tf = time.time() # final time
8
    while True:
9
        ti = tf
10
        tf = time.time()
11
        yield tf-ti # returns the time difference
12
13
TicToc = TicTocGenerator() # create an instance of the TicTocGen generator
14
15
# This will be the main function through which we define both tic() and toc()
16
def toc(tempBool=True):
17
    # Prints the time difference yielded by generator instance TicToc
18
    tempTimeInterval = next(TicToc)
19
    if tempBool:
20
        print( "Elapsed time: %f seconds.\n" %tempTimeInterval )
21
22
def tic():
23
    # Records a time in TicToc, marks the beginning of a time interval
24
    toc(False)
25
26
27
task = nidaqmx.Task()
28
task.ai_channels.add_ai_voltage_chan("myDaq1/ai0")
29
task.start()
30
31
samples = 100
32
tic()
33
34
for i in range(10):
35
    y = task.read(number_of_samples_per_channel=samples)
36
37
toc()
38
task.stop()

Die NI-DAQmx Python Documentation sagt, es gibt mehrere Möglichkeiten:

- nidaqmx.task.channel
- nidaqmx.task.in_stream
- nidaqmx.stream_readers
- ...

Hat das schon jemand gemacht und weis wie es besser geht? In der Doku 
steht nur, dass ich die number_of_samples_per_channel ändern kann, aber 
nicht die SampleRate. Oder ich sehe es einfach nicht.

Wie auch immer, ich freue mich über jeden Tipp.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.