alternate

on a pulse at inlet 'trig' , a pulse is sent alternating at 'o1' or 'o2'. 'rst' will reset the logic, so on the next pulse at 'trig',a pulse is sent at 'o1'.
Author: robert schirmer
License: BSD
Github: rbrt/control/alternate.axo

Inlets

bool32.rising trigger

bool32.rising rst

Outlets

bool32.pulse o1

bool32.pulse o2

Declaration
int ntrig;
int p_set;
int p_reset;
int op;

int rst;
Init
p_set = 0;
p_reset = 0;
op = 0;
Control Rate
outlet_o1 = 0;
outlet_o2 = 0;

if ((inlet_trig && !ntrig) && !op) {
  ntrig = 1;
  outlet_o1 = 1 << 27;
  op = 1;
}

if ((inlet_trig && !ntrig) && op) {
  ntrig = 1;
  outlet_o2 = 1 << 27;
  op = 0;
}

if (!inlet_trig)
  ntrig = 0;

if (inlet_rst && !rst) {
  op = 0;
  rst = 1;
}
if (!inlet_rst)
  rst = 0;

Privacy

© 2024 Zrna Research