Mega Fireworks Sequencer Idea/Please Help

Sorry , I am really dense today. The MOSFET boards are serially controlled? Or each one has a separate MEGA controlling it?

each mosfet board is serial controlled, which theoretically allows as many mosfet boards as there are available digital pins

OK. Thanks. Is there a library that you are using?

For the wireless module, I'll use manicbugs rf24 library, but not for the mosfet boards. I inquired when ordering and this was the response:

"Library - I don't believe so. I only do 4 SPI.transfer()s to send data after it's determined elsewhere that an update is needed.
Ex:
code elsewhere updates byteArray[2] for example based on Serial data, blink without delay elapsed time, button press, etc.
code sets flag: updateNeeded = 1;
code does whatever else; could be updating another byte of byteArray[] - set the flag if something was changed.

Eventually, the sketch gets to this part:
if (updateNeeded == 1){
updateNeeded = 0; // clear flag
digitalWrite (ssPin, LOW);
SPI.transfer (byteArray[0]);
SPI.transfer (byteArray[0]);
SPI.transfer (byteArray[0]);
SPI.transfer (byteArray[0]);
digitalWrite (ssPin, HIGH); // outputs updated on this rising edge

so it sort of looks and acts like a function, but isn't one."

So it is something like a shift register?
Before you connect fireworks, make sure you know exactly how the board is controlled.

Just another idea of a module test feature: when you add a LED, diode and resistor (to Vcc) to each FET, as a dummy load, you can verify that the FETs are all intact and work properly, and also check the programmed sequence. Or for programmatical tests add a second shift register, that reports the output pin states to MISO.

The power to the igniters should be OFF for testing, of course :wink:

Isaac96:
So it is something like a shift register?
Before you connect fireworks, make sure you know exactly how the board is controlled.

Thats right. The mosfet boards are controlled by shift registers

DrDiettrich:
Just another idea of a module test feature: when you add a LED, diode and resistor (to Vcc) to each FET, as a dummy load, you can verify that the FETs are all intact and work properly, and also check the programmed sequence. Or for programmatical tests add a second shift register, that reports the output pin states to MISO.

The power to the igniters should be OFF for testing, of course :wink:

for testing purposes, I'll be using led's. I feel that more closely represents the actual use case

tonight, my thoughts paused on this thread.
hope all went great!

You'll be happy to know it went beautifully. It was quite possibly the most nerve wracking thing I've ever done. (especially when the neighbors started shooting off their fireworks while we were still wiring ours up and some ash fell down and hit me in the head). But everything worked, and no one got hurt. It was a great show and I'm never doing it again.

Great !

as for that last statement...
I go back t the last part of the last sentance in your first post.

next year, set up a web cam!

dave-in-nj:
next year, set up a web cam!

I got it on video. I just need to figure out a place to host it, since youtube will flag it for the music in it.

For anyone interested here is my code. (I'm sure there are more elegant ways of going about it, but it worked for me)

// Fireworks Sequencer code by Savan12986.
// Provided for informational purposes only.
// If you use or modify any of this code please provide attribution.
// No warranties or guarantees expressed or implied.
// I accept no responsibility for any harm be it physical or 
// otherwise resulting from use of this original or modified code.
// Use at your own risk.


int switchPower = 6;      // Power to Switch
int start = 7;            // Switch input to board
int latchPin = 8;         // Orange
int clockPin = 9;         // Yellow
int outputEnable = 10;    // Green
int dataPin = 11;         // Blue
int power = 12;           // Red
int startLED = 53;        // Orange to led
const int totalCues = 38;   //enter total number of cues
int registers = 8;          //enter total number of registers
long cue[totalCues] = {15,45,45,45,60,30,46,15,15,45,120,30,50,10,15,75,30,45,15,75,30,60,45,60,10,50,110,115,15,50,100,30,15,135,30,25,5,5};  //cue delays in seconds
int fuseDelay = 1000;     // fire each fuse for 1 second

 
void setup() 
{

  Serial.begin(57600);       // set up Serial library at 57600 bps
  Serial.flush(); 
  for(int i = 0; i < totalCues; i++)
  {
    cue[i] = (cue[i]*1000)-fuseDelay; //convert all cues from seconds to ms and compensate for fuse delay
    Serial.print("Cue: ");
    Serial.print(i+1);
    Serial.print(" delay: ");
    Serial.println(cue[i]);
  }
  pinMode(outputEnable, OUTPUT);
  digitalWrite(outputEnable, HIGH); //disable shift register output for safety
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  pinMode(start, INPUT);
  pinMode(power, OUTPUT);
  pinMode(switchPower,OUTPUT);
  pinMode(startLED, OUTPUT);
  digitalWrite(switchPower, HIGH);           
  clearRegisters();
}
 
void loop() 
{
  digitalWrite(outputEnable,HIGH); //disable output
  
  digitalRead(start);
  
  if(digitalRead(start)==HIGH)    //if start switch flipped
  {
    Serial.println("Starting");
    Serial.println("Waiting 1 1/2 mintues");
    delay(90000);                    //wait 1 1/2 minute before firing
    digitalWrite(startLED, HIGH);    // Sequence has started LED
    Serial.println("Starting sequence");
    digitalWrite(power, HIGH);       //enable 5v to the shift registers
    clearRegisters();
    
    delay(cue[0]);                                      
    primeShiftRegister();            //prime first cue
    Serial.println("Firing cue: 1");
    digitalWrite(outputEnable,LOW);  //output first cue
    delay(fuseDelay);                //wait for fuse to ignite
    digitalWrite(outputEnable,HIGH); //disable output
    Serial.print("Wainting: ");
    Serial.print(cue[1]/1000);
    Serial.println(" seconds to next cue.");
  
    for (int i = 1; i < totalCues; i++)  //cycles through all cues
    {
      delay(cue[i]);
      digitalWrite(outputEnable,LOW);
      shift();
      Serial.print("Firing cue: ");
      Serial.println(i+1);
      delay(fuseDelay);
      digitalWrite(outputEnable,HIGH);
      Serial.print("Wainting: ");
      Serial.print(cue[i+1]/1000);
      Serial.println(" seconds to next cue.");
    }
    Serial.println(" ");
    Serial.println("DONE!!");
    Serial.println(" ");
    clearRegisters();
    digitalWrite(startLED, LOW);    // turn off sequence start LED
  }
}
 
void primeShiftRegister()  // primes the first register output with a 1
{
  digitalWrite(dataPin, HIGH); 
  digitalWrite(latchPin, LOW);
  digitalWrite(clockPin, HIGH);
  digitalWrite(clockPin, LOW);
  digitalWrite(latchPin, HIGH);
}

void shift() // shifts the high output pin foreward 1 by manually writing in a 0 and cycling the clock
{
  digitalWrite(dataPin, LOW); 
  digitalWrite(latchPin, LOW);
  digitalWrite(clockPin, HIGH);
  digitalWrite(clockPin, LOW);
  digitalWrite(latchPin, HIGH);
}

void clearRegisters()
{
   for (int i = 0; i < registers; i++)  //clear the registers with 0's
   {
     shiftOut(dataPin, clockPin, MSBFIRST, 0);
   }
}

You could put the video in a zip file. Or use Google Docs.