How To Call Multiple Script Files in LabWindows™/CVI™ Using NI-FGEN API

Updated May 11, 2018

Reported In

Hardware

  • PXIe-5451
  • PXIe-5450

Software

  • LabWindows/CVI

Driver

  • NI-FGEN

Issue Details

I have a PXIe-5450 and PXIe-5451. 
I want to load multiple script files in order to generate different waveforms and call those scripts programmatically in LabWindows™/CVI™ . 
How to do it?
 

Solution

In order to call multiple script files programmatically, here are the steps to follow:
 
1.    Initialize the session with the function  niFgen_init(resource, VI_TRUE, VI_TRUE, &vi);
2.    Configure the active channels for the session  with the function niFgen_ConfigureChannels(vi, channelname);
3.    Call the niFgen_ConfigureOutputMode(vi, NIFGEN_VAL_OUTPUT_SCRIPT);  to switch to script mode.
4.    Write all waveforms that are referenced in the script by calling the function niFgen_WriteNamedWaveformI16 (vi, channelname, scriptWaveforms[i].name, numPoints, wfmData); 
You will need to associate the proper names to them.
5.    After your waveforms are written to your device, call the function niFgen_WriteScript(vi, VI_NULL, scripts[currentScript]); to write the script(s) containing the generation instructions to be executed.
6.    Select the script you want to execute by calling the NIFGEN_ATTR_SCRIPT_TO_GENERATE attribute with the function niFgen_SetAttributeViString (vi, channelname, NIFGEN_ATTR_SCRIPT_TO_GENERATE, scripts[ScriptNumber]);
7.    Call the niFgen_InitiateGeneration(vi); function to execute the selected script.
8.    You can check whether the current generation is completed using the function niFgen_IsDone (vi, ViBoolean* Done );. This function sets the done parameter to VI_TRUE if the session is in the Idle or Committed states.
9.    Before calling the next script , you must stop the generation by calling the function niFgen_AbortGeneration(vi);
10.    Repeat steps 6, 7,8,9 in order to choose the next script to run.
11.    At the end, do not forget to close the session using the function niFgen_close(vi);

 

Additional Information

There is a LabWindows™/CVI™ example that demonstrate this functionality :
C:\Users\Public\Documents\National Instruments\CVI\samples\niFgen\ArbitraryScript 

Note.- The signal generator must not be in the Generating state when you change the attribute NIFGEN_ATTR_SCRIPT_TO_GENERATE. To change the device configuration, call the niFgen Abort Generation or wait for the generation to complete.
 

WAS THIS ARTICLE HELPFUL?

Not Helpful