Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
2 ratings:
 5 out of 5     Rate this Document

Specific scripts cause incorrect behavior when using script triggers in NI-FGEN 2.4

Primary Software: Driver Software>>NI-FGEN
Primary Software Version: 2.4
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Signal Sources (AWG/FG/AO)>>Arbitrary Waveform and Function Generators>>PCI-5421, Signal Sources (AWG/FG/AO)>>Arbitrary Waveform and Function Generators>>PCI-5421, Signal Sources (AWG/FG/AO)>>Arbitrary Waveform and Function Generators>>PXI-5421, Signal Sources (AWG/FG/AO)>>Arbitrary Waveform and Function Generators>>PXI-5422, Signal Sources (AWG/FG/AO)>>Arbitrary Waveform and Function Generators>>PXI-5441

Problem: The Script language introduced with niFgen 2.4 and used by the NI Signal Generator products is a very flexible technology. There are a few very specific scripts that do not work as they should. These scripts involve nesting a “repeat until scriptTriggerX” instruction in a “repeat Forever” instruction. For example, the following script does not work as intended.

script myScript0
  repeat Forever
    repeat until scriptTrigger0
      generate wfmSine
    end repeat
    generate wfmSquare
  end repeat
end script

The script is intended to have the AWG generate waveform wfmSine over and over until scriptTrigger0 is True, then generate wfmSquare, and then loop back to repeat wfmSine until the scriptTrigger0, and so on. Unfortunately, after receiving the first scriptTrigger0, generating wfmSquare once, and looping on wfmSine the second time, a second scriptTrigger0 causes the generation to terminate.

Solution: The workaround involves adding a line to the script to use another scriptTriggerX, that otherwise is not being used.

Configure another scriptTriggerX (scriptTrigger 1, for example) as a Digital Level Script Trigger with the niFgen Configure Digital Level Script Trigger.vi. Configure the active level for the desired trigger as “Low Level” and configure the Source as “Low”. Low is not a pre-filled value and must be entered manually. See the following image for an example.

LabVIEW Code Portion

Add an extra “repeat until scriptTriggerX” around the “generate wfmSquare” command. Follow it with the “end repeat” command to finish the “repeat until...” line. See the following script.

script myScript0Fixed
  repeat Forever
    repeat until scriptTrigger0
      generate wfmSine
    end repeat
    repeat until scriptTrigger1
      generate wfmSquare
    end repeat
  end repeat
end script

Though the “generate wfmSquare” instruction is in a “repeat until..” instruction , scriptTrigger1 has been configured in a way that the trigger is always asserted, and as such, wfmSquare will be generated only once before moving to the next instruction.

Here are a few other scripts that don’t work as they should, but have similar workarounds as the solution above.

The following script is similar to the previous script. It generates wfmSquare once, and then loops forever, generating wfmSine inside a repeat until scriptTrigger0 loop. After the first trigger, waveform generation comes to a premature end. The fixed is similar to the previous example, to add an extra “repeat until scriptTriggerX” around the generate wfmSquare line. The scriptTrigger is configured as before.

IssueFixed Version
script myScript1
  generate wfmSquare
  repeat Forever
    repeat until scriptTrigger0
      generate wfmSine
    end repeat
 end repeat
end script
script myScript1Fixed
  repeat until scriptTrigger1
    generate wfmSquare
  end repeat
  repeat Forever
    repeat until scriptTrigger0
      generate wfmSine
    end repeat
  end repeat
end script

The following script is designed to wait until receiving a scriptTrigger0 before moving on to the repeat Forever statement and starting waveform generation. It also comes to a premature end once the second scriptTrigger is received. The fixed version uses a dummy waveform of zeros. This waveform, essentially nothing, will generate until scriptTrigger0 occurs, and then the desired waveform will generate as desired. wfmZeroes should have the minimum number of samples supported by the specific module to minimize delay from trigger to next step of the script. Note that this solution does not require the extra scriptTrigger as described for the previous examples.

IssueFixed Version
script myScript2
  wait until scriptTrigger0
  repeat Forever
    repeat until scriptTrigger0
      generate wfmSine
    end repeat
  end repeat
end script
script myScript2Fixed
  repeat until scriptTrigger0
    generate wfmZeroes
  end repeat
  repeat Forever
    repeat until scriptTrigger0
      generate wfmSine
    end repeat
  end repeat
end script


Related Links:

Attachments:


image.jpg


Report Date: 02/27/2006
Last Updated: 03/13/2006
Document ID: 3UQG9AOL

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit