NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Orel Bechler
Posts: 32
0 Kudos
Accepted Solution

FPGA Timing Error When Compiling PID Loop

Hi.

 

I am using Labview 2011 with an FPGA PCI card- 7833R.

 

My problem is that whenever I try to incorporate FPGA designed VIs into my code, I get a timing error.  See pictures posted below.

 

In this case, I have a PID express VI which I use in a regular while loop (not even timed!) in my FPGA code, but upon compilation I get an error saying that the maximum clockrate possible is 43 MHz.

 

I have many loops, some run on 80 MHz.  Is there a way to slow down a specific while loop, so that it runs at 40 MHz and not 80 MHz like the other?  The compiler doesn't seem to respond to simply adding a loop timer...

 

Thanks,

 

Orel.

 

P.S.  The same thing happens when I try to add a low-pass filter VI to the FPGA code.

Member
Finnabon
Posts: 102
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Hi Orel, 

 

What do you have the Sample Time of the PID Express VI set to?

 

Have you tried using a Timed Loop Structure with the 40MHz OnBoard clock as its source?

 

Are you certain this error is a result of this loop? If you were to compile an FPGA project with just this segment of code in the project, does this error still occur? 

 

Let me know, and I'll see what else I can find for you.

 

Allie

Member
Orel Bechler
Posts: 32
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Hi Allie.

 

Thanks for your reply.

 

As far as I know, the Sampling Time (Ts) input of the PID Express VI has nothing to do with the execution clockrate.  It affect the output of the VI.  Nonetheless, I've tried them all- 80 MHz, 40 MHz, and even slower clockrates.

 

I've also tried the Timed Loop Structure with the 40 MHz OnBoard clock as you suggested, but upon generation of the compilation files it tells me that this object (PID Express VI) is not supported in the single-cycle Timed Loop.  This is also true for the Tick Count Express VI and the Filter VI.

 

I'm certain this error is a result of this loop, as I've tried to compile an FPGA VI which includes just this loop and nothing else.

 

Is this some sort of bug?  Or perhaps I have the FPGA or compiler inefficiently configured somehow?

 

Again, thanks for your time.

 

Orel.

 

P.S.  I'm attaching the project window, showing the configuration of my FPGA.

Member
Finnabon
Posts: 102
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Hi Orel, 

 

I'm going to set up the hardware and try compiling the code here on the same hardware to see if I can reproduce the issue. It shouldn't take too long once I track down all of the hardware.

 

Let me know if there are any remaining details I should know before I get started!

 

Allie

Member
Orel Bechler
Posts: 32
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Thanks!

 

I guess the main issue is about FPGA clockrate and how to manage it.  I think these VIs would work at 40 MHz, but I also need the 80 MHz derived clock.

 

I thought that setting the rate of a regular while loop to be 40 MHz should solve the problem, but I guess I was wrong...  Maybe I should try doing it with a constant and not a control variable.

 

Orel.

Trusted Enthusiast
nathand
Posts: 2,823
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Is it possible you set the top-level clock to 80Mhz?  That's what it looks like to me.  In the project explorer, right-click the FPGA target, select properties, then go to the "Top-Level Clock" category.

Member
Finnabon
Posts: 102
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

I agree with Nathan. Double check that your toplevel clock isn't set to 80MHz. 

 

I tested it out and it only failed timing requirements with the top level clock was 80MHz as opposed to 40MHz.

Member
Orel Bechler
Posts: 32
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Thanks Allie and Nathan!

I'll give it a try next week.

Will that change anything in regards to the other 80 Mhz loops? How will the compiler distinguish which is which?
Trusted Enthusiast
nathand
Posts: 2,823
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

If you need to specify which clock to use, use a timed while loop instead of a standard one.

 

Quick introduction to FPGA clocks, ignore if you already know all this:

A standard LabVIEW while loop will not necessarily execute in a single FPGA clock cycle.  To guarantee that a loop will execute in a single clock cycle, use a Single-Cycle Timed Loop (SCTL) - a timed loop that uses the internal clock (or a derived clock) as the timing source.  You will see SCTLs mentioned in the FPGA documentation.  Code inside a SCTL uses fewer FPGA resources, but is also subject to some restrictions.  You cannot place more code inside a SCTL than can execute in a single clock cycle, and some functions cannot be placed inside a SCTL because they require multiple clock cycles to execute.

 

In the case of the PID function, there must be something inside it that needs to execute in a single cycle and requires more time to execute than an 80mhz clock allows.  Since a standard while loop is governed by the top-level clock, anything inside it that must execute in a single cycle is subject to that top-level clock even if the overall loop takes more than one cycle to execute.

Member
Orel Bechler
Posts: 32
0 Kudos

Re: FPGA Timing Error When Compiling PID Loop

Thanks, Nathan.

 

Your post was most helpful.  I'm familiar with the Single-Cycle Timed Loop structure, but I still don't understand if changing the top-level clock changes the tick count of the FPGA.  I mainly use regular while loops timed using ticks.

 

I would think that each tick would now stand for one 40 MHz cycle (which is 25 ns).  Is that correct?

 

Thanks again,

 

Orel.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page