From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple AI reads cause timing violation

Solved!
Go to solution

Hi,

 

I have a simple piece of FPGA code that writes to 8 digital outputs and reads from 72 AI channels (spread across three 9205 modules) in one while loop. This code refuses to compile because of timing violation. While disabling parts of the read, I found that this violation occurs for more than 36 AI reads. However, I could not find any information on limits for how many channels can be simultaneously read. I have tried using separate I/O nodes for each module, separating into two loops, and increasing the wait time. Nothing seems to solve this problem. There is not a lot of scope for pipelining in parallel reads and writes. Any help is appreciated.

 

Thanks

0 Kudos
Message 1 of 11
(3,203 Views)

You only mentioned the modules. What controller is this running on? Just curious.

0 Kudos
Message 2 of 11
(3,181 Views)

By controller do you mean cRIO? It's the 9039 (Sync).

0 Kudos
Message 3 of 11
(3,136 Views)

So you have a 9039 with three 9205's. What module are you using to do the analog output? Do you have any other modules?

 

When you say that the issue shows up for more than 36 reads, were you able to get it working with 36 but not 37? Is this with the analog output code included? Do you see a change if you remove that?

 

What's your sample rate on the AI and AO channels? I'm assuming you're using a 40 MHz FPGA clock?

 

Does your code do anything besides analog I/O? Would you be able to post it?

 

A couple of things I would try at this stage:

Try replicating the AI behavior by editing the "NI 9205 Basic IO" example in the example finder.

Try changing to a derived clock with a little higher frequency and see if the behavior changes.

Bill B.
National Instruments
0 Kudos
Message 4 of 11
(3,122 Views)

I am using a 9476 for digital output. I am not providing analog output or using any other modules.

I have tried the code with two modules being read instead of three, and with the digital output removed, among other things. They only change the violation by some pico seconds but do not solve the problem. I haven't gotten to figuring out the exact threshold for AI reads that causes this issue.

I can't say for sure what the sampling rate is. I am using a 40MHz FPGA clock. I just tried using a 80MHz clock, and that did not help either. Is there a way to find what the sampling rate for each module is? 

I am also attaching my code for you to have a look.

Thanks!

 

0 Kudos
Message 5 of 11
(3,111 Views)
Solution
Accepted by topic author I.Ray

Oh, sorry, I misread that as analog out for some reason.

 

Looking at your code, it looks like you're using read/write controls for all of the channels. This is probably part of the problem. If you don't put in a delay value into the loop, it's going to try and run at the 9205's max speed, which I believe is about 200KHz aggregate. The read/write controls probably just can't keep up with that much throughput.

 

You could maybe try and make the current setup work by lowering the loop rate to a really low value. However, the better approach is going to be using the DMA FIFO. This will make your code more expandable and improve maintainability. The 9205 Basic IO example that I mentioned uses this approach. I would start from that base and expand it to meet your needs.

Bill B.
National Instruments
0 Kudos
Message 6 of 11
(3,103 Views)

That makes sense, and I was looking at the example thinking about that. This is probably a dumb question but what would I do if I wanted to display the readings, instead of just storing them in the FIFO? I know I can read from the FIFO, but will that not cause the same loop rate problem again? Or would collecting the data in the FPGA layer and displaying it in the RT solve this problem?

0 Kudos
Message 7 of 11
(3,098 Views)

Not at all. That can actually become fairly complicated depending on the circumstances.

 

What it really depends on is how much post-processing you're doing to the signal.


Essentially, the benefit of the fifo is that it enables a producer-consumer architecture where the FPGA produces the data at the rate that it needs to and then the RT host can process (or consume) the data at its leisure. It does this by creating a buffer between them, and the RT host can read all or part of the buffer in a single read. This gives you more breathing room for processing, but in some applications, the RT host could still have trouble keeping up.

 

However, in your application, as I understand it,I think the example will function as needed. It actually reads everything up to the last full cycle of the buffer and sends it to a graph. I think that will be good enough to get you moving. If you end up needing to do more processing at some point and run into more trouble, I'd make another post at that time.

Bill B.
National Instruments
Message 8 of 11
(3,094 Views)

I changed it to read into a DMA FIFO and it finally compiled! I will try reading it in the RT now. But yes, the data will not just be displayed but also processed. I was hoping to do some of that in FPGA but hopefully I'll be able to make it work in the RT code. 

 

Thank you for all your help, Bill!

0 Kudos
Message 9 of 11
(3,091 Views)

@I.Ray wrote:

But yes, the data will not just be displayed but also processed. I was hoping to do some of that in FPGA but hopefully I'll be able to make it work in the RT code.


Use a target defined FIFO.  Then you can really do the Producer/Consumer inside of the FPGA where your acquisition loop reads the data and throws it into the FIFO and another loop gets the data from the FIFO and processes it.  You can then use a DMA FIFO to pass that processed data to the RT if you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 11
(3,080 Views)