HP VXI 75000 C Series User's And Scpi Programming Manual page 408

Algorithmic closed loop controller
Table of Contents

Advertisement

alg_num++;
}
(void) printf("All %d algorithm(s) loaded without errors\n\n", alg_num-1);
#else /* Download algorithms with in-line code */
algorithm = " \n"\
"/* Example algorithm that calculates 4 Mx+B values upon\n"
" * signal that sync == 1. M and B terms set by application\n"
" * program. \n"
" */\n"
" static float M, B, x, sync;\n"
" if ( First_loop ) sync = 0;\n"
" if ( sync == 1 ) {\n"
"
"
"
"
"
" } \n";
INST_SEND(e1415, "alg:def 'ALG1',500,%*B\n", strlen(algorithm) + 1, algorithm);
#endif
algorithm = " \n"\
"/* Example algorithm that calculates 4 Mx+B values upon\n"
" * signal that sync == 1. M and B terms set by application\n"
" * program. Calculations are different than above.\n"
" */\n"
" static float M, B, x, sync;\n"
" if ( First_loop ) sync = 0;\n"
" if ( sync == 1 ) {\n"
"
"
"
"
"
" } \n";
/* Preset Algorithm variables */
INST_SEND(e1415,"alg:scal 'alg1','M',%f\n", 1.234);
INST_SEND(e1415,"alg:scal 'alg1','B',%f\n", 5.678);
INST_SEND(e1415,"alg:upd\n");
/* Initiate Trigger System - start scanning and running algorithms */
INST_SEND(e1415,"init\n");
/* Alter run-time variables and Retrieve Data */
{
float32 sync, array[4];
int i;
for ( i = 0; i < 10 ; i++ ) { /* make 10 changes to 'x' */
408 Example Program Listings
/* Next algorithm */
writecvt( M*x+B, 10 );\n"
writecvt(-(M*x+B), 11 );\n"
writecvt( (M*x+B)/2,12 );\n"
writecvt( 2*(M*x+B),13 );\n"
sync = 2;\n"
writecvt( -(M*x+B), 10 );\n"
writecvt( M*x+B, 11 );\n"
writecvt( 2*(M*x+B),12 );\n"
writecvt( (M*x+B)/2,13 );\n"
sync = 2;\n"
INST_SEND(e1415,"alg:scal 'alg1','x',%f\n", (float32) i );
INST_SEND(e1415,"alg:scal 'alg1','sync',%f\n", 1 ); /* set sync */
INST_SEND(e1415,"alg:upd\n");
/* The following alg:scal? command will not complete if the
* update has not occured. Then, it's a matter of waiting for
Appendix G

Advertisement

Table of Contents
loading

This manual is also suitable for:

Vxi e1415a

Table of Contents