Here is a approach using two alternately triggered software timers to generate the interleaved pulses. I am simulating the zero cross interrupt with a timer interrupt output on pin 3. Jumper pin 3 to pin 2 which is the external interrupt pin.
I've scaled everything down by a factor of 10 to see reasonable serial output of the interleaved timing. The serial output looks reasonable but this wasn't tested with a scope.
EDIT 11:00 revise location of counter reset to fixa bug where case 7 not being actually entered
change startTimer variables to unsigned long
//https://github.com/PaulStoffregen/TimerOne/blob/master/TimerOne.h
#include <TimerOne.h> //to generate external interrupt model zero cross
const unsigned long interval = 5000;//pulse length high microseconds and initial delay from trigger
const unsigned long scaleFactor = 10;//slowing factor, replace with 1 for full speed
const unsigned long period = interval*scaleFactor;
byte timerACount = 0;
byte timerBCount = 0;
volatile boolean runTimerA = false;
volatile unsigned long startTimerA;
volatile boolean runTimerB = false;
volatile unsigned long startTimerB;
volatile boolean intTrigger = false;
byte pinStart = 4;//start number output pins for 6 pulses
void setup()
{
//set pins 4,5,6,7,8,9 as output for 5ms pulses
for (byte i = 0; i <= 5; i++)
{
pinMode(pinStart + i, OUTPUT);
}
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), pulseTrainTrigger, FALLING);
pinMode(3, OUTPUT);//timer trigger
Serial.begin(115200);
Timer1.initialize(20000*scaleFactor);//every 200 ms scale factor 10
Timer1.attachInterrupt(trigger);
Serial.println(micros()/1000);
}
void loop()
{
if (runTimerA ==true && (micros() - startTimerA >= period))
{
//enters 5ms after initial trigger
//enters at 0 and increments counts to 1,2,3,4,5,6,7
startTimerA += period;
timerACount++;
Serial.print('\t');
Serial.print("A");
Serial.print(timerACount);
Serial.print(" ");
Serial.println(micros()/1000);
// if (timerACount == 7)
//{
// timerACount = 0;
// runTimerA = false;
//}
}
switch (timerACount)
{
case 1://5ms after trigger turn on first output
digitalWrite(pinStart, HIGH);
break;
case 2://10ms after trigger
digitalWrite(pinStart + 1, HIGH);
digitalWrite(pinStart, LOW);
break;
case 3://15ms after trigger
digitalWrite(pinStart + 2, HIGH);
digitalWrite(pinStart + 1, LOW);
break;
case 4://20 ms after trigger
digitalWrite(pinStart + 3, HIGH);
digitalWrite(pinStart + 2, LOW);
break;
case 5://25ms after trigger
digitalWrite(pinStart + 4, HIGH);
digitalWrite(pinStart + 3, LOW);
break;
case 6://30ms after trigger
digitalWrite(pinStart + 5, HIGH);
digitalWrite(pinStart + 4, LOW);
break;
case 7://35 ms after trigger turn off last output
digitalWrite(pinStart + 5 , LOW);
timerACount = 0;
runTimerA = false;
break;
}
if (runTimerB == true && (micros() - startTimerB >= period))
{
//enters at 0/increments counts to 1,2,3,4,5,6,7
startTimerB += period;
timerBCount++;
Serial.print('\t');
Serial.print('\t');
Serial.print("B");
Serial.print(timerBCount);
Serial.print(" ");
Serial.println(micros()/1000);
// if (timerBCount == 7)
// {
// timerBCount = 0;
// runTimerB = false;
// }
}
switch (timerBCount)
{
case 1://5ms after trigger
digitalWrite(pinStart, HIGH);
break;
case 2://10ms after trigger
digitalWrite(pinStart + 1, HIGH);
digitalWrite(pinStart, LOW);
break;
case 3://15ms after trigger
digitalWrite(pinStart + 2, HIGH);
digitalWrite(pinStart + 1, LOW);
break;
case 4://20 ms after trigger
digitalWrite(pinStart + 3, HIGH);
digitalWrite(pinStart + 2, LOW);
break;
case 5://25ms after trigger
digitalWrite(pinStart + 4, HIGH);
digitalWrite(pinStart + 3, LOW);
break;
case 6://30ms after trigger
digitalWrite(pinStart + 5, HIGH);
digitalWrite(pinStart + 4, LOW);
break;
case 7://35 ms after trigger
digitalWrite(pinStart + 5 , LOW);
timerBCount = 0;
runTimerB = false;
break;
}
if (intTrigger)
{
intTrigger = false;
Serial.println(millis());
}
}
//alternate timers with external interrupt trigger
void pulseTrainTrigger()
{
static byte triggerCount = 0;
if (triggerCount == 0)
{
startTimerA = micros();
runTimerA = true;
}
if (triggerCount == 1)
{
startTimerB = micros();
runTimerB = true;
}
triggerCount++;
if (triggerCount == 2)
{
triggerCount = 0;
}
}
//test trigger
//generate trigger pulse on pin 3 with Timer1 jumper pin 3 to pin 2
void trigger()
{
intTrigger = true;
digitalWrite(3, HIGH);
digitalWrite(3, LOW);
}