02-01-2016 12:22 AM
Hello,
in this VI, I attempt to sample analog input at rate of 1khz, 1s worth of sample. This data array will be processed later. As I want to make sure the data array is really what I expected from the sampling, it was not !
The time taken to sample 1000 samples at 1khz was actually 1400 to 1410ms. What is wrong in my setup and how do I know when to trust the timed loop timing ?
I have also experimented with High throughput Addon, unfortunately it only allowed AI0 to be selected, I need 3 analog input like so, and for some reason, audio input jack wasn't in the selectable list.
Thank you!
Myrio 2015
02-02-2016 12:17 PM - edited 02-02-2016 12:31 PM
Hi zigbee1,
So, off the top of my head, I'm not used to seeing this particular setup for acquring AI voltages.
Have you considered using one of the DAQ examples in LabVIEW to acquire your data? (Help>>Find Examples>>Hardware Input and Output>>DAQmx>>Analog Input)
The way you're approaching the problem differs from best practices for using LabVIEW to acquire data. Giving one of those pre-built examples will make your applications easier for others to view.
Or is there a particular reason you are using this configuration? Also, what device are you using?
02-02-2016 02:45 PM
Hey RahRahMirez, I am using myRIO device, this device has a dozen of inputs and I can acquire 1 same at a time for any of those input. To acquire multiple samples, I have to switch the FPGA personality to High through put, as a result, it can then acquire N samples (instead of just 1), but unfortuately this "acquire N samples" is only selectable with 1 input pin MXP pin AI0.
I think that myDaq supports "acquire N samples" for all inputs, but this not the case with myRIO.
02-03-2016 09:16 AM - edited 02-03-2016 09:19 AM
@RahRahMirez wrote:Hi zigbee1,
So, off the top of my head, I'm not used to seeing this particular setup for acquring AI voltages.
Have you considered using one of the DAQ examples in LabVIEW to acquire your data? (Help>>Find Examples>>Hardware Input and Output>>DAQmx>>Analog Input)
The way you're approaching the problem differs from best practices for using LabVIEW to acquire data. Giving one of those pre-built examples will make your applications easier for others to view.
Or is there a particular reason you are using this configuration? Also, what device are you using?
They are using a myRIO which is similar to a CompactRIO - the myRIO does not support DAQmx.
I suspect that your problem might lie in how you are benchmarking your code and the fact you are using Express VIs to read the data from the myRIO for the following reasons:
1) The timed loop may have some setup/initialisation before/after it completes.
2) The first call of the Analog input Express VI will download/run and open the reference to the FPGA on the myRIO and this will take some time to complete.
3) There may be something at play with the fact that you use build array - causing the myRIO to spend time allocating memory for the array as it gets larger.
So...what can you do about it?
- The nodes in the timed-loop can give you information about the actual period of the timed loop if you drag down the arrows (you can get current/previous iteration timing information) - if you take a look at those values, you'll probably see the first iteration take longer than subsequent iterations. You could also collect these/max/min values for reference.
- Replace the Express VI with it's appropriate equivalent code (I think you can do that from the configuration of the Express VI) - you should get 3 VIs...an initialise, read and close VI. Place the initialise and close outside of the timed loop.
- As you know you want 1000 samples, initialise the array before the loop, keep it in a shift register and use replace array subset to replace the items each time the loop runs. This allocates the memory in advance for more efficiency.
If you wanted to get really accurate with your timing, you would write some FPGA code which acquires 1000 samples at 1kHz and uses a DMA FIFO to transfer them to the RT part of the myRIO...but we may be getting ahead of ourselves!