Examples - Simple application - 2

Top  Previous  Next

//-----------------------------------------------------------------------------
// test2.vpl, created 2000-08-01 20:10
//
//-----------------------------------------------------------------------------
INCLUDE rtcu.inc
 
// This program:
//   negates o1 on each leading edge detected on input i1
//   negates o2 on each falling edge detected on input i1.
//
 
// Next follows all the variables that can be configured via the configuration dialog
VAR_INPUT
  i1 : BOOL; | Input
END_VAR;
 
VAR_OUTPUT
  o1 : BOOL; | Output1 (Negated on leading edge)
  o2 : BOOL; | Output2 (Negated on falling edge)
END_VAR;
 
// Here follows the programs global variables
VAR
  edge : RF_TRIG;
END_VAR;
 
PROGRAM test;
 
// The next code will only be executed once after the program starts
BEGIN
  // Code from this point until END will be executed repeatedly
  edge(trig := i1);
  IF edge.rq THEN
     o1 := NOT o1;
  ELSIF edge.fq THEN
     o2 := NOT o2;
  END_IF;
END;
 
END_PROGRAM;