Script Mode

NI Signal Generators Help (NI-FGEN 18.1)

Edition Date: April 2018

Part Number: 370524V-01

»View Product Info
Download Help (Windows Only)

Script mode allows you to use scripting to link and loop multiple waveforms in complex combinations using a script. A script is a series of instructions that indicates how waveforms saved in the onboard memory should be sent to the DUT. The script can specify the order of the generated waveforms, the number of times they are generated, and the triggers and markers associated with the generation.

To create your script, complete the following steps:

  1. Call the niFgen Configure Output Mode VI or the niFgen_ConfigureOutputMode function to switch to Script mode.
  2. Write all waveforms that are referenced in the script by calling the niFgen Write Named Waveform VI or one of the niFgen Write Named Waveform Functions and associate the proper names to them.
  3. After your waveforms are written to your device, call the niFgen Write Script VI or the niFgen_WriteScript function to write the script(s) containing the generation instructions to be executed.

    The script you write can manage waveform generation based on multiple waveforms and triggers. For example, you could download waveforms A, B, C, and D into device memory. You could then write a script that would wait for a trigger to initiate generation and, as you receive this trigger, generate waveform A three times with a marker at position 16 each time and finally generate waveforms B, C, and D twice (BCDBCD). The following code illustrates this example:

    script myFirstScript

      wait until scriptTrigger0

      repeat 3

        generate waveformA marker0(16)

      end repeat

      repeat 2

        generate waveformB

        generate waveformC

        generate waveformD

      end repeat

    end script

  4. (Optional) You can write multiple scripts that exist simultaneously on your device. If you write multiple scripts to your device, you must select the one you wish to execute by setting the Script to Generate property or the NIFGEN_ATTR_SCRIPT_TO_GENERATE attribute.
  5. Call the niFgen Initiate Generation VI or the niFgen_InitiateGeneration function to execute the selected script.
    Note Internally, the script stores physical device memory locations to refer to named waveforms. Thus, you must write all waveforms to the device before writing the script, or the device does not know where the waveform is located. The niFgen Initiate Generation VI or the niFgen_InitiateGeneration function returns an error if this rule is violated. If you delete waveforms and rewrite them, rewrite the script to update it with the new locations even if the script text has not changed.

    In some cases at high Sample clock rates, your script may result in an underflow error. Underflow errors in a script can be created by waveform size, marker placement, and specific script instructions. To avoid underflow errors, refer to the minimum waveform size in your device specifications.

Related Topics:

Common Scripting Use Cases

Scripting Instructions

WAS THIS ARTICLE HELPFUL?

Not Helpful