Справочник Пользователя для VXi VT1529A/B

Скачать
Страница из 529
Generating User Defined Functions   489
A typical use of this function would be to output an analog voltage or current 
at each Scan Trigger of the VT1422A and over the range of the haversine. 
For example, suppose a new position is desired for an analog output and it 
is moved from 1 mA to 3 mA over a period of 100 ms. If the TRIG:TIMER 
setting or the EXTernal trigger was set to 2 ms, then forcing fifty intervals 
over the range of the haversine is desired. This can be easily done by using 
a scalar variable to count the number of times the algorithm has executed 
and to scale the variable value to the -
π
/2 to 
π
/2 range. 3 mA is multiplied 
by the custom function result over each interval which will yield the shape 
of the haversine (0.003*sin(x)+0.001). 
This is illustrated in the example below. The program (sine_fn.cpp) on the 
CD illustrates the actual program used to generate this haversine function. 
Simply supply the algebraic expression in my_function(), the desired range 
over which to evaluate the function (which determines the table range), and 
the name of the function. The Build_table() routine creates the table for the 
function and the ALG:FUNC:DEF writes that table into VT1422A memory. 
The table MUST be built and downloaded BEFORE trying to use the 
function.
The following is a summary of what commands and parameters are used in 
the program example. Table F-1 shows some examples of the accuracy of 
the custom function with various input values compared to an evaluation of 
the actual transcendental function found in 'C'. Please note that the Mx+B 
segments are located on boundaries specified by 2/64 on each side of X=0. 
This means that if the exact input value that was used for the beginning of 
each segment is selected, the exact calculated value of that function at that 
point will be determined. Any point between segments will be an 
approximation dependent upon the linearity of that segment. Also note that 
values of X = 2 and X = -2 will result in Y=infinity. 
−π/2
π/2
+1
−1
−2
+2
Figure F-1. A Haversine Function