The following is a description of both the hardware and software of the Raspberry Pi computer controlled fireworks launcher including construction and layout, electronic / electrical components, run time software parameters, launch operation and ignition method:
NOTE: CLICK ON A SUBJECT TITLE TO EXPAND IT (READ THE CONTENTS). CLICK AGAIN TO COLLAPSE IT, OR CLICK ON A NEW TITLE.
So, why a fireworks launcher? Well, it didn’t start out that way. I heard about this cheap, tiny single board computer that was soon going to be released called the Raspberry Pi, so I pre-ordered one and when I got it I started to play around with it on a breadboard with some LED’s and switches. My schooling is in Electrical Engineering Technology, which led me into a career building test sets, designing/building circuit boards, programming, and supporting UNIX/Linux servers and Windows workstations, so the fireworks launcher was a nice mix of all these things to keep my skills fresh while looking for a job. I have never worked with a device like the Raspberry Pi before, or one of the other somewhat similar devices (Arduino, Stamps, etc.), so this gave me the opportunity to also learn about GPIOs and other interfaces. Since I have worked almost exclusively with Red Hat Linux and its offshoots in the past (Centos, Scientific Linux), it also introduced me to strictly Debian, as opposed to the modified Debian distros like Mint and Ubuntu which I have installed on my desktop computers. Also, in the back of my mind, the fireworks launcher has always been something I wanted to build since I was a kid, but never had the time.
So, why the Raspberry Pi instead of one of the many other boards available? Well, $35 for a credit card sized computer first caught my eye; of course that cost is in the noise now, considering what I paid for all the other parts! Secondly was the great community that was available through the Raspberry Pi Foundation’s forum. Finally, pre-built libraries in various languages were available to do all the really hard work.
The fireworks launcher is a self contained, portable, battery powered, wifi controlled 8 port device. After quite a bit of testing, the device was completed just in time for the fourth of July, 2013, when it made it’s final debut. Now the original goal for this device was to be more than just a fireworks launcher, but rather a general multipurpose computer with I/O and wifi capabilities. That is why I ran the Pi’s connectors to the exterior of the chassis, added the option to run it off of AC, and gave it the capability to control AC devices.
The fireworks launcher first started out as a breadboard with some LEDs, jumper cables, switches, resistors, transistors, etc. After I got the basics up and running, I transferred everything to a solderable circuit board and chassis. Since I had to fabricate pretty much everything by hand from scratch, the first thing I did was to walk through the aisles of a couple of hardware stores (as in Home Depot and Lowes) to get some ideas on how I was going to build it. I also searched the Internet to get some ideas. Luckily I had all the power tools already (Drill, Sawzall, Circular Saw, Dremel, files, hand tools, etc.). I wanted to keep the chassis as small as possible, so the most time consuming process was to get everything to fit. So, before I bought a single part, I spent a lot of time picking the parts I wanted off of the Internet (Mostly from Digi-Key and Mouser) and gathered the physical dimensions of all the parts. I then made “paper doll” cutouts of every part, and rearranged them several times until I came out with the most compact and ergonomic layout. I then chose a chassis that would fit everything, with a little extra space, and then placed all the orders. Luckily I went for the extra space, because now it is gone! Everything is mounted on a piece of plywood, with countersunk holes drilled for all mounting bolts, so it will lay flat when place on a surface.
As shown in the pictures on this web site, I laid out and assembled the components into four distinct quadrants in the chassis (AC, DC, Relay Interface, and Raspberry Pi). Here are the reasons why:
1) AC Quadrant
The AC components and circuitry are located very close to each other and away from any low level DC components as not to create any EMF problems. The top left area was chosen because this is the normal location for a power cord. Rather than hard wire the AC power cord and use grommets, I chose to use an AC power entry inlet module so the power cord could be removed during battery operation. I would have liked to have swapped the location of the AC inlet module with the AC outlet module for cosmetic reasons, but it was just a matter of where they would fit, so be it. Since this is a sealed chassis, air flow was mandatory, and since the AC/DC power supply is the biggest heat generator, the exhaust fan was placed nearby. This also makes sure that the heat is removed immediately, and does not flow over other components. Naturally, the AC outlet relay and AC fuses were also added to this area.
2) Relay Interface Quadrant
The terminal strip to attach the cables from the launcher to the fireworks needed to placed on the rear of the chassis. There were two reasons for this. First, it just makes sense, since that is where you would want to connect the cables. Doh. However, a not so obvious reason is to make sure that the launch indicator LED’s were viewable while wiring up the fireworks. This offers an added safety feature if something were to go horribly wrong with the launcher electronics or software (luckily, that has not happened). A quick look at the indicator LED’s while hooking up the cable to the fireworks fuses will show whether a port is on or not. If all the LED’s are off, it is safe to connect to the fireworks. If you notice, the terminals are numbered/labeled in reverse. This way, after the wires are attached, and I am standing in front of the launcher getting ready to launch from my smartphone, the devices to be selected for a launch will be numbered from 1 on the left to 8 on the right, which makes it easier to tell what device I am launching. The 8 channel relay board was positioned close to the terminal strip to keep the wiring short and neat. The connectors of the relay interface circuit board were laid out so that the ribbon cables and power cables would line up with both the pi and the relay board.
3) Raspberry Pi Quadrant
Because of the location of the relay interface board, the Raspberry Pi needed to be positioned where the ribbon cable could be connected, also keeping in mind fitting in all the pi’s other cables. To attach the Pi to the chassis, I had a low quality case that I first bought, which broke, so I just clamped it down with a bracket. I left the top off for better cooling. I originally had a Model B Rev 1 board installed without mounting holes, but when I switched to a Model B Rev 2 board I wasn’t about to trust mounting it with just some standoffs, especially with all of the added stress of the cables, so I didn’t change anything. I originally just made a large cutout to feed all the raspberry pi cables out from the chassis, but it didn’t look very professional, so I found the Keystone jacks online and thought, hey, a little extra work but that would work out perfectly. I only wish the jacks and plate came in black; well actually they do, but the price would have been quadrupled. I then ordered the shortest cables I could find to connect everything. The router power jack was also added here because that way both the router power cable and Ethernet cable would feed from the same chassis side. The extra hole you see on the top right was not a mistake…..really! That was a design change. I originally put the wifi dongle inside the chassis and ran a cable to a connector on the chassis, where I screwed in the antenna. But after switching to the Keystone jacks it was no longer needed. There is an air intake with a removable and cleanable foam filter on the front of the chassis, directly in front of the pi, to suck in cool air that is pulled in by the fan on the rear of the chassis.
4) DC Quadrant
That of course leaves the DC quadrant. The switches needed to be on the front of the chassis for easy access. Each switch has an accompanying LED indicator. The metal bar you see across the switches is to prevent accidental tripping of the switches if bumping into them; turning on the relay power or turning off the pi at the wrong time would obviously be a bad thing. The 12V and 5V fuse holders were also placed in this area, as well as the 12V DC to 5V DC USB cigarette lighter car charger. I used a marine grade cigarette lighter socket mounting bracket because it came with mounting holes. To mount the batteries I made a wooden bracket and used some threaded rod and a battery clamp to hold them in place. They are placed on a rubber mat to protect them from any major shock or vibrations. As can be seen, the external tall wifi antenna was an afterthought, as it doesn’t quite fit on the plywood base. The launcher works just fine with the Linksys’s standard antennas, but the external antenna gives more range due to its height and dB gain. The antenna mounting contraption was built using various pieces of PVC pipe that I glued together. I call it my little toilet tower. That one took a couple of trips down the hardware store’s PVC bin aisle to figure out how I was going to do it. The location to mount the antenna was two-fold. First, it was the only micron of open space left. Two, it needed to be kept as far away as possible from the wifi dongle on the other side of the chassis to minimize interference.
1) AC/DC Operation
The Raspberry Pi and associated circuitry are capable of getting their power from the AC-DC 12V switching power supply or from one of the two 12V batteries, selectable from the front panel switch labeled “PI POWER”. The LED next to the switch is bidirectional (GREEN for battery power and RED for A/C power). The 12V is used to power the router and fan, but for the pi and the rest of the circuitry it is converted to 5V using the Dual output USB car charger. The 1 Amp output of the car charger powers the pi, while the 2.1 Amp output is used to power the relay board coils. The relay board outputs are only capable of running off of DC (Battery only) due to the high current needed to ignite the nichrome wire, especially when all 8 ports are activated simultaneously. As a safety precaution, the relay output power can be turned on/off from the front panel with the switch labeled “RELAY POWER”; the relay power switch is toggled to the on position after the pi boots up and all the GPIO ports have been initialized. When used as a launcher, 99% of the time everything will be run off of batteries due to the fact that it will be in a field somewhere, far away from any AC sources. Why are there two batteries. Simple……..I got them for free, so I used them both. The way they are hooked up is that one battery supplies power to the Pi and circuitry (after conversion to 5V), while the other one is used to ignite the fireworks at the full 12V level. This works out well because the relay power battery will drain a lot faster than the pi battery, and by the time the relay battery is depleted, there is still plenty of run-time for the pi and it will not crash due to too low a voltage. Two batteries also gives me the option to run them in parallel and get a super long pi run time if I so desire. The batteries are also a reasonable size (I can’t imagine carrying around this thing with a car battery), they are deep cycle batteries so they are perfect for the high amperage pull necessary to launch the fireworks, and they have a decent 12AH rating each. I don’t have a charging circuit for the batteries. I just charge them up before use with my two motorcycle battery chargers.
So why an AC option? Two reasons. First, when when using the fireworks launcher for other projects, or to change code, or whenever I don’t need to run on batteries, it is handy to run off of AC so I don’t have to deal with charging batteries. Secondly, it gave me the opportunity to add circuitry in order to have the capability to control AC appliances and devices from the GPIO. This was accomplished with an opto IC, Darlington pair IC, a relay and an AC outlet. Even though the relay board is supposedly rated for A/C operation (which I doubt), there is no way I am going to use a non electrical body certified device with AC voltages and current. Therefore I purchased separate components, and all parts and wiring of this part of the circuit are UL certified for 120 VAC operation at 15 Amps. As an additional safety margin, the fuse on the output is rated for only 10 Amps.
2) 8 Channel Relay Board and Relay Interface Board
The relay board is an off the self Sainsmart relay board. Unfortunately it is active LOW, which is not desirable safety-wise for a fireworks launcher, and not to mention just a plain stupid a** design. The other issue is that the Pi’s Broadcom GPIOs are 3.3V based, and sinking 5V (or whatever it really is due to the voltage drops) through a 3.3V device is just not a good idea. This was easily fixed by putting transistors between the GPIO outputs and the relay board, and this is one of the purposes of my relay interface board. Now a HIGH signal activates the relays. To further protect from false triggers, a resistor is placed from each GPIO output to ground because the GPIOs are INPUTS set to a LOW condition, but are in a floating state at boot. The resistor guarantees a LOW state at boot. Also, although it could change at any time in firmware updates, I have chosen GPIO ports that are consistent and in the same state at boot (INPUTS and LOW state), staying away from ports that are OUTPUTS or HIGH at boot. The relay interface board serves other functions as well. It has the circuitry for controlling the AC output relay, it serves as the way to connect the Pi to the relay card via the header connectors, it is the central point for connecting the various voltages (3.3V and 5V from the pi, and 5V from the USB car charger) to the various components in the chassis like the reset switch and indicator LED. Actually it is not a reset switch; the word “shutdown” was too long a label word to fit in the space on the front panel. It is actually a shutdown switch.
3) Circuit protection
The following items are separately fuse protected. Each battery supply, the switching power supply, the A/C outlet, the fan, the 12V side of the USB car charger, each of the 8 relay outputs, and every power rail on the relay interface board (3.3 and 5V lines from the pi, and the 5V relay coil power line from the USB car charger).
Now the launcher may look a little strange with all the antennas, so let me explain. In reality, and the way I usually use it is to use the Linksys router with the two antennas that come with it and nothing else. I chose the Linksys router because a) I had one b) it runs off of 12V and uses very little current and c) it runs second party firmware very well (I am currently running Shibby Tomato, which has a ton of useful features). I looked at newer routers, and it would have been nice having the 5 GHz range and higher power/speed, but all these newer routers require higher voltages than 12V and suck up a massive amount of current. The router is connected to the pi directly via an Ethernet cable, so there is no need for any other wifi devices. I just make an SSH connection from my smartphone to the pi using wifi. It connects through the router, through the Ethernet cable and finally to the pi. The router is set up to assign static ip addresses via DHCP to the pis Ethernet port, the pi’s wifi dongle, the wifi dongle on a second raspberry pi, and my smartphone. This gets rid of the hassle of determining what ip address that DHCP has issued to all of these devices; I put labels on all the devices with their mac and ip address. I can launch from my smartphone from a tested distance of 400 to 450 feet before the signal degrades too much and the connection becomes unstable. So what is with that tall antenna and the extra wifi dongle? The tall antenna to the left of the launcher gives me extended range through its height and gain. I fabricated three pieces of PVC pipe for three different final antenna heights (32”, 44” and 60”). In this mode of operation, the router’s left channel is disabled and it runs from the right channel only. The wifi dongle that you see in the picture is so I can simultaneously transmit/receive via the usb port, while still being connected through the router. This allows me for example to run wavemon to get a list of available access points in the area, while still being connected through the router and viewing the results. Both the router and dongle have removable antennas, making them flexible with regard to cable length or antenna types.
1) Launcher Software
I chose “C” as the programming language because I have used it the most in the past and because of its intimate relation with UNIX and Linux operating systems, especially with regards to the low level stuff.
All this would not be possible without Mike McCauley’s fantastic “C” library for the Broadcom BCM 2835, so a big kudos to him. It made interfacing with the GPIO pins a breeze. No low level coding at all was necessary. Heck, almost all of the time-consuming part of writing my code was the user input validation and error checking to insure there were no false launches, while the rest was happily taken care of by the library.
The launch software has no fancy interface, just plain old terminal based text. It does the job. There is various error checking to prevent entering invalid characters or numbers, out of range values, duplicate values, an improper quantity of values or improperly formatted entries. In the event of an improperly aborted program, CTRL-C for example, the signal handler insures that it is caught and upon exit the ports are set to a LOW state and the library is properly closed. All GPIO ports are set to OUTPUTS and a LOW condition upon both entry and exit of the program.
The sequence of the launch operation is as follows (See the “Launcher Videos” tab of this web page for videos of the launch sequence):
a) Enter the Launch Method (DEFAULT IS CONSECUTIVE):
There are two types of launches, either “Consecutive” or “Simultaneous”. As you might imagine, in a consecutive launch each firework is ignited one at a time, one after the other, in the order that they are given. In a simultaneous launch all fireworks are ignited at the same time.
b) Enter the Launch Sequence (DEFAULT IS LAUNCH PAD #1):
This is where you enter the firework port numbers to be ignited. Valid port numbers are 1 through 8. Any number of port numbers can be entered, in any order, and they will be fired in the order that they are entered.
c) Enter the Ignition Duration (DEFAULT =5. THAT EQUATES TO 5/10ths OF A SECOND, SO FINAL TIME IS 0.5 SECONDS):
This is how long power is applied to the output port. The reason it is entered as tenths of a second is because I discovered during the testing phase that it only takes a fraction of a second to ignite the fuse (about .1 to .3 seconds), and since this variable is an integer, it will not accept decimal points. For example, if I enter a value of 20, that equals 20/10, which is 2 seconds. Anyway, 5 (½ second) was selected as the default because it leaves more than enough of a buffer to properly ignite any fuse. I may change this item from an integer to a floating point, but it just isn’t worth the time as I rarely change its value other than when experimenting
d) Enter the Launch Delay Between Launches (DEFAULT = 0 SECONDS). NOTE: THIS PARAMETER IS ONLY APPLICABLE TO CONSECUTIVE LAUNCHES:
This is the time to wait before igniting the next device, after the Ignition Duration is complete. This is useful for an automated delay launch sequence, for example launch a device every 5 minutes without intervention. I may add a randomizer, so you have no clue when the next launch will happen; a bit dangerous, but it certainly would be humorous to see the look on people’s faces. As you might expect, this step does not apply to the simultaneous launch method, and for that reason this step is not shown on the screen in that case.
e) Press the “ENTER KEY” to launch. Press “q” then “ENTER KEY” to abort:
I think that speaks for itself. This is the last chance to quit before you shoot a rocket into someones face, who for reasons that can only be explained by the consumption of mass quantities of alcohol, is staring down one of the launch tubes.
2) Custom Scripts
As far as custom scripts are concerned, there are two. Intermittently my wifi dongle does not get an ip address at boot. Since it is a headless device, the only option would be to re-seat the dongle. Not fun if you are 400 feet away, and hot swapping of the dongle with the pi is not recommended (even though it does work). So I modified and added a script that was originally written by Kevin Reed, that pings my router every minute, and if there is no reply, then it resets the interface. This completely eliminated the problem; hopefully eventually I will find the real problem. The second script is for the shutdown button (although labeled “Pi Reset” as I explained above). I poll whether the button is pressed every 15 seconds, and if it is, I issue a safe shutdown. Basically I hold down the button until the LED next to the shutdown button turns off, and then I can release the button because I know that the shutdown is complete. At that point I know it is safe to turn off the “PI POWER” switch and kill all power to the pi.
3) Raspberry Pi Operating System
I am running a Raspberry Pi Model B Rev 2 board and Rasbian Wheezy version 2013-02-09 with the all current updates.
4) Other Installed Software
Other software I have added related to the fireworks launcher includes tightvnc, which I use when connecting to the launcher from my other pi and a large monitor. I also installed some network tools including putty, nmap, zenmap and wavemon.
The fireworks are ignited using nichrome wire. After much testing, I have determined the perfect combination to insure proper ignition of all types and diameters of fuses (proper nichrome gauge, nichrome length, ignition time, etc.). I have found that the most reliable method is to heat the wire until melting (about 2600 degrees) which will reliably burn through and ignite any type of fuse that I can throw at it, even good quality American made thick waterproof Visco fuse. Launching from each port requires 2 Amps, for a total simultaneously 8 port launch current of 16 Amps; wiring, connectors and fuses are DC voltage/current rated accordingly to handle this much current. There are 8 ten foot cable pairs that extend out to the devices to be launched. This keeps the launcher away from any sparks that may be flying around. As I previously mentioned, the cables are attached to the chassis via a terminal strip. It is a 16 connector terminal strip with screw terminals. At the other end of each cable are special alligator clips that can reliably grab the small gauge nichrome wire. Thanks to Silvertronic, who were nice enough to send me a bunch of sample alligator clips to test.
If you are looking for a cheap, reliable web hosting company to host your own project I would highly recommend Stablehost, the folks that I use to host this website. After a bit of research I settled on them, mostly from the many good reviews and recommendations from www.webhostingtalk.com, which seems to be the premier web hosting forum site. Stablehost’s technical support and customer service personnel are not only competent, but have responded quickly to all my requests. With one of the coupons they offered on the Internet, I am only paying $2 a month, which I feel is reasonable for a personal website. I had originally started with one of the very popular free hosting companies (If not the most popular), but that had turned out to be a nightmare to say the least (No response to my support questions, servers down or extremely slow most of the time, application software not working, etc.). Click the button below for the Stablehost web site:
For now I am going to take a short break and work on something new. However, expanding the 8 ports to 16 or 24 comes to mind. But I wouldn’t build a whole new unit, maybe put on a second floor. A graphical interface would be a nice addition and something new to learn. Since it was recently announced that there will be no major upgrades for the pi for the next 3 years, I might replace the pi with one of the many other boards that are becoming available from other manufacturers. There are all some really nice products out there with more modern faster processors, more memory, more input/output ports, different OS compatibility, etc.
That is all…..carpal tunnel is setting in.