countExt

cyclic up counter with external count-up control
Author: Johannes Taelman edit by Remco van der Most
License: BSD
Github: sss/logic/countExt.axo

Inlets

int32.positive MaxCount

bool32.rising trigger

bool32.rising reset

Outlets

bool32.pulse carry pulse

int32 output

int32 max

Parameters

int32 max

Declaration
int ntrig;
int rtrig;
int32_t count;
Init
count = 0;
ntrig = 0;
rtrig = 0;
Control Rate
int max = inlet_MaxCount + param_max;
outlet_max = max;
if ((inlet_trig > 0) && !ntrig) {
  count += 1;
  if (count >= max) {
    count = 0;
  }
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;
if ((inlet_r > 0) && !rtrig) {
  count = max - 1;
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;
outlet_o = count;
outlet_c = (count == 0) && inlet_trig;

Privacy

© 2024 Zrna Research