Overall Program Structure - VXI VT1422A User Manual

Remote channel multi-function dac module user’s and scpi programming manual
Table of Contents

Advertisement

Overall Program
Structure
/*
Example Algorithm to show language elements in the context of a complete
custom algorithm.
Program variables:
Program Function:
Algorithm returns user_flag in CVT element 330 and another value in CVT element 331
each time the algorithm is executed.
When user_flag = 0, returns zero in CVT 331.
When user_flag is positive, returns user_value * 2 in CVT 331
When user_flag is negative, returns user_value / 2 in CVT 331 and in FIFO
Use the SCPI command ALGorithm:SCALar followed by ALGorithm:UPDate to set
user_flag and user_value.
*/
static float user_flag;
static float user_value;
writecvt (user_flag,330);
if (user_flag )
{
}
else writecvt (0,331);/* else clause goes with first if statement. Note single line else */
Chapter 6
The preceding discussion showed the differences between individual
statements in BASIC and 'C'. Here it will be described how the VT1422A's
Algorithm Language elements are arranged into a program.
Here is a simple example algorithm that shows most of the elements
discussed so far.
user_flag
Set this value with the SCPI command ALG:SCALAR.
user_value
Set this value with the SCPI command ALG:SCALAR.
/* Declaration statements (end with ; ) */
/* Always write user_flag in CVT (statement ends with ; ) */
/* if statement (note no ; ) */
/* brace opens compound statement */
if (user_flag > 0) writecvt (user_value * 2,331); /* one-line if statement (writecvt ends with ; ) */
else
/* else immediately follows complete if-statement construct */
{
/* open compound statement for else clause */
writecvt (user_value / 2,331); /* each simple statement ends in ; (even within compound ) */
writefifo (user_value); /* these two statements could combine with writeboth () */
}
/* close compound statement for else clause */
/* close compound statement for first if */
Creating and Running Algorithms
221

Advertisement

Table of Contents
loading

Table of Contents