You can link and loop multiple waveforms together in a generation operation 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 in which the waveforms are generated, the number of times they are generated, and the triggers and markers associated with the generation.

Note When using the Digital Signal Transceiver (DST) instruments, some script instructions used by other devices in NI-RFSG may not be supported.

Basic Scripting Example

You can create a script to manage waveform generation based on multiple waveforms and triggers. For example, you could download waveforms A, B, C, and D into instrument memory and script it to do the following:

  1. Wait for a trigger to initiate generation.
  2. Upon receiving this trigger, generate waveform A three times with a marker at position 16 each time.
  3. Generate waveforms B, C, and D twice (BCDBCD).

The following is the script of 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

Scripting Instructions

Scripts consist of five primary instructions: generate, repeat/end repeat, wait, if/else/end if, and clear. Additionally, all instructions in a script are surrounded by the keywords script <script name>/end script. Multiple scripts can exist on the device at one time—you can choose which script to execute by referencing the script name.

For examples of scripting applications, refer to Common Scripting Use Cases.

Note When using a digital signal transceiver (DST) instrument, the following restrictions for scripts apply:
  • if else instruction is not supported.
  • break instruction is not supported.
  • stream instruction is not supported.
  • The maximum compiled script size is 6,100 instructions. Each script language instruction requires roughly one compiled instruction, plus one instruction for each marker.
  • Nested repeats are only allowed if the outer repeat is a repeat forever instruction, and there are no other instructions preceding it or past the end of the repeat block. You can only use a single nesting level.
  • Markers are allowed in generate and finite wait instructions. They are not allowed in conditional wait instructions.

Common Scripting Use Cases

Refer to Scripting Instructions for examples of using primary scripting instructions, including generate, repeat/end repeat, wait, and clear.

Single Waveform (one-shot/finite generation)

script singleWfmExample
    generate wfm01
end script

This script generates wfm01 and then stops. When generation stops, the last sample of wfm01 is held at the output.

Generating Waveforms with Markers

script wfm01MarkersExample
    generate wfm01 marker0 (0, 20)
end script

This script generates the entire wfm01 waveform and generates a Marker Event at samples 0 (the start of the waveform) and 20.

Sequence of Multiple Waveforms

script upWfm01DownExample
    generate countUp
    generate wfm01
    generate countDown
end script

Generating Waveform Subsets

script wfm01SubsetExample
    generate wfm01 subset (20, 60)
end script

This script generates 60 samples from wfm01, starting at sample 20.

Note The subset beginning sample number must be an integer multiple of 4. The subset number of samples must also be an integer multiple of 4.

Finite Repetition (N Times)

script up3Wfm01DownExample
    generate countUp
    repeat 3
        generate wfm01
    end repeat
    generate countDown
end script

Conditional Repetition — Repeat until Trigger

script upWfm01UntilTrigDownExample
    generate countUp
    repeat until scripttrigger0
        generate wfm01
    end repeat
    generate countDown
end script

Continuous Generation — Repeat Forever

script upThenUpAndDownForeverExample
    generate countUp
    repeat forever
        generate countUpAndDown
    end repeat
end script

Waiting for Triggers

script upWaitWfm01DownExample
    generate countUp
    wait until scripttrigger0
    generate wfm01
    generate countDown
end script

The following diagrams illustrate the preceding script behavior:



or

script upWaitWfm01DownExample
    generate countUp
    clear scripttrigger0
    wait until scripttrigger0
    generate wfm01
    generate countDown
end script


These two scripts are similar, but a Script trigger received during generation of countUp causes the first script to move to wfm01 after the smallest possible delay. By adding a clear instruction, you can ignore any triggers received before the wait instruction.

Finite Wait

script upWait32DownExample
    generate countUp
    wait 32
    generate countDown
end script

Stepping Through Multiple Waveforms

script stepThroughUpAllZerosDownExample
    repeat forever
        generate countUp
        clear scripttrigger0
        wait until scripttrigger0

        generate allZeros
        clear scripttrigger0
        wait until scripttrigger0

        generate countDown
        clear scripttrigger0
        wait until scripttrigger0

    end repeat
end script

Bursting Through Multiple Waveforms

script burstThroughUpDownThenZerosOnesExample
    repeat forever
        repeat until scripttrigger0
            generate countUp
            generate countDown
        end repeat

        repeat until scripttrigger0
            generate allZeros
            generate allOnes
        end repeat
    end repeat
end script