Example language usage – VXI VT1422A User Manual

Page 185

Advertising
background image

Creating and Running Algorithms 183

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>)

Example Language

Usage

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;

/* 20 mA max output */

static float output_min = .004;

/* 4 mA min output */

static float input_val, output_val;

/* intermediate I/O vars */

static float remote_input_val;

/* I/O var for remote channel*/

input_ val = I108;

/* get value from input buffer channel 8*/

remote_input_ val = I14001;

/* get value from input buffer channel 4001*/

output_val = 12.5 * input_val;

/* calculate desired output */

if ( output_val > output_max )

/* check output greater than limit */

output_val = output_max;

/* if so, output max limit */

else if( output_val < output_min)

/* check output less than limit */

output_val = output_min;

/* if so, output min limit */

O116 = output_val / 2;

/* split output_val between two SCP */

O117 = output_val / 2;

/* channels to get up to 20 mA max */

writecvt(remote_input_val,501);

/* remote chan val to CVT element 501 */

Advertising
This manual is related to the following products: