This project was created in order to make my air-powered potato (well, it’ll shoot anything that ends up in the barrel) cannon safer, but most of all, way cooler! The cannon controller simply allows the user to arm the cannon and then fire it either instantly, or after a countdown. The same functionality can be had by using two momentary switches, but the controller does make it tougher to accidentally fire the cannon. Here’s the old controller:
The controller is based on a PIC microcontroller and some other free parts I was able to obtain, such as the dot-matrix LED display, the push button switches, the key switch, and even the case. The software on the PIC is pretty ugly, and is not really interrupt driven for any of it. Basically a state machine is inside that waits for the user to press the “Arm” button, and then waits for the fire button to be pressed after the Arm button was pressed. The controller then goes into a sequence of flashing the fire LED during the countdown, or just lighting the fire LED if the countdown is disabled. The controller drives the air valve with 24V via a relay and a FET to switch the relay on. The key switch merely turns on a relay that turns power on to the whole box, which prevents the cannon from being able to be fired without having the keys to turn it on. It also has a settings mode (key turned all the way to the right), which allows the user to change the brightness of the LED display, set the amount of time the air valve is open for, and to set the countdown time (or disable it). The settings are stored in the PIC’s internal EEPROM. All in all, this version of the cannon controller works quite well, but leaves a little to be desired. Its main issues are that the software is awful to maintain as it was hacked together quickly (features aren’t easily added or changed) and that the controller cannot be disarmed without either firing the cannon or by turning the controller off and then on again. There are also multiple external power supplies that need to be plugged in to operate everything. I’d rather just have a single supply to plug in. Here’s a picture of the insides of the old controller (discretely wired on some perfboard):
The next revision of the cannon controller fixes these issues, and adds the possibility of many new features. There are a bunch of new features that I wanted to add, such as automatic reloading (for the golf ball barrel only), pressure monitoring, muzzle velocity measuring, and the possibility of adding a wireless remote. The perfboarded controller would allow for some of those features to be added, however, there isn’t any free space on the board for additional electronic parts such as drivers for more air solenoids. This inspired the controller that was just built.
The new controller consists of a 2-layer PCB, 9 solenoid drivers (NMOS FETs and back-EMF diodes), 9 analog inputs (one being a conditioned pressure sensor input), 8 opto-isolated digital inputs, multiple LED display support, onboard switchers to generate the 24V coil voltage and 3.3V logic voltage, support for more buttons and more LEDs (if needed), a 434MHz wireless module, and lastly, a PIC microcontroller with enough pins to facilitate all of this. There are only two unused pins on the PIC (64 pin part), and those can be used for a serial port if desired.
I designed the schematics and PCB myself, and had the board made by Dorkbot PCB. The PCBs are pretty cheap ($5 a square inch for 3 boards), and have excellent build quality. The soldermask is purple, which I wouldn’t have chosen, but it really looks awesome w/ the ENIG finish that is included for $5 a sq. inch. I used this place for the Bluetooth OBD-II reader projects too. A picture of the populated board to come…
Of course with every new PCB I make, there’s usually some small issues that were overlooked or just plain messed up. For as many parts that are on this board, the amount of errors is quite small. I messed up a footprint for a power supply FET, had the same power supply schottky diode mounted 180 degrees from where I wanted to mount it, and when the 24V regulator is disabled, voltage is still present at 24V (essentially VIN appears at the output of the switcher). Since I made the controller somewhat generic (this could be used to control other projects requiring mechanical automation, and I have 3 boards sooo), some other mods were created that are specific to the air cannon. Other than that though, it was a very successful spin 1 of the PCB. I won’t be doing a second spin as that costs $$$ that I don’t have, and there’s really no need for it.
The software on the new controller has been totally reworked to be more of an operating system like device that services tasks in a round-robin fashion, like the thermostat software does. Everything in the microcontroller is interrupt driven, so if the microcontroller isn’t servicing some task, it’s just sitting idle waiting for some sort of an interrupt. The controller can now be disabled by pressing the Arm button once the controller is armed, only a single supply is needed to power the controller, and the controller allows for the possibility of more features/expansion.