Skip to main content

Kollmorgen Support Network

Counter with Non Zero Start Number | 21 Aug 2020 | |

Counter with Non Zero Start Number

image

The MCFB_CTU_Start function block is similar to the CTU function block with the additional feature that the counter can be started with a non-zero value. The counter does not include a pulse detection for iCU input. Use R_TRIG or F_TRIG function block for counting pulses of CU input signal. Additionally, the counter allows for stating with a non-zero value that has been stored in retain memory through input iStartValue.

  1. iCU (BOOL) - Enable counting. Counter is increased on each call when iCU is TRUE
  2. iStartValue (DINT) - Count value saved in retain Memory
  3. iReset (BOOL) - Reset command. Counter is reset to 0 when called with RESET to TRUE
  4. iPV(DINT) - Programmed maximum value

Outputs:

  1. oMaxValueReached (BOOL) - TRUE when counter is full, i.e. when CV = PV
  2. oCV (DINT) - Current value of the counter

The attached example adds the MCFB_CTU_Start  kUDFB to a KAS project starting template and includes the program VariableStartValueCounter to run it.

image

The variable r_counterValue was added to the Retain Variables and shows how a variable can be setup to retain the present count when the counter stop excecuting, and upon restart takes on the latest value as a starting point  

image

About this Article

C Wontrop