VXi VT1422A 사용자 설명서

다운로드
페이지 529
200 Creating and Running Algorithms  
A Very Simple First Algorithm
This section shows how to create and download an algorithm that simply 
sends the value of an input channel to a CVT element. It includes an example 
application program that configures the VT1422A, downloads (defines) the 
algorithm, starts, and then communicates with the running algorithm. 
Writing the
Algorithm
The most convenient method of creating an algorithm is to use the 
hps1422.exe soft front panel program. Use the Algorithms Panel to create, 
edit and save the algorithm to a file called "mxplusb.c." The following 
algorithm source code is on the examples disc in a file called "mxplusb.c."
/* Example algorithm that calculates 4 Mx+B values upon
 * signal that sync == 1. M and B terms set by application
 * program.
 */
 static float M, B, x, sync;
 if ( First_loop ) sync = 0;
 if ( sync == 1 ) {
writecvt(  M*x+B,   10 );
writecvt(-(M*x+B),  11 );
writecvt( (M*x+B)/2,12 );
writecvt( 2*(M*x+B),13 );
sync = 2;
 }
Running the
Algorithm
A C-SCPI example program "file_alg.cpp" shows how to retrieve the 
algorithm source file "mxplusb.c" and use it to define and execute an 
algorithm. When "file_alg.cpp" is compiled, type 
file_alg mxplusb.c
 
to run the example and load the algorithm. View the readme.txt file provided 
with the VXIplug&play driver for example program file location.
Modifying an Example PID Algorithm
While the example PID algorithms supplied as source files with the 
VT1422A can provide excellent general closed loop process control, there 
will be times when the process has specialized requirements that are not 
addressed by the as-written form of these PID algorithms. In this section, 
coping and modifying an example PID algorithm is described.
PIDA with Digital
On-Off Control
The example PID algorithms are written to supply control outputs through 
analog output SCPs. While it would not be an error to specify a digital 
channel as the PID control output, the PID algorithm as written would not 
operate the digital channel as desired.
The value written to a digital output bit is evaluated as if it were a boolean 
value. That is, if the value represents a boolean true, the digital output is set 
to a binary 1. If the value represents a boolean false, the digital output is set 
to a binary 0. The VT1422A's Algorithm Language (like 'C') specifies that a 
value of 0 is a boolean false (0), any other value is considered true (1). With 
that in mind, the operation of an example PIDA will be analyzed with a 
digital output as its control output.