Questo blocco funzione esegue la gestione di un counter in incremento. Agendo sull’ingresso di reset R è possibile in qualsiasi momento azzerare il valore del counter CV.
Ad ogni fronte di attivazione dell’ingresso CU, il valore del counter CV viene incrementato. Quando il valore del counter raggiunge il valore di preset, definito su PV, l’uscita Q viene settata ed il conteggio si arresta.
Solo agendo sull’ingresso di reset si potrà resettare il counter e fare ripartire un nuovo conteggio. L’ingresso di reset è prioritario sull’ingresso di incremento.
Descrizione
CU (BOOL) Comando incremento counter, ad ogni fronte attivazione il valore del counter CV si incrementa.
R (BOOL) Comando di reset, attivando l’ingresso il valore del counter CV si resetta.
PV (INT) Valore di preset, quando il valore del counter CV raggiunge questo valore l’uscita Q si attiva ed il counter non si incrementa più.
Q (BOOL) Uscita counter, attiva se il valore del counter CV raggiunge il valore definito in preset PV.
CV (INT) Valore counter, valore di conteggio counter, quando raggiunge il valore di preset PV, l’uscita Q si attiva ed il counter non si incrementa più.

Esempi
Come utilizzare gli esempi.
Nell’esempio viene gestito un counter in incremento, attivando Reset il counter viene resettato a 0. Ad ogni fronte di attivazione di Clock il valore del counter si incrementa, quando il valore diventa 10 si attiva COutput.
LogicLab (Ptp115, IL_CTU)
PROGRAM IL_CTU
VAR
Clock : BOOL; (* Clock command *)
Reset: BOOL; (* Reset command *)
CValue : INT; (* Counter value *)
COutput : BOOL; (* Counter output *)
Counter : CTU; (* Counter *)
END_VAR
(* ************************************************************************** *)
(* PROGRAM "IL_CTU" *)
(* ************************************************************************** *)
(* This program shows the use of CTU function block. *)
(* ------------------------------------------------------------------------- *)
(* ---------------------------------------------------------------------- *)
(* COUNTER *)
(* ---------------------------------------------------------------------- *)
LD Clock (* Clock command *)
ST Counter.CU
LD Reset (* Reset command *)
ST Counter.R
LD 10
ST Counter.PV
CAL Counter (* Call the function block *)
LD Counter.Q
ST COutput (* Counter output *)
LD Counter.CV
ST CValue (* Counter value *)
(* [End of file] *)
LogicLab (Ptp115, ST_CTU)
PROGRAM ST_CTU
VAR
Clock : BOOL; (* Clock command *)
Reset: BOOL; (* Reset command *)
CValue : INT; (* Counter value *)
COutput : BOOL; (* Counter output *)
Counter : CTU; (* Counter *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_CTU"
// *****************************************************************************
// This program shows the use of CTU function block.
// -----------------------------------------------------------------------------
// -------------------------------------------------------------------------
// COUNTER
// -------------------------------------------------------------------------
Counter(CU:=Clock,R:=Reset, PV:=10); //Call the function block
COutput:=Counter.Q; //Counter output
CValue:=Counter.CV; //Counter value
// [End of file]