09-05-2013 09:32 AM
Hi,
I am measuring voltage from resolvers which run at +-10V and 4KHz with a CRIO equipped with AI slot 9201. I am very rookie on CRIO stuff but the 9201 is able to sample at 500KS/s so that means that the FPGA should be adcquiring at more or less 62 KHz all channels. I am passing the data from the target to the RT with a FIFO configured with 4095 elements although I only need 8 each time. Ideally I have to do operations with these voltages in the RT loop at 40 Khz more or less but with simply timming techniques involving Thick count I am measuring only 150 Hz on my RT loop!!! I would appreciate any clue about where I am making mistakes. Thanks!!
Enrique
09-05-2013 11:48 AM
I see a number of problems here, but I don't think you'll get to 40khz even if you fix all of them.
First, you have Wait until Next Ms Multiple inside the timed loop, with the value set to 1 ms. So that loop won't ever execute faster than 1khz. There's no need for a separate wait inside a Timed Loop - use the loop timing. In addition you have the DMA FIFO read, which will limit the timing to whichever is slower - the DMA read, or the 1ms wait. On the other hand, if you didn't have something else inside the loop limiting the loop rate, the 1mhz cycle time would probably consume all the CPU time and network communication would fail. My recommendation is that you use only one timing mechanism in the loop.
Second, you should not configure the DMA FIFO depth to be so small; it will likely lead to the DMA filling and losing data. Try removing the FIFO configure and let it use the default depth, unless you have some specific reason to change it. The FPGA will normally run much faster than the host, so the FPGA will write small amounts of data to the FIFO frequently and the host reads much larger blocks at a slower rate. In your case you're trying to keep them matched, implying that the host and FPGA run at the same loop rate, which is unlikely to work well. The host probably cannot process samples as fast as the FPGA can read them, if you're trying to process each value individually.
Finally, if you really want to maximize the sampling rate and transfer to the host, then you should read one input while you write the previous one to the FIFO, instead of reading all 8 inputs and then writing them individually to the FIFO. In your current situation there is no sampling while you write to the FIFO, and no transfers to the FIFO while you're sampling.
09-05-2013 11:54 AM
Try taking out the Network Shared Variable. I am guessing that writing to the NSV is really cutting down on your loop rate. However if you do this, it will be dificult to determine what your loop rate is. I suggest that you set up a case structure where you only write to the NSV once every second instead of at 1MHz.
09-06-2013 10:20 AM
Hi,
Thank you very much for your support. It seems that now it is working much better. You have taught me important concepts of these kind of systems.
Regards
Enrique