Hey all, I'm back again! "So soon?" you ask. Well, let me assure you that I'm cranking along on a very fun project, but I have so many questions left unanswered. P.S. - thanks again to AWOL and davekw7x for the help on the PROGMEM conundrum ![]()
So here is the setup:
Assume I have a 60Hz square wave coming into any of the digital pins, 0-5v. Can anyone think of a way to make a function wait for the rise and then delay a preset amount and then commit a permanent loop of delayed output signals, used as triggers, to some very nifty SCR units that are time synced to that input?
My 2 theories:
1- Tell one of the timers in charge of the PWM on a given digital pin that it should follow that external signal instead of the internal timer, then set it to both the appropriate duty cycle, and make it invert the ON/OFF to OFF/ON for output. I'm sure thats not the hardest thing to do, but I don't even know where to begin.
2- Work out which pins are on which timers. I believe there are three timers, hence there being 6 PWM pins on my UNO. Figure out which timer both millis() and delay() function on, so as not to disturb them. Then program the other timers to run at 60Hz and use an external interrupt from my clock signal to set the PWM on my output pins starting at the next change of state, which should sync them.
Side question - is there any way to pulse the PWM output so that in a cycle it would run:
OFF(for some duration)/ON(for some other duration)/Off(for a third duration)
As it stands now, the PWM on my OUTPUT pins are hard coded to a time delay calculated in the program and then run continuously.
//this program defines the firing sequence for the TCR branch of a 3 phase SVC
//the delays are hard programmed to operate with a 50% duty ratio over the
//period of approx ~ .01667sec
void FiringSequence(unsigned long delayTime){
 delayMicroseconds(delayTime);
 do{
  digitalWrite(10, HIGH);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(10, LOW);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(9, HIGH);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(9, LOW);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(6, HIGH);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(6, LOW);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(10, HIGH);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(10, LOW);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(9, HIGH);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(9, LOW);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(6, HIGH);
  delayMicroseconds(1389);
  //delay(1000);
  digitalWrite(6, LOW);
  delayMicroseconds(1389);
  //delay(1000);
  //Serial.println("cycle complete");
 }