Tuesday, September 20, 2016

Coil Gun Simulation Program

For those who are not aware, undergraduate engineering students are required to complete a senior design project in their last year before they can receive their B.Sc. In undergraduate, my senior design project was to design and construct a single stage handheld electromagnetic launcher (coil gun) capable of accelerating a projectile to a muzzle velocity equivalent to that of a .22 caliber pellet gun (~13 [J] to 44 [J]). Normally, I wouldn't consider schoolwork to be interesting enough to warrant a post on this site, but one novel development resulted from the research and development process of designing the coil gun for my senior design project. Prior to beginning preliminary construction and benchtop testing of a specific coil gun design, I went in search of theoretical treatments of coil gun operation in the literature, so I could get a rough estimate of the geometric and component requirements that would be needed to meet our muzzle energy specification. After much digging, the best I could find were a few rules of thumb for coil gun design that were determined experimentally. Not having a very large budget, and having a hard deadline for the project, I felt that I probably wouldn't have the resources needed to iterate through several experimental designs in search of an acceptable solution.

Consequently, I set out to develop a simulator capable of rapidly approximating the electro-mechanical behavior of a coil gun with a reasonable degree of accuracy. As anyone who is familiar with coil guns is no doubt aware, this presents a broad set of challenges and complications that preclude a clean, purely analytic solution. In particular, transient changes in coil inductance brought on by the motion of the ferromagnetic core (projectile) through the coil during firing and the changing magnetization and relative magnetic permeability of the core material with the B field generated by the coil during firing are particularly difficult to predict. Moreover, the force between the coil and projectile that induces the launching of the projectile is governed by a set of elliptical integral calculations. In the process of developing an understanding of each physical effect at play, I developed six interconnecting physics modules to calculate the coil inductance, discharge current, induced coil B field, projectile magnetization, magnetic force, and projectile motion in the system at a given point in time (shown below in Figure 1).

Figure 1: Diagram of simulator physics modules

Using these simulation blocks, it was possible to put together a fully integrated simulation program that could predict the overall system behavior of the coil gun during a discharge event by stepping the physics in small differential time intervals. Once the simulator was fully developed, I spent a good bit of my time trying to debug the physics modules by improving the approximations made by the simulator. For instance, the magnetic permeability of the space surrounding a coil gun during a discharge event is anything but uniform; this greatly complicates the calculation of inductance for the solenoid coil of the gun. After much tinkering with the simulator I found that the best way to approximate the permeability environment was to take a volumetric average of the permeability within the firing chamber. Similarly, to approximate the magnetic saturation of the projectile, the simulator requires the user to provide experimental B-H curve data for the material used.

All of the technical development of the simulation program aside, once I had tweaked the simulator enough, I found that the final muzzle energy it predicted for my senior design coil gun was seemingly very accurate. That said, I haven't seen any other simulators out there that are quite as comprehensive as mine. After letting the simulation code collect dust for a while now, I looked back over the code and decided that I should release the simulator program to the public so that perhaps someone else looking to build a coil gun might benefit from my work.

So, without further ado, here is a link where you can download the full MATLAB code for the simulator as well as a standalone executable version of the simulator.

Here are a few other notes regarding the simulator for those interested in using the simulator:
  • The simulator requires you to have B-H curve data for the magnetic material that the projectile is made of; however, the download link above includes example .csv files containing B-H curve data for several common ferromagnetic materials
  • The simulator is capable of estimating the inductance of the solenoid coil itself, but, if you happen to be lucky enough to have an RLC meter, you can input an override inductance parameter for the coil.
  • There are three modes of firing available in the simulator: thyristor, mosfet with freewheeling diode, and contactor. If you aren't sure what kind of component you plan to use for your coil gun, I would recommend just setting the simulator to contactor mode by unchecking the thyristor and mosfet radio buttons in the simulator parameters window.
  • The download link above includes MS Word documents with my original theoretical calculations used in the simulator development if you are interested in that sort of thing.
  • The download link also includes citations of all academic papers and websites that I got information/theory from that was used in making the simulator. 
  • You can actually use this program for multi-stage designs by using the initial conditions parameters.
  • Before anyone tells me that my simulator makes too many simplifications to be 100% accurate, I know. The whole point of the simulator is to be able to run very fast simulations to aid in coil gun optimization.

