298 Chapter 8
Using Agilent VEE Functions
Using Functions
Otherwise, it is stored to be called from the Call object or any other
expression field. Changes to a
UserFunction will be inherited by all
instances in the program that calls that
UserFunction. You can also create
libraries of
UserFunctions for more code re-use.
Lab 8-1: UserFunction Operations
This exercise describes how to create a UserFunction named
ArrayStats, which will accept an array, calculate its maximum value,
minimum value, mean, and standard deviation, and put the results on its
output pins.
Creating a UserFunction
1. Select Device ⇒ Formula, delete its default input pin, and change its
default expression to
ramp(1024,1,1024).
This will create a 1024 element array with values from 1 to 1024.
2. Select
Device ⇒ UserFunction. Rename it ArrayStats.
a. Add one data input terminal for the array
b. Add four data output terminals for the results.
c. Rename the output terminals:
Max, Min, Mean, and Sdev. Select max,
min, mean, and sdev from the Probability & Statistics
category in the
Function & Object Browser box.
d. Place them in
ArrayStats, and connect their data inputs to A and
their data outputs to the appropriate output terminals. Make the
ArrayStats window smaller to see both of the Main and
ArrayStats windows. See Figure 8-1.