11-08-2024 07:50 PM
Hello,
I have a PXIe system (PXIe-1071 chasis with PXIe-8840 controller) and I have an FPGA (PXIe-7965R) in one slot. AI module NI-5761 is attached to it, which is rated for 250 MS/s over four channels. What I'm trying to do is stream data from the AI module at 40 MHz and save it to a file on the controller. I want to do this with a python interface, since the PXIe-8840 has a Linux OS on it and I'm aiming for maximum performance and can't afford hiccups due to Windows nonsense. Ideally the data would stream indefinitely. I probably need to capture 30-60 minutes of data at most, but would like to be able to do it indefinitely. I'm reading only 2 channels from the AI module as I16 data type, which means I would need around 80 Mbyte/s which seems rather reasonable and well within modern computing capabilities.
The way I'm doing it is via target-to-host FIFO. I call the buffer with
AI0_fifo=session.fifos['AI0-FIFO']
AI0_fifo.configure(BUFFER_SIZE)
where I used BUFFER_SIZE ranging from 10K to 100M. This seems to work. If I monitor the size of the FIFO I see it go up as I collect data and the rate at which it grows is as I would expect i.e. 40 samples per microsecond. Without reading the FIFO obviously the FIFO fills up. However, when I read the FIFO I can't seem to be able to keep up. I use the following to read the FIFO
AI0_values = AI0_fifo.read(num_samples, timeout_ms=100)
where num_samples I tried ranges from 100 to 10M. If I check the amount of time it takes to read number of samples I get the same number of seconds per sample no matter how big of data chunk I try to read from FIFO. In my case this is roughly 8-10 microseconds per sample. This seems REALLY slow since it would give me ~100 kS/s rate which is way below what I would expect. Mind you I'm not even writing this to a file or doing any processing at this point, just timing how long it takes to get AI0_values tuple generated.
What I'd like to know is if there is some sort of limitation with NIFPGA for python implementation where this is not possible. Or if there is something really wrong in what I'm doing. From the documentation it seems to be pretty straightforward. If I only needed to capture a few seconds of data this would work, since I could just make a huge buffer, let it fill up and then read out at my own leisure. Since I want to do a more or less continuous stream I really need to get a speed up.
Any help/thoughts/comments are appreciated.
Thanks.