04-02-2011 08:59 AM
Hi all,
I'm writing a state machine which include 3 cases, used to send digital data out in each case.
Case 01 is default and it sends data out without needing a trigger signal, then move to case 2.
Case 02:
- If trigger happens within 50 ms, send case 02's data out and move to case 3
- If trigger does not happens within 50 ms, not send case 02's data, just move back to case 01.
50 ms seconds is counted from the beginning of case 01, but case 01 needs about 100 ms to complete (I used Tick count to count this value, please comment if this calculation is correct). The samples rate is 30 kHz, there are only 8 samples, so the time is just 8/30k = 267 us, I don't understand why it needs 100 ms to complete!!).
My question are:
1. Is there any way to reduce the execution time of an iteration?
2. How can we abort all commands in an iteration to move to next iteration.
Please have a look at the attached VI.
I'm using NI DAQ USB 6363, Labview 2010, Core 2 DUO CPU, T7300 @ 2GHz, 1G RAM.
Thanks
diem
04-04-2011 12:39 PM
Diem,
You should take your DAQmx Create Channel, DAQmx Timing, and DAQmx Clear Task vi's outside of your loop. You only need to configure your task once, and the reason your loop is taking so long to execute is because you are clearing your task and reconfiguring it each iteration. What do you mean by "abort" your loop. Case structures, such as you are using, would be a way do to this. You could use a boolean as an input to a case structure, and only execute a certain chunk of code if that boolean is true.
Jon S
04-04-2011 11:39 PM
Thanks Jon,
I think I can handle the case structure problem, but when taking DAQmx Create Channel, DAQmx Timing, and DAQmx Clear Task vi's outside of the loop, I've got problem with overflow of the on-board memory (Error 200621). I can't reduce the data rate or increase the number of samples as they are required by the application.
Do you have any suggestions?
Cheers,
04-05-2011 05:25 PM - edited 04-05-2011 05:26 PM
Have you tried lowering the sample rate to see if you can get rid of the error? Also, I think that your start tast vi should come before your wriet. It seems the archictecture of your program should be fine other than that.
Jon S
04-05-2011 07:01 PM
Yes, Jon, I even made it down to 100 Hz, the overflow uasually happened at loop number 3. I don't understand how people can send out data packets of about 1000 bits at rate of several hundred kHz continueously?
04-06-2011 06:05 PM
Diem,
You need to change your samples per channel to 64. I was wrong about the start task, it's fine where you had it. The problem is that you are actually getting an underflow error. The buffer is waiting 1024 samples, and the most it ever receives is 64. Let me know if this works!
Jon S
04-06-2011 06:54 PM
Thanks Jon,
Yes, it was underflow, it still happens with even 10 samples. However, my goal is to send out 1024 samples at rate 30,000 Hz for each case.
04-07-2011 05:54 PM
So even when you reduce the Sample Clock Samples per Channel to 64, you are still getting the underflow error? That isn't expected. Have you tried making a vi that just writes the data at 30kHz? You can eliminate the case structure and just execute the digital write and see how long it takes this to run. I'll try and see if I can recreate the error on my end too.
Jon