Example Language Usage - VXI VT1422A User Manual

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

Advertisement

Example Language
Usage
Chapter 6
Arithmetic Operators: add +, subtract -, multiply *, divide /
Note: See "Calling User Defined Functions" on page 193.
Assignment Operator: =
Comparison Functions: less than <, less than or equal <=, greater than
>, greater than or equal >=, equal to ==, not equal to !=
Boolean Functions: and && or ||, not !
Variables: scalars of type static float and single dimensioned arrays of
type static float limited to 1024 elements.
Constants:
32-bit decimal integer; Dddd... where D and d are decimal digits but D is
not zero. No decimal point or exponent specified.
32-bit octal integer; 0oo... where 0 is a leading zero and o is an octal digit.
No decimal point or exponent specified.
32-bit hexadecimal integer; 0Xhhh... or 0xhhh... where h is a hex digit.
32-bit floating point; ddd., ddd.ddd, ddde±dd, dddE±dd, ddd.dddedd
or ddd.dddEdd where d is a decimal digit.
Flow Control: conditional construct if(){ } else { }
Intrinsic Functions:
Return minimum; min(<expr1>,<expr2>)
Return maximum; max(<expr1>,<expr2>)
User defined function; <user_name>(<expr>)
Write value to CVT element; writecvt(<expr>,<expr>)
Write value to FIFO buffer; writefifo(<expr>)
Write value to both CVT and FIFO; writeboth(<expr>,<expr>)
Here are examples of some Algorithm Language elements assembled to
show them used in context. Later sections will explain any unfamiliar
elements seen here:
Example 1;
/*** get input from channel 8, calculate output, check limits, output to ch 16 & 17 ***/
static float output_max = .020;
static float output_min = .004;
static float input_val, output_val;
static float remote_input_val;
input_ val = I108;
remote_input_ val = I14001;
output_val = 12.5 * input_val;
if ( output_val > output_max )
output_val = output_max;
else if( output_val < output_min)
output_val = output_min;
O116 = output_val / 2;
O117 = output_val / 2;
writecvt(remote_input_val,501);
/* 20 mA max output */
/* 4 mA min output */
/* intermediate I/O vars */
/* I/O var for remote channel*/
/* get value from input buffer channel 8*/
/* get value from input buffer channel 4001*/
/* calculate desired output */
/* check output greater than limit */
/* if so, output max limit */
/* check output less than limit */
/* if so, output min limit */
/* split output_val between two SCP */
/* channels to get up to 20 mA max
/* remote chan val to CVT element 501 */
Creating and Running Algorithms
*/
183

Advertisement

Table of Contents
loading

Table of Contents