Common Scripting Use Cases

NI RF Signal Generators Help (NI-RFSG 18.1)


Edition Date: June 2018
Part Number: 371025V-01
View Product Info

Download Help (Windows Only)


NI-RFSG 18.1 Help
NI-RFSG 18.2.1 Help
NI-RFSG 19.1 Help

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

Conditional Branching — If/Else

script branchingExample
    repeat forever
        generate wfm01
        if scripttrigger0 then
            generate wfm02
        else
            generate wfm03
        end if
    end repeat
end script

The following diagram illustrates the preceding script behavior:

Note Note  If you are using a vector signal transceiver (VST) device, Conditional Branching is not supported using NI-RFSG. Refer to Scripting Instructions for more information about VST restrictions on scripts.

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

WAS THIS ARTICLE HELPFUL?

Not Helpful