One final comment, if anyone has any questions/comments about the simulator or would like me to make a formal tutorial/documentation file for the simulator, feel free to contact me. For now, I'm just kinda throwing this thing out there and seeing if it sticks to anything.

Monday, July 18, 2016

Retroplayed: Episode 2

About two years ago, I published the first episode of a video game review series, which I had dubbed "Retroplayed," that focused on examining technically impressive retro games. If memory serves I promised the second episode of the series "sometime before the turn of the next millenium." So, in keeping with that promise, here's the second episode of Retroplayed:

In this episode, I take a look at Zero Tolerance for the Sega Genesis. An early 2.5D FPS from Technopop.

Wednesday, May 18, 2016


     Once again, it's that time of year wherein I have just barely enough free time in my schedule to eek out a new update for the TEROS Engine. Many moons ago, shortly after completing the BETA update, I realized that the NPolygon class could be harnessed to create a patterned texturing algorithm, capable of using an ASCII text pattern stored in file to define a complex, non-homogenized polygonal surface texture. Sadly, it has taken over half a year for me to finally find the time to test the algorithm that I devised for said texturing. Nonetheless, I have managed to implement the algorithm successfully, and I'm happy to report that it works as intended (so far). So, without further ado, I present the traditional video update for the BETA software release:

     As always, this new BETA software release can be found on both my Google Drive account and my GitHub page.  Moreover, in keeping with tradition, the new software release comes with the customary addition of a new tutorial file on the texturing algorithm, as well as updated documentation files. It is my hope that, with this final time saving feature implemented in the engine, the software may finally prove simple enough to use to attract some seriously interested independent developers, but, as always, I'm just glad to have had the fun of designing the algorithms to implement this new feature.

Monday, May 25, 2015

TEROS Engine BETA Video Update

     As promised in my last post, I have completed the video update for version of the TEROS Engine. In the video, I go over the new NPolygon class in depth, and I demonstrate the usage of the .STL to .TR3 file conversion software that has been bundled with version

     As per usual, I hope that this latest release will generate some interest in the TEROS Engine, but, if nothing else, this update was definitely an exciting challenge to bring from the drawing board to reality.

Friday, May 22, 2015


     Back from the dead after almost a full year of developmental hiatus, the latest version of the TEROS Engine--BETA finally here. In the last video update--BETA mentioned that the engine was unlikely to see any further updates until I received feedback from beta users. Ultimately, such feedback was never received, but I did finally come up with a new feature to add to the engine--arbitrarily many-sided polygons. Previously, the TEROS Engine only supported triangular polygons; in this update, a new object class--the NPolygon class--has been added to implement polygons of any geometry and complexity.

An example of an NPolygon object.

      In addition to the creation of the NPolygon class, a .docx version of the TEROS Engine documentation file has been created for version to provide a more convenient reference manual. Moreover, I have created an .STL to .TR3 file conversion program that should enable potential TEROS Engine developers to create 3D models in existing modeling software, save said models as stereolithography files (.STL), and convert them for use with the TEROS Engine.

As per usual, a download of version can be found on my GitHub page and on my Google Drive account. Furthermore, a video update for this new version is in the works.

Tuesday, August 26, 2014

Enabling the 'ls' Unix Command on Windows Terminals

     Recently, a friend of mine related to me his frustration with the nonexistence of the 'ls' command on Windows operating systems, due to Microsoft's preference of the 'dir' command. Naturally, upon hearing of his plight, I decided to bash out a quick C++ program to remonstrate the deficiency. After using this program to enable use of the 'ls' command on my friend's computer, it occurred to me that there might be others who would wish for the same feature on their Windows terminals, and, as such, I have packaged all the necessary files and instructions for enabling the 'ls' command here for public download.

Tuesday, May 20, 2014

Retroplayed: Episode 1

     Last year, I began work on the pilot episode of what I hoped would become a series of video game reviews highlighting underappreciated technical marvels in gaming history. In this inaugural episode, I take a look at Dan Kitchen's Tomcat: The F-14 Fighter Simulator, a surprisingly intricate Atari 2600 flight simulator.

     Overall, given the delayed production in my finishing this review, I was fairly happy with how it turned out in the end, and I hope it does justice to what is one of my favorite Atari 2600 games. If the Fates are kind, I'll probably start production on the next episode sometime before the turn of the next millennium.