FUNCTION_BLOCK SAW_GEN

An instance of this Function Block type generates a sawtooth waveform in the range {0..100} with a period of 100 CLK events. Its operation is modeled by the Execution Control Chart (ECC) and algorithms shown below.

See the WAVEFORMS system configuration for an example of the use of instances of this and other waveform generation FB types.

ECC
ALGORITHM STEP IN ST : (* Clock step *)
IF QI THEN
  IF OUT >=100 THEN OUT := 0;
  ELSE OUT := OUT + 1;
  END_IF;
END_IF;
END_ALGORITHM

ALGORITHM RESET IN ST : (* Reset output to zero *)
OUT := 0;
END_ALGORITHM