I am having some problems getting my NI USB 6353 to behave, so I am hoping someone more competent than me can explain what I am doing wrong.
Here is the situation: I want to start sampling one AI-channel during 1 ms after an external digital trigg signal goes high. I sample at a rate of 1MHz, and I take 1k samples.
You can see my little test-vi below. I check the time elapsed between start and stop of AI-read.
The external trigger goes high every 10:th ms (f_trigg 100Hz). The AI-read time should theoretically be 1 ms, with plenty of time to wait for the next trigger, 9 ms later.
However, it seems impossible to get the AI-read time below 40 ms. Clearly something is wrong in my code, but what?
I would be most grateful for any advice regarding this.
Solved! Go to Solution.
One tip is to use an explicit "DAQmx Start Task" before your loop. This moves the task state model to the "Running" state before your read. (By not having it, DAQmx Read will implicitly move it to Running, but now you're also timing the transitions through the Reserved and Committed states.)
Your use model (sample for a period of time after receiving a periodic external trigger signal) also sounds like it could be a good fit for a retriggerable task.
Adding to bstreiff's answer that I kudo'ed.
1. I agree with his advice to configure to be hardware-retriggerable, then start the task before the loop. This assumes you want to capture 1 msec of data for each trigger that repeats every 10 msec.
2. Another use of the task state model he linked is to "commit" the task before the loop, then you can start and stop the task inside the loop with very minimal overhead. Likely well below 10 msec.
I don't think it's the best option for your particular app here -- when available, hardware-triggering will be better. It's just something to keep in mind for future tasks where you have no hardware trigger but want low overhead for stops and restarts.
Thank you Brandon.
I had tried start-stop outside my loop previously, but failed. This produced a DAQ-error, but with the use of the Retriggerable property node when configuring my task, the AI-read now takes 6 ms. This gives me enough time to be ready for the next trigger puls.