LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected behavior of the FPGA VI Reference Function

Hi everyone. I have a LabView code on PC that calls the FPGA VI Reference Function (https://www.ni.com/docs/en-US/bundle/labview-fpga-module/page/lvfpgahost/open_fpga_vi_reference.html) to run a LabView FPGA code. The main code also passes a number (e.g., 1, 2, or 3) to the LabView FPGA code to determine which function to run. My problem is that let's say I enter number 3 and start running the program, somehow the FPGA code seems to first run with either the default number or the number that I entered last time before it stopped, and then 3, but not run with 3 directly.  In other words, whatever the FPGA code executes, it is offset by a number (e.g., it will go from 1 - 2 - 3 - 2 if I enter 2 - 3 - 2, where the 1 is either from last time or the default value).

 

I am wondering what caused this behavior and whether it is related to the memory of the FPGA VI Reference Function? Is there any fix to this problem? Really appreciate your help!

0 Kudos
Message 1 of 8
(1,052 Views)

We never write any value to the register before the FPGA VI is running. Use an interrupt to notify that the FPGA VI is ready.

Synchronizing FPGA VIs and Host VIs Using Interrupts (FPGA Interface)

ZYOng_0-1679609391055.png

 

On the host PC, do the following:

1. Run FPGA.

2. Wait for the IRQ from the FPGA VI

3. Write FPGA I/O for the function value.

4. Write Start command to start execution.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 8
(1,041 Views)

See https://www.ni.com/docs/en-US/bundle/labview-fpga-module/page/lvfpgahelp/config_fpga_vi_to_run_auto....

 

The bitfile (when compiled) can be set to run automatically.

 

In https://www.ni.com/docs/en-US/bundle/labview-fpga-module/page/lvfpgahost/open_fpga_vi_reference.html... see "Select the open behavior."

 

Somewhere a setting has the bitfile running before you get a chance to set the control value.  One of the above items should allow you to correct this.  if you recompile the bitfile, maybe you should set it so default values do not allow it to go into a 'running' state (though this may be an overreach).

 

To the above post on interrupts, I would add that you can do this some other way as well (such as checking that a counter or value on the FPGA VI is changing or at an expected value).  Not against interrupts, bottom line, it is good to confirm bitfile state before going to the next step of an application.


Certified LabVIEW Architect, Certified Professional Instructor
ALE Consultants

Introduction to LabVIEW FPGA for RF, Radar, and Electronic Warfare Applications
0 Kudos
Message 3 of 8
(990 Views)

Hi Justin, Thank you for posting this for me!

0 Kudos
Message 4 of 8
(871 Views)

Hi Terry, thank you for sharing the links, my issue is not about automatic running, it's more about starting from default values, but you are pointing out a feature that I ignored previously, I will double check, thanks!

0 Kudos
Message 5 of 8
(868 Views)

@princelog wrote:

Hi Terry, thank you for sharing the links, my issue is not about automatic running, it's more about starting from default values, but you are pointing out a feature that I ignored previously, I will double check, thanks!


It is related.  If automatic running is disabled, you can set the control values to bypass the defaults and then run the bitfile.


Certified LabVIEW Architect, Certified Professional Instructor
ALE Consultants

Introduction to LabVIEW FPGA for RF, Radar, and Electronic Warfare Applications
0 Kudos
Message 6 of 8
(847 Views)

Hi ZYOng,

 

Your solution resolved my issue, and if I may add, it will be good to complete your list as:

 

On the host PC, do the following:

1. Run FPGA.

2. Wait for the IRQ from the FPGA VI

3. Write FPGA Input for the function value.

4. Write Start command to start execution.

5. Read FPGA Output from the execution result.

 

PS. have you ever tried communicate between DSOX2024A (Keysight) O-scope and computer through labview?

0 Kudos
Message 7 of 8
(816 Views)

Hi Terry, thank you, I mean I know this part so it's not blocking my progress, but think you for the insight!

0 Kudos
Message 8 of 8
(815 Views)