LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA to Host Data Aquisition Trouble with FGPA I/O Items

Hi everyone - 

 

I'm having an issue where I can't seem to get my FPGA code to read data channels. My goal is to pull data using FPGA, push it to a DMA buffer, and then have my host computer pull data from the DMA buffer and save it. The goal is to take pressure and temperature data at 2000 Hz. 

 

Current Issue

I've used the FPGA wizard to create an FPGA VI and a host VI. While I'm in the FPGA VI, I need to tell it to read in which channels (from the NI 9201) and to write them to the buffer. I can add a Read I/O Method item, and it shows three options. I/O Item, Timeout, and Timed Out. I believe when I click on I/O Item I should be able to select Mod2/AI0, for example. But instead it just says "No FPGA I/O Selectable". I'm not sure what I'm missing. I've attached the screenshot of the error, my two VIs, and a screenshot of my project. 

 

Troubleshooting

I tried to use an I/O node instead of a Read I/O Method item. For this one, I am able to select I/O items without issue. However, when i try to take in data and then display it on the FPGA front panel (for debugging purposes), the data remains at 0.00000. I'm expecting it to read 0.0000 , -0.0001, 0.001, etc from jitter. If I try to pass it to my host VI and save the data, the resulting data text file is empty. It's possible that I'm not passing or saving the data correctly, but my suspicion is that I'm just not reading in data from the start, and so I'm not passing anything through the buffer. Also - if I try to create a Reset I/O method, I get the same error where it says there are no selectable FPGA I/O items. So I'm not sure why I can select them for a node but not for method(s). 

 

Please note that I'm using an expansion chassis, so I don't have Labview Real-Time. After reading Labview material, it says that I should be able to pass the FPGA data directly to the host, but it might not be an expected method of data aq. 

 

Hardware

 

  • NI 9146 with 4 slots that have:
    • NI 9213 with 6 thermocouple channels
    • NI 9201 with 8 pressure transducer channels
    • NI 9472 empty
    • NI 9472 with 5 valve command channels
  • Lenovo Desktop computer, with Windows 7 64-bit

 

Software

  • Labview 2011 SP1
    • Development System, Professional Development System
    • Application Builder, FPGA Module (and FPGA Development), Real Time Module, Touch Panel Module
    • All available toolkits
    • NI LabVIEW Signal Express 2011
    • NI LabVIEW System Identificaiton Assistant 2011

 

Any ideas where I'm going wrong?

0 Kudos
Message 1 of 8
(3,317 Views)

For I/O you generally use an I/O Item, not a Method. A Method is more often used for configuring some parameter of the item, not for reading the input or setting the output (although this has changed between versions of LabVIEW FPGA and depends somewhat on the hardware). You didn't upload your full project so I can't quickly confirm this, but it's quite possible that you have no I/O channels that support any methods, so you can't select a channel from the method node.

 

Have you checked the error wires to confirm that you're not getting an error when you try to run your FPGA VI? Have you tried running it with execution highlighting enabled? Tried running it with the FPGA running in simulation rather than on the real hardware? (Right-click the FPGA target within the project explorer).

0 Kudos
Message 2 of 8
(3,282 Views)

Hi Nathand,

 

Thank you for your response.

 

How do I save an entire FPGA project to be able to upload it here? I have the project file, but I don't think all the necessary files are included with it. 

 

I switched the code to only use I/O nodes. When I run the codes together, there are no error codes. Everything runs, but there's just no data. When I try running in simulation mode, the FPGA VI runs without issue, showing that there's a buffer underflow, and it shows a random integer in the Numeric output box. So that's promising. But if I run the host VI at the same time, it throws the error "NI-488: Command requires GPIB Controller to be Controller-In-Charge". It also says "An input parameter is invalid. For example if input is a path, the path might contain a character not allowed by the OS such as ? or @." I believe this must be because I'm trying to give it a name for the saved file. The VI pops up the window, asking for the new data file's name, I give it Test01, and it throws this error. 

 

I didn't know about highlighting and stepping through until just now. I turned that on and ran through the FPGA VI on the simulation. It shows the sim FPGA Target generating data, and that data being transferred to the Auto-Indexed Tunnel, but never to the buffer. I ran through a few loops and the bubbles never went to the BuffDMAIn0 block. 

 

Thanks for your help!

0 Kudos
Message 3 of 8
(3,274 Views)

To upload your entire project, make a ZIP archive containing all the relevant files - the Project (lvproj) file and all of your VIs. It looks like there aren't too many of them. That would make it possible to duplicate exactly what you're doing and see the same errors (at least in simulation).

 

I don't see anywhere in your code where you attempt to log to a file.

 

Where does the "Input parameter is invalid" error occur? Depending on how you're reporting the error, it should show you exactly which function or VI generates the error, which would be helpful.

0 Kudos
Message 4 of 8
(3,262 Views)

