ADVANCED: UPDATEIO

Top  Previous  Next

UPDATEIO will force an update of all in- and outputs on the RTCU platform. Normally UPDATEIO is not needed as the BEGIN/END construction will handle the updating of the in- and outputs. But in some cases, it can be necessary to utilise the UPDATEIO manually in a program. For example in a REPEAT statement, it could be necessary to update all in- and outputs in each iteration.

UPDATEIO will update first the inputs, then the outputs, in that order.

 

 

Example:

INCLUDE rtcu.inc
 
VAR_OUTPUT
  output : ARRAY[1..16] OF BOOL;| Our 16 digital outputs
END_VAR;
 
VAR
  a     : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
  a := 1;
 
  REPEAT
    output[a] := TRUE; // Set the output TRUE
    UPDATEIO; // Update all in- and outputs
    Sleep(delay := 100); // Wait 100 milliseconds
 
    output[a] := FALSE; // Set the output FALSE
    UPDATEIO; // Update all in- and outputs
    Sleep(delay := 100); // Wait 100 milliseconds
 
    a := a + 1; // Next output
 UNTIL a > 16
  END_REPEAT;
END;
 
END_PROGRAM;

 

This example will make a "running" light on the 16 outputs. Output 1 will be on for 100 ms, then output 2 will be on for 100 ms, and so on.