206 Creating and Running Algorithms Chapter 6
SOUR:FUNC:COND (@141) make Digital I/O channel 141 a
digital output. The default
condition for 140 is digital input.
define algorithm
ALG:DEF 'alg1','
static float setpoints[ 1024 ], index, num_events, n;
if ( First_loop ) {
index = 0; /* array start point */
n = num_events;/* preset interval */
}
n = n - 1; /* count trigger events */
if ( n <= 0 ) {
O100 = setpoints[ index ]; /* output new value */
index = index + 1; /* increment index */
if ( index > 1023 ) { /* look for endpoint */
index = 0;
O140.B0 = !O140.B0; /* toggle update bit */
}
n = num_events; /* reset interval count */
}’
ALG:SCAL "alg1","num_events", 10 output change every 10 ms
ALG:ARRAY "alg1","setpoints",<block_data> set first profile
ALG:UPD force change
TRIG:TIMER .001 trigger event at 1 ms
TRIG:SOUR TIMER trigger source timer
INIT start algorithm
Download new setpoint profile and new timer interval:
ALG:SCAL "alg1","num_events", 20 output change every 20 ms
ALG:ARRAY "alg1","setpoints",<block data> set first profile
ALG:UPD:CHAN "I140.B0" change takes place with change
in bit 0 of O140.
This example program was configured using Digital Output and Digital Inputs for the express reason that multiple VT1422A's may be used in a system. In this case, the VT1422A toggling the digital bit would be the master for the other VT1422A's in the system. They all would be monitoring one of their digital input channels to signal a change in setpoint profiles.