Alright, I've attached the project and VI files. Let me know if it asks for anything else. 

 

About logging, in the NEERhiMain20 code (which is my host code), I attempt to save the data to a txt file. In both codes there is an error display that is supposed to display errors on the front panel. 

 

I worked on hunting when and where the errors happen. When I step through the NEERhiMain20 VI, it runs smoothly at first. It pops up and asks me what to name my file. That works fine. It never gives me the chance to click the Start button though. It gets all the way up to the Flush structure when it throws error code -61167 ("niLvFpga_Reset_Dynamic.vi") to the front panel. It keeps going. Then when it gets to the Close File item (which is outside the loop, but it reaches this after only one loop), the "input parameter is invalid" error pops up. Just thinking aloud here: So it seems like it's closing the file after only one loop. It is supposed to run several loops and only close once I click stop. I'm also supposed to be able to click Start to start taking data. I think perhaps I've done something in the wrong order because it gets an error about closing a file, when it shouldn't even be thinking about closing the file.

 

I attached screenshots of both errors. Thanks in advance for your help.

0 Kudos
Message 5 of 8
(3,254 Views)

You have a couple of problems:

1) Don't wire a 0 to the number of iterations for the For loop. That's why it never sends any data to the DMA FIFO. Since you're also trying to auto-index on the array, no need to wire anything to the N terminal.

zero iterations.png

2) It's obvious from the error message that the Reset method isn't supported in simulation, so take it out! Or disable it, with a diagram disable structure or case structure.

3) You should store the file refnum in a shift register, and DON'T leave that terminal unwired in any case of the case structure. That's the reason you're getting the error at the end, as you can see with execution highlighting turned on. You get an error from the unsupported (in simulation) Reset method, which means none of the other FPGA functions execute, and you enter the "0" case of the logging case structure. You left the file refnum unwired so the output is a default value, which isn't a valid refnum, so you get an error when you try to close the invalid refnum.

Message 6 of 8
(3,247 Views)

Thank you, this is very helpful. I've fixed all of your corrections and now it's running a lot smoother, but still not getting the simulated data where it needs to go. A few notes and questions:

 

1. For the ref num, should it go through a shift register for every loop? Right now I have it enter the outer loop through a shift register, then go into the inner loop through a shift register as well. It then exits one shift register, then the next, and finally goes to the close file item.

2. I figured out that it was stopping the data acquisition loop if there was a buffer underflow, so I told it to only stop when I gave it the local stop signal.

3. Before I realized #2 above, I thought maybe it was timing out. So I told both buffer write and read to never timeout. 

4. I realized I was always giving it the 0 signal for the data ready loop. I stopped that, and told it a signal of 3. I also told the buffer read item that the number of elements was 3, although I'm realizing that I don't think that's correct. How does one calculate or choose the number of elements to tell the Buffer to read? 

 

Updated project is attached if that's helpful.

 

Thank you.

 

 

0 Kudos
Message 7 of 8
(3,227 Views)

scarrera wrote:

1. For the ref num, should it go through a shift register for every loop? Right now I have it enter the outer loop through a shift register, then go into the inner loop through a shift register as well. It then exits one shift register, then the next, and finally goes to the close file item.

The way you have it set up is correct. It would also work with tunnels instead of shift registers, but for this sort of pattern a shift register is usually a better choice.

 


@scarrera wrote:

4. I realized I was always giving it the 0 signal for the data ready loop. I stopped that, and told it a signal of 3. I also told the buffer read item that the number of elements was 3, although I'm realizing that I don't think that's correct. How does one calculate or choose the number of elements to tell the Buffer to read?


I can't figure out what you're trying to say or do here. You always try to read 2000 elements, so why does the 3 matter? What is the "DMA Calcs" VI supposed to be doing?

 

In your logging case structure, what's the point of converting an array of integers into an array of singles, and then that array into an array of doubles, and formatting them with a decimal when you know they're integers? What's the 0 supposed to signal, versus any other value? Also, instead of doing decimate/build/transpose array, use Reshape Array to get the 1-D array to a 2-D array.

 

The number of elements to read depends on how often you need the data. When logging to a file, it's generally better to process larger chunks rather than smaller ones. It also depends on how fast you're acquiring the data and the size of your DMA FIFO, since of course you want to retrieve data before the FIFO fills. It's best to use a short timeout with the DMA FIFO Read. You know your sampling rate so you know how long it will take to acquire the desired number of points. A good approach is to wait just slightly less time than it will take to acquire all the data, then have a short but non-zero timeout on the DMA FIFO Read, so at most you're waiting a short time and the code still has a chance to catch up (slowly) if it's slightly behind. Another common approach is to read 0 elements from the DMA FIFO, which will return the number of elements available, then do a second read with a zero timeout for that number of elements. See here for more information: http://digital.ni.com/public.nsf/allkb/583DDFF1829F51C1862575AA007AC792

Message 8 of 8
(3,222 Views)