Introduction: Coilgun Without Massive Capacitors. Finished
About six months ago I built simple coilgun Which had breadboard taped on a board (original project). It was fun and functional but I wanted to finish it. So I finally did. This time I'm using six coils instead of two and I have designed 3D printed case around to give it a futuristic look.
I have also made a video if you want to see it in action :)
Step 1: Tools and Materials
Let's start with the tools.
- 3D printer
- drill
- Dremel
- handsaw
- hot glue gun
- M3 tap
- soldering iron
Materials:
- filament for 3D printer(I used regular PLA)
- my STL files here
- 40 x 10 x 2mm L shaped aluminium profile
- M3 hardware
- magnet discs 8x1.5mm link
electronics:
- arduino nano
- 2x 1400mAh 11.1V 3S 65C Lipo battery link
- 1200mAh 1s Lipo battery This one would do
- 2x step up converters (I'm using XL6009)
- OLED screen .96'' 128x64 i2c SSD1306 link
- AA flashlight (optional)
- laser diode (optional)
- microswitch for trigger V-102-1C4 link
- 3x toggle switches MTS-102 SPDT
- XT-60 connectors (5x female,3x male)
Boards:
- 6x MIC4422YN
- 6x IRF3205 + heastsinks (mine is RAD-DY-GF/3)
- 24x 1n4007
- 6x 10k resistors
- 6x 100nF capacitors
- 6x 100uf capacitors
I'd suggest grabbing more of these as you might break some in the progress. Especially the MOSFETs . I ended up using about 20 of those.
You'll also need things to create the coils but I'm using the same coils as in the previous tutorial so go there and for that you just need the 0.8mm enameled copper wire, infrared LED and phototransistor + some resistors which is all explained in the other tutorial.
Step 2: Frame
The entire gun is build around aluminium frame. I decided to go with aluminium frame because it's light, sturdy, aluminium profiles are easy to get and are fairly cheap. On top of that you can use common hand tools when working on them. The profile I'm using is 40 x 10 x 2 mm and 1 meter long. It needs to be cut to two different pieces. One 320 mm long and the other 110 mm. I have used handsaw to cut them.
The longer piece will be holding pretty much everything and the smaller one will have just the handle. Now It's time to drill a ton of holes and make few cutouts. I have included two pictures showing what needs to be cut and how. The picture without dimensions has red dots is some of the holes. Those are supposed to be drilled with 4 mm drill. The reaming holes without the red dots need to be drilled with 2.5 mm drill and tapped with M3 tap.
The shorter piece is much easier. There is also a picture of that one. I just want to clarify the pictures show the 40 mm widest plane. The 10 mm wall would be on the top side underneath the shown plane so it cannot be seen. That is true for all 3 of those diagrams. As I said, this one doesn't have nearly as much holes but the aluminium profile is way too wide. So it needs to be narrowed all the way across as shown on the diagram.
The main frame will still need couple of holes for wiring. They can be added later but if you want you can drill them now however it might be challenging to know where exactly to put them. More on that in the wiring section.
Attachments
Step 3: Coils
It wouldn't be coilgun without coils, right? The coils I'm using are hand wound onto a 3D printed base. They are identical To the ones I have created in my first coilgun. I'd suggest following those instructions. You can find it here.
The only difference is the fact that the last coil has different 3D printed base as it has infrared sensors on both sides. The sensors are identical too but there is a little bit tidier wiring. At this point you can put the IR sensors in place but don't worry about power and signal wires.
Once you have all 6 coils finished they need to be mounted on the main frame. It's really just matter of screwing them in place. Also I have a tube running trough the coils at this moment but I'll remove it later as it there just to make sure everything is aligned. Depending on how precise your holes are you might only want to screw in two or three screws for each coil to make sure they are as straight as possible.
Step 4: Driver Circuits
Next step is to create the electronics that switches the coils. It's good time to create it now as it will sit on the coils and it's essential part of them. The design is quite different from my previous one as there were some flaws with it. The switching MOSFET is still IRF3205 but we are driving the gate this time with MIC4422YN which is dedicated gate driver. There are couple of passive components as well which are on the schematic.
I'm also providing Eagle files including the board file I've used. Of course you don't have to make your own PCB. You can send it to professional manufacturer or I'd suggest just making it on pref-board. It's really just six components. The biggest part is the heatsink which was complete overkill in my case. I've found that the MOSFETs don't get warm at all. I had coil running for few seconds and it was already on fire and the MOSFET was just warm to touch but not even close to being hot. I'd suggest really tiny heatsink or you could probably do it even without one. Whatever heatsink you'll use don't use the frame as one because you'll connect drains of all the MOSFETs together.
Once you have the drivers done connect them to your coils and add flyback diodes!! Don't forget this because you might get your coils on fire too :D. Flyback diode clamps down high voltage that builds inside of a coil when turned off. Flyback diode needs to be connected on the terminals of the coils in the opposite direction meaning at the point where the coil is connected to the positive terminal of a battery the diode will have it's cathode(negative) terminal connected and vice versa. I'm using 1N4007 but not just one as it wouldn't handle the current so I have four of them connected in parallel. These four diodes are then connected to the coil directly on the coil wire. You'll need to scrape of some of the coating to solder on this wire.
Please keep in my that some of the photos might be missing resistors have different components etc.. Make sure to follow the schematics as those are updated. Some of the footage was done in early prototyping stage.
Attachments
Step 5: Wiring
This is the part where the gun becomes mess. You can try making it tidy as I did but it'll become messy anyway :D. There is a schematic showing what needs to be connected where. Coil0 is considered the first coil that a projectile enters. The same goes for sensors.
I'm using flat cable and I'd suggest you do the same. I started by connecting an arduino to the gate drivers. The arduino is positioned on the very front of the gun with USB port facing outwards for easy programming. Next it was just mattering of connecting everything together and eyeballing the correct length for every wire.
For the IR sensors I have actually drilled holes through the frame where I'd route the wires. I started by connecting the signal wires to every sensor. I used flat cable once again and it actually looked really neat. It only when downhill once I started connecting the power lines. I ran two solid core wires across all of the openings. One for 5V and the other for 0V. Next I made connection from these wires to every single sensor. This is the point where it starts looking really janky especially after taping all of the exposed wire with electrical tape.
All of the connections we've made so far will be handling low current but now it's time to connect the power lines for the coils and MOSFETs. I'm using 14 AWG silicone wire which is quite flexible. Also make sure you get thicker solder as you'll need quite bit of it. We are just going to connect all positive terminals together and do the same with negative terminals. If you're using the same PCB as I did the pads should be exposed right on top of the coils. I'd suggest also putting generous amount of solder on the tracks of the circuits boards that will be handling the high current.
Step 6: Power Supllies
Grab your boost converters and let's get this puppy running. I'm using XL6009 but really any step up converters. We are not going to pull more than 500mA and that is including the flashlight and laser. One converter needs to be set to 12V and the other to 5V. I'm placing them as shown on the picture leaving some space for the battery between the arduino and the converters. The inputs of both converters needs to be connected to the battery.
Next we need to connect all grounds together. The two converters already have grounds connected so just connect theirs with the main 6 cell battery ground which is the thick black wire running on the driver PCBs.
Now the 5V from the output of one converter needs to be connected to the 5V which we have already running to the arduino, sensors and everything else. The 12V output of the other converter must be connected to the MOSFET drivers. I have connected it to the first one and then daisy chained them all together.
Now when you plug in the single cell battery your arduino should start blinking and the gun should be ready but double check all of your connections before plugging the battery because in my case more often than not something blows up on the first try.
Step 7: Projectiles and Magazine
As projectiles I've purchased meter long 8 mm steel rod. Make sure it's magnetic before buying. I have then cut it to 38 mm long pieces. These could already be used as projectiles but I wanted a sharp tip.
The easiest way would be to use lathe and if you have one definitely use it. I however don't have access to lathe. Instead I've decided to make lathe out of a power drill :D .I've clamped the drill to my workbench and inserted a projectile into the chucks. Then I took dremel tool with cut off wheel. By spinning the projectile and grinding it with the dremel I was able to create any tip I wanted. I ended making 8 of these as I can shoot one after another.
For the magazine I printed out magazine and magazine_slider STL files which was the easy part since we also need a spring. I was experimenting with a 3D printed springs but it didn't really work out. I ended getting 0.8 mm spring wire(music wire). I then wound this wire around wooden stick that was 5.5mm x 25mm(any similar size will do). I started by securing one end with a screw and the wound it around. It does take quite a lot of force. I ended up making around 7-8 loops. Once you release the pressure it will spring out and look really bad. Just take pliers and bend it to it's final shape. The spring can then be inserted into the magazine.
With that done take a magnet which I mentioned in the materials and super glue it on the magazine. There is special spot for it. If you have the magazine holder printed out you'll find matching spot for another magnet. You can glue that in as well just make sure you have matching polarity. The two magnets should attract each other when glued in.
Step 8: Assembling the Insides
Before you can try the gun out you'll need to have a trigger and loading mechanism. So let's build that. You'll need to need to have few parts printed out. They are all listed on the first picture. At this point you should be able to just screw them in place. The trigger needs to be held with 2 mm rod so it can spin freely. As I switch I'm using V-102-1C4 microwitch. The wiring for it is actually mentioned at the wiring step and the switch will fit right in the switch holder. When printing the grip mount use at least five perimeters as these parts will need to hold quite a lot of weight.
Once you have everything connected check if the magazine fits right. You might need to adjust some of the holes. I actually ended up using just two screws as some of the holes were off. Also check if the trigger is pushing the microswitch and adjust it if necessary.
Another unnecessary step would be to add barrel. I say unnecessary because the gun will work fine without it. I decided to use one anyway. There is a 3D model called barrel. It needs to be printed with vase mode and since it is just really high tube the quality might get worse as you print higher so I actually ended up printing two of them halfway. I didn't even drill holes for the sensors as I found out they work anyway since it's just 0.4 mm thick despite the fact it was printed in black color.
Step 9: Software and Calibration
Go ahead and download the .ino files. I'm using arduino IDE 1.0.5 but there shouldn't be problem with the newer one either. You'll also need couple of libraries but they are only necessary for the OLED screen. The libraries are Adafruit_SSD1306 and Adafruit_GFX .
With all the libraries you should be able to compile the sketch and upload it. Before I go into the calibration process let me just explain how exactly the code works. We have 6 coils, when you pull the trigger the first coil will turn on until its sensor sees the projectile. If it takes more than 100 ms the system assumes there is no projectile and will stop leaving a message on the screen. These 100 ms can be changed by changing safeTime variable(uses us instead of ms) in shoot() function. Only the sensor on the first coil is actually being used(I have tried many different iterations and some of them use all but this works the best). The following coils all have set time for how long they are on one after another.
The times for the coils are set with the array called baseTime [6]. The first value is always zero as the first coil works differently and only the rest needs to be calibrated. As you can see the last two coils in my case are also 0 and that is because I'm not using them as they don't work and I couldn't be bothered fixing them :D . You want to start by zeroing all of them except the second one(like this: long baseTime [6] = {0,1000,0,0,0,0}; ). You can then upload it and try to fire. The last two sensor will calculate the time it took for the projectile to travel trough them therefore you can calculate the speed. I would suggest saving the value in spreadsheet together with the baseTime value. Repeat it at least 5 times and average it out for more precise results. You can then add 500us and try again until you get the best speed possible. Once you are satisfied with one coil leave the best time set and move to the next coil and repeat the whole process. When calibrating use the coilgun2_calibration.ino code and once done the values need to be copied to coilgun2.ino and uploaded.
Step 10: 3D Printing
There is a lot of files that need to be 3D printed and some of them are quite large. I was printing everything on CR-10 3D printer which has huge build volume so if you have smaller printer some parts might need to be split. I was using regular PLA for all parts and the print settings must be optimized for every part so I've compiled a list whether a part needs support or any other special settings. By default I was using 3 perimeters, 3 bottom layers and 4 top layers at 205°C with heated bed at 60°C.
Apart from the parts inside I've also finished and painted everything. I don't want to go too deep into this as there is already enough tutorials about this. I would suggest this one. In a nutshell I sanded all surfaces applied primer and sanded again. I repeated this 2-3 times and spayed it with paint and finished with clear coat.
Step 11: Final Assembly
Before putting everything together there's few thing missing. The switches, flashlight, laser, wiring for the main battery and LEDs that light up the inside of the gun. Let's start with the on/off switch which needs to be connected in series between the small 1 cell battery and boost converters. I'm actually soldering pin header on the switch and running cable with crimped pin header from the battery just so I can disconnect it for easy assembly. I'll be doing the same for every switch.
I also have flashlight on the front of the gun but you might not have as it was designed for just some flashlight I've had laying around. For the schematic I have just added resistor for the LED and connected it to the battery in series with another switch. I repeated the same for the laser diode. It was actually laser pointer that ran on 4.5V so I connected it right on the 5V line with switch in series.
For the decorative lights I have connected those directly to the 5V line adding connector to make the gun can be disassembled. Two blue 5 mm LEDs have mounting spot in trigger_cover STL files.I have used 12k resistor for each one to make them glow very dimly. On the coil cover I've added 6 blue 3mm LEDs to light up the coils. I have connected the in parallel and added 22R resistor before connecting them to 5V line.
Now we still don't have any permanent way to connect the main batteries. Since one battery is housed in the stock, the other is in the front handle and they need to be connected to the quick release switch we'll need to make several connections. I've provided diagram that explain exactly how it needs to be connected instead of explaining it. Use at least 14 AWG wire also make sure you first push the wire trough the handle and stock before soldering as it won't be possible afterwards.
With all that done the gun should be fully operational and it's time to make it look nice. I'm not going to explain the assembly step by step as it is shown in the video or you can look at the 3D model.