I was reminded recently that when writing code in C, you have to take care to understand how variable are going to be used when declaring them. I was had just finished working on the code used to control the fire effects at The Crucible‘s Maker Faire 2013 booth when the system just seemed to come to a halt. That’s not quite what it was supposed to do.
The system was designed to have 3 24′ towers as the central part of the booth. On top of the towers would be accumulator based fire effects – a 24″ round sphere w/ a 2″ exhaust port, a 9″ x 24″ oblong tank w/ a massive 3″ pneumatic solenoid / exhaust and three smaller accumulators based on old fire extinguishers. The solenoids on the fire effects would all be controlled with an Arduino. The idea was that there would be no direct user interaction this year but the system would run automatically. Plug in the Arduino and away we go.
The code would run one of a number of possible sequences, pause between 30 and 90 seconds, randomly run the next sequence, pause . . . And it did that, most of the time. A couple of times after starting up the Arduino, several sequences would run and then nothing else would happen. Made me wonder if I had crashed the Arduino.
I added some Serial.print statements to the code to dump out details on what was happening internally and ran the code again. This time it ran without issue for almost 2 hours before coming to a halt. Looking at the output on the serial console showed that that pause value was -31438. Of course everything came to a halt, the system was attempting to pause negative 31,438 milliseconds! This didn’t make much sense until I reread the Arduino docs and saw that ints are 16 bit values. Of course it rolled over into a negative number.
Digging into the code I realized that I had used int’s in several places where an unsigned long was needed. Once fixed, all was right with the world and the system went on to work just fine for both days of the Maker Faire.
Perhaps I need to start writing these systems on a Raspberry Pi where I can use Python 😉
I just read a post on Becky’s blog called “Mmm, serif-y.” She seems to have some mixed feelings about the little Arduino. I tend to agree with her but I’d like to offer a consideration that the Arduino has done more to open electronics and hardware hacking to more people than any other available electronics / hardware / software system to date. It’s easy to use, has lots of examples, an IDE that just work across Windows, OS X and Linux, and is very extensible through shields.
While many of these budding hardware hackers will never progress past the “oh golly gee, my led is blinking” stage, there are lots that will begin to explore more electronics, pcb design and creation, and such. They’ll discover that they can work with different types of hardware and electronics to bring their creations to life. And along the way they will also discover the wonderful sight of chips, resistors and caps going up in smoke. With that annoying burnt electronics smell that comes with it.
They’ll realize that the set of electronic candles they want to create would be too expensive if each one had an Arduino. They’ll start looking at other possibilities like using a PIC processor and designing their own PCB. They’ll ask questions and talk with others who are working to create their own bit of custom electronics. They’ll join or start a local hackerspace. And along the way, they’ll learn a bit and create even more.
All this because they were exposed to that simple world of the Arduino.
I gave a talk at PyCon 2012 on using Python to control external devices through an Arduino.
Seems I was just a wee bit nervous giving the talk. Perhaps some more practice next time…
I had a need to control 16 fire poofers. I wanted the control to be done through a Arduino microcontroller so that the effects like Fire, Stage Left, Thumping and Fire Line can be done. So, a new fire control panel had to be built.
Before I get too deep into the details of building the panel, please read Fire Effects – Safety before even considering doing something like this at home or where you like to play.
The panel started out life as a stainless steel box (A24H2412SS6LP) that was received as part of a donation a while ago. It measures 24″ x 24″ x 12″. It was a bit deeper than needed but that’s ok. The extra space could always be used for something.
The first work was to modify the front door to allow for the switches to manually control everything. There’s a number of different types of switches that are needed to allow the control panel to work with this project as well as future ones.
- An emergency stop switch is needed to shut everything down in the event of things going sideways.
- Toggle switches for things like solenoids on propane tank feeds.
- Toggle switches to control solenoids and igniters.
- Push button momentary contact switches to control solenoids on propane lines feeding fire effects.
- Push button momentary contact switches connected to an Arduino.
- Toggle switch to turn power off to the Arduino and any supporting electronics in case it needs to be reset.
The panel was laid out with 4 logical sections:
- Top most is for the Arduino power switch.
- Next is for the push button momentary contact switches for the Arduino.
- Next is a field of toggle switch / push button momentary contact switch pairs. This allows an individual effect to have a toggle for the igniter and a push button for the solenoid.
- The bottom most is the emergency power switch and the capped toggle switches for the propane feeds.
Just How Many Drills Are Needed?
Once the basic layout was decided, the front door was removed and layout work done to position the switches.
A whole lot of time was spent on a milling machine with a step drill to drill out the holes needed for the switches.
At one point, I had to stop so I cleaned off the panel and remounted it to see what it was going to look like when done. There were only 2 more holes needed, the power switch for the Arduino and the emergency stop switch.
What Does This Wire Do?
With the holes all drilled, the switches were inserted and secured into the panel. It was a bit unfortunate but I used cheaper switches that I purchased through Jameco. The problem with these switches is that the nuts couldn’t be tightened too much or they would slip. Rather annoying but I had already invested in getting them installed and there was a show coming up where I wanted to use the panel.
With all the switches installed, the task of running and soldering all the wires was next. Blue wire was used to connect one side of all the toggle switches with power. White wire was used for the push buttons and yellow for the toggle switches.
Ethernet, It’s Not Just For Networks!
Next up was creating a way to allow the various switches to be connected to the things that they’re controlling.
Since there would only be low current / low voltage signals being sent out from the control panel, I decided to use ethernet cat 5 cable. It’s readily available and reasonably easy to work with. With 4 paired conductors in each cable, I settled on 1 pair for power, 1 pair for ground and 2 pairs for control. That allows each cable to control up to 4 devices. 4 ethernet covers were use with 4 jacks per cover giving a total of 64 control channels.
In an effort allow for changing configurations, all the switches were wired to terminals on one set of euro-style terminal blocks and the ethernet control lines were wired to terminals on another set of euro-style terminal blocks.
The switches are on the left side blocks and the ethernet on the right. With this in place, it’s fairly easy to move the jumpers from one location to another to allow for difference switches on the front panel to control different devices in the field.
In order to allow this control panel to do anything, I created octa-control packs that are deployed in the field and provide switch 120v Edison sockets.
Each octa-control pack has 2 connections for ethernet signal lines, an 8-way relay board, 4 duplex Edison sockets and power plugs to provide power to the Edison sockets.
Originally I also designed quad-control packs that used a single ethernet, 4-way relay board and provided 4 switched Edison sockets. So far I haven’t built any since the octa-control packs have worked well for the types deployments the system has been on.
You can see the 8-way relay board here. It’s a tight fit but works well. The relay board is a Hivitronix “Eight Way Channel Relay Board” that can be found on ebay for around $32 plus shipping. The board requires 12v power which is provided from the control panel via 2 pairs of the ethernet lines, blue / blue stripe are +12v and green / green strip are ground. The remaining ethernet lines are connected to the 8 control pins that trip the relays. Each relay is in turn wired to 120V coming in from the power cords and to the individual hot side of the Edison sockets. The neutral side of the sockets is connected to the common side of the 120V power cord.
So far, everything has been done to allow for manual control. This makes for easier test of the system when it’s deployed as well as if automation isn’t needed. But computer control of the system is a major reason for building this control system and the heart will be an Arduino Mega board.
On a side note, I’d like to give a big shout out to Lady Ada and her amazing crew over at Adafruit. They’re helpful, friendly and provide outstanding customer service. Get your Arduino’s from them!
Now this part is a bit of a mess. Not being an electrical engineer caused a few missteps here. To start with, the switches were setup to provide +12V along the ethernet control lines to the relay boards. That means that the Arduino has to supply +12v for all the circuits which is something that it didn’t want to always do. It let me know this by resetting regularly. So I got a bunch of UDN2981 Darlington IC chips that allows for 8 switched channels each. Connecting the I/O pins of the Arduino to the control pins on the UDN2981 chips and the output pins of the UDN2981 chips to the corresponding ethernet control lines allowed the Arduino to switch the needed +12V and control the relays in the octa-control packs.
All was fine until one of the manual switches was thrown and the Arduino stopped working. This turned out to be a problem where applying +12v to the output pins on the UDN2981 chips caused the chips to burn out. So I added a diode to each of the output pins of the UDN2981 chips to keep the +12V from the manual switches from causing any more grief.
The first generation code for doing fire effect sequences can be found at https://github.com/pkropf/Control_Panel.
As you can see from the image above, there was quite a bit of a hack that was put in place at the last minute before the first show. I’ll get to pulling it out some day and cleaning everything up. In the mean time, the system has been used successfully on The Crucible’s Fire Circus in July 2011, The Crucible’s Fireside Lounge August 2011, the mini-Maker Faire in the east bay October 2011 and The Crucible’s Machine: A Fire Opera in January 2012.
Having run the system several times now, I have quite a few ideas on changes that should be made. Things like:
- Designing a circuit board for the UDN2981 chips and diodes.
- Replacing the euro-style terminal blocks with a set of patch panels and use banana plugs to configure the switches to relays.
- Reorient the switches so that the push buttons are either in the center with the toggles surrounding them or the push buttons on one side and the toggles on the other.
- Adding visual indicators on what’s happening like status lights on the Edison plugs and expose the leds on the relay boards.
- Possibly set up some sort of feedback that can be displayed on the control panel to let the operator know the status of the control packs.
- Add temperature, voltage and current monitoring displays.
- Design an Arduino control pack that has an embedded Arduino controller that can be controlled via the control panel.
With a little luck I’ll actually make the time to do some of these…
Learned a good lesson today. When working with a microcontroller board like an Arduino Uno that runs on 5 volts when it’s connected to a laptop’s USB port, don’t apply 12 volts to one of the digital I/O pins. Tends to burn out parts the Arduino and kills the laptop. Luckily it was a Macbook Pro that looks to have just shutdown and started up again when the power button was pressed. Anyone know if there’s an overvoltage circuit of some sort on the USB ports that shuts down the hardware to prevent problems? Or did I just get lucky?
This wonderful and exciting lesson was learned while working on getting an Arduino to run patterns on the fire effects system for the Crucible’s Fire Circus 2011 show. Once the snarfed Arduino was swapped out for a working board, the sequence code was able to run.
The problem stems from using a 12 volt supply to drive the relay packs and trying to tie the digital pins of the Arduino to the same control lines. The 12 volt supply is currently used to manual controls. I’d like the Arduino to be able to piggyback on the same lines to also control the relay packs. I’m hoping that changing out the 12 volt supply for a 5 volt supply will let the two live and work in peace. I’ll stop by HSC tomorrow morning and see if I can find a suitable 5 volt supply.
In the mean time, here’s the first reasonably successful sequence running: