11-12-2012 04:00 PM
I'm just now getting into the testing phase of my program and when running a 30 cycle data measurement I'm only getting 364 data points. My time delay is 0.01s and I'm reading from a 1hz signal. From what I understand I should be getting around 3000 data points...can anyone look at my VI and give me some direction on how to fix this problem?
11-12-2012 04:05 PM - edited 11-12-2012 04:07 PM
You are creating your channels on every iteration of the while loop. That takes time. Plus over time that could eat up resources and potentially crash your PC.
The Create Channel VI's should be outside the While loop before it starts.
You should also use the close or destroy task functions after the while loop is over.
Don't forget to make the labels of your control and indicator terminals visible in the block diagram and give them meaningful labels so you know what each do.
11-12-2012 04:08 PM
ahh, makes sense about the channels...will this give me the 3000 data points that I need? I'm new to this so forgive me: "close or destroy task functions" - what exactly does this do?
11-12-2012 04:09 PM
Problems I see:
1.) You are initializing each channel during every loop iteration. The initialization should only happen once. Move it outside the loop.
2.) You are only reading one sample per loop iteration, so the sample rate is limited by the time delay in your loop. I suggest reading multiple samples per iteration.
11-12-2012 04:10 PM
how would I read mutiple samples per iteration?
11-12-2012 04:12 PM
It closes out the resources you opened when you created the task. I'm pretty usre the ULx library has it as it was modeled after DAQmx. I just don't have tha library installed on this PC.
For multiple samples, click on the polymorphic selector below those VI's and you should see an option for N samples or multiple samples.
11-12-2012 04:13 PM - edited 11-12-2012 04:16 PM
Initialize the tasks before the loop, then clear the tasks after the loop is complete. Could you bundle all of your signals into one task? That would make your code a lot cleaner.
11-12-2012 04:14 PM
I'm not sure how to do the singals all in one task. I'm using a MCC usb daq...
11-12-2012 04:19 PM
Ravensfan, does the polymorphic selector VI go inside my while loop? I get creating the channels everytime is dumb and that I need to do it outside the while loop, but which VI do I put outside the while loop? There's 2 VIs...
11-12-2012 04:24 PM - edited 11-12-2012 04:24 PM
Here is a starting point. This is not a complete solution, but should give you an idea.
Choose all of the AI channels you want to aquire with the "physical channels" control.