I am using a USB DAQPad-6015 to acquire data from 8 analog channels and using an external clock (200Hz). I am also retrieving data from a library function node call which schedules a callback function to run at approximately 1000Hz. The function prototype accepts a pointer to an array, and the array contents are updated each time the callback function is run. Thus in labview I initialize an array and pass this as a parameter and am able to retrieve the data.
Using an event structure I am sampling the data from the library function node every time the DAQ takes a sample (so at 200Hz). I expect to see no repeated values from the dll data, but this isn't the case.
I am not sure why this happens. I thought possibly acquiring data from the analog channels takes priority over the scheduled callback function -- thus it might not be running at 1000Hz as I expect -- but I'm wondering if there could be any other explanation.
Any help would be much appreciated.
I've attached a simplified version of the VI and the output data.
The first thing I see in your code is some unnecessary frames of your sequence structure. Since your error wire is connected from each Call Library node, your VIs on this wire will be forced to execute in order of dataflow. Check out the document linked below for a brief introduction to this.
Dataflow Programming Basics in NI LabVIEW
Regarding duplicate data points, it does look like your EveryNSamples code is running however it doesn't look like it is getting updated data points from your dll. What do you see if you drop your scheduler rate to 200 Hz or somewhere between 200 Hz and 1000 Hz? Also we need to determine whether your dll is generating duplicate points or whether some aspect of your LabVIEW program is duplicating values.
If you set your scheduler to pull data from your dll at 1000hz and put this in a completely seperate VI and seperate loop, would you see 1000 new points every second?
Also, try benchmarking your two loops to see what kind of iteration time you are seeing.
Community: Benchmark Loop Iteration Time
Hi Chris, thank you for your reply and your suggestions.
When I lower the scheduler rate to 500 Hz, it does not seem to make much of a difference. When checking the number of repeated samples, both seem to have anywhere between 30 and 60 repeated values.
I also checked the scheduler performance on its own, by using a timed loop set to run at 1kHz. Although its software timed, I thought it would give a good estimate. Anyways, in the 1 second it ran, only 3 of the 1000 samples were repeated.
I tried benchmarking the two loops and found something interesting. In the loop which pulls data from the scheduler, the loop time is 0ms for around 60 consecutive iterations, and then jumps to around 300ms for one iteration, and then repeats. I am guessing this may be that the Tick Count isn't registering the time properly - and it makes sense that if each iteration is 5ms (200Hz) apart, this would give 300ms for 60 iterations. Since this number of iterations matches the number of repeated values somewhat, I think they are related. But I'm not sure what the source of the problem is.