This paper belongs to the Advanced Features in High-Speed Digital I/O Devices: White Paper Series
Download a PDF of the entire Advanced Features of High-Speed Digital I/O Devices White Paper Series
Scripting is used for linking and looping together multiple waveforms. A script is just a series of instructions that indicates how many waveforms saved on the onboard memory should be sent to the DUT and in what order. 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.
Figure 1 - The script editor can be used to create scripts which can then be loaded into LabVIEW or other programming environments for generation of complex waveforms.
You can create a script to manage dynamic 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 dynamic generation and, upon receiving this trigger, generate waveform A three times, then generate marker 0, and finally generate waveforms B, C, and D twice (BCDBCD).
A simple script example is shown below:
Script MyScript
Generate WfmA
Repeat Forever
Generate WfmB subset(100,400)
Repeat 2
Generate WfmC
end repeat
end repeat
end Script
Figure 2 - Scripting can be used for linking and looping of waveforms or their subsets.
Since waveforms can be repeated, memory utilization becomes a valuable advantage of scripting. In the figure below, the entire waveform takes up 1.5MB on the onboard memory of the device.
Figure 3 : Generating a complex digital waveform takes up a lot of onboard memory.
However, if you look closely, a part of the above waveform is repeated multiple times. The figure below shows how we can break up the above diagram into repeating waveforms.
Figure 4: Scripting can be used to generate repetitive waveforms. The memory occupied by the waveform after using scripting is much lesser.
A user could use a script similar to the one below to utilize memory better.
Script MyScript
Generate WfmA
Repeat 3
Generate WfmB
End Repeat
Generate WfmC
End Script
Scripts consist of six primary instructions: generate, repeat/end repeat, if/else/end if, wait, 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.
Some examples of scripting instructions are:
There are different kinds of script triggers that you can use for triggering individual waveforms..
Types of Triggers
None | |
Digital edge (29) | The device does not use a Script trigger. |
Digital level (30) | The data operation does not start until a digital edge is detected. |
Software (32) | The Script trigger is active when the level of the Script trigger matches the desired level. |
The data operation does not start until a software trigger occurs. | |
Table 1: Types of Triggers for scripting
The memory option corresponds to the number of samples you store in memory. For generation the memory is shared with the script. Most scripts use very little memory (on the order of 1000 samples). On acquisition only, you can increase the channel memory by reducing the data width. If you are trying to convert the memory size in MB. You have
Ex. 6552
64 mb/ch x 4 =256 MB
Since this is dedicated for both acquisition and generation the 64 mb/ch board has 512 MB of memory. Please refer to Advanced Features of High-Speed Digital I/O devices: Memory for exact calculations of Script Size.
You can generate a single waveform using scripting.
script upOnly
generate countUp
end script
You can generate a subset of a particular waveform. The code below generates 40 samples from countUp starting at sample 10.
script upOnlySubset
generate countUp subset (10, 40)
end script
You can also generate waveforms with markers. The example below generates a marker at samples 0 (start of the waveform) and 20.
script upOnlyWithMarkers
generate countUp marker0 (0, 20)
end script
You can generate waveforms in a sequence with no software lag in between.
script upAllOnesDown
generate countUp
generate allOnes
generate countDown
end script
You can create a script to repeat a particular waveforms a finite number of times.
script up3AllOnesDown
generate countUp
repeat 3
generate allOnes
end repeat
generate countDown
end script
script upOnesOrDown
generate countUp
if scripttrigger0 then
generate allOnes
else
generate countDown
end else
end script
script upAllOnesUntilTrigDown
generate countUp
repeat until scripttrigger0
generate allOnes
end repeat
generate countDown
end script
script upThenUpAndDownForever
generate countUp
repeat forever
generate countUpAndDown
end repeat
end script
script upWaitAllZerosDown
generate countUp
wait until scripttrigger0
generate allZeros
generate countDown
end script
or
script upWaitAllZerosDown
generate countUp
clear scripttrigger0
wait until scripttrigger0
generate allZeros
generate countDown
end script
Note: These two scripts are similar, but a script received during generation of countUp causes the first script to move to allZeros after the smallest possible delay. By adding a clear instruction, you can ignore any triggers received before the wait instruction. |
script upWait32Down
generate countUp
wait 32
generate countDown
end script
script stepThroughUpAllZerosDown
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
script burstThroughUpDownThenZerosOnes
repeat forever
repeat until scripttrigger0
generate countUp
generate countDown
end repeat
repeat until scripttrigger0
generate allZeros
generate allOnes
end repeat
end repeat
end script
Users can use scripting to generate complex waveforms and perform onboard operations such as hardware decision making based on script triggers. Scripting can also be used to link and loop waveforms to utilize the onboard memory in the best way possible.