MATLAB projects

I love figuratively getting my hands dirty when working on stuff, but unfortunately sometimes I use a keyboard.

Programming is an awesome tool.

My experiences with it take a slightly obtuse route. The earliest attempts were using my graphing calculator, a TI-Nspire, to make functions for math class. This simplified such things as the law of cosines to shorten my homework load significantly. Later on I learned more of the coding language than needed just to punch out numbers, and on a TI-89 I eventually developed a clever quadratic function into an artillery game. Unfortunately, the scripts for these have long since been lost to time and software updates.

Once enrolled in UC Davis I took a formal programming course, where I learned MATLAB. It was a good course, and I was excited to bite into some useful coding. After the course I began to use it as a graphing calculator, as it is highly capable in matrix operations, such as Eigenanalysis. It proved to be a valuable ally in homework, as well as a powerful tool in personal projects.

The first such project I embarked on was in early 2012. Due to the wonders of the internet, there had been announced a mysterious gigantic NERF blaster, what is now released as the Centurion. At the time, we knew it had a new type of dart, a larger caliber than before, and a large advertised range of 100 feet. It was new and very exciting, as a club I attended at the time regularly ran NERF wars.

The NERF Centurion. In reality it was a bit underwhelming, because the internet is incredible at hyping things up.

Curious to determine the dart’s size, I went to work on a ballistics calculator. I figured that the size they chose would optimized for the expected spring energy of the blaster. I was looking for that sweet spot of maximum range as size varied. There were, admittedly, several layers deep worth of speculative numbers used. Many specifications were simply madeup. By observing the output graphs, the optimum dart size was determined to be 2.0cm in diameter and 3.4g in mass. By some stroke of luck, the many assumptions used in the calculations yielded a shockingly accurate figure. The actual MEGA darts that were eventually produced were in fact 20mm in diameter. Mass readings on them are hard to find, however, so I have yet to determine the accuracy of that figure. You can see the report I wrote on the matter here. It was written in freshman year and I had not yet learned how to write a proper report, so forgive it if it tries to sound smarter than it is.

Regardless, the ballistics calculator proved to be a very interesting script. It worked through an iterative function- calculating the various forces acting upon the projectile and adjusting the acceleration, velocity, and position appropriately as each time unit ticked by. It was in fact an Euler approximation method, as coarse or as fine as you determine your computer has to deal with.

This gives you a trajectory!

Now, the fun part is that in the loop function, you can put as many forces, functions, calculations, etc. as you want. I ended up keeping track of velocity components as well as projectile energy (kinetic, gravitational, and total mechanical) all as functions of horizontal position, tracking along with the projectile!

ballistic2 ballistic1

Using this calculator as is, I was able to determine necessary design specifications in my water balloon launchers, in particular the elastic bands’ dimensions, given an intended effective range.

A modified script was later made for the water balloon launchers. I wanted to determine firing solutions at various ranges. The script was modified in a few ways. First a target was included, modeling a reasonably average person, shy of 2 meters in height. To model the splash damage (hahaaa), I simply included an area in front of the person to count as a hit as well. The simulation ran a series of ranges of the target, from point blank to beyond maximum range. At each range point, the script would simulate a series of trajectories, determining which ones hit and which ones did not. It was in fact quite inefficient and took a number of minutes to finish calculations, but it worked well enough that I liked it, and developed firing solution charts with them.

wbl_firingsolutions

Firing solutions of the Mk2 Wasserfaust launcher

Lately, I have used MATLAB for the Davis Robotics Team. I had used it to write an algorithm for motor control software. We were at the moment pursuing an underwater ROV design which required a set of eight motors to drive it in the 3D environment. Luckily as it was not a spacecraft we could safely eliminate a number of axes of freedom.

The design used a slight offset angle for the horizontal motors, which increases maneuverability while keeping the number of motors low. The structural designers knew more of it than I, to be honest. Anyways, we needed to be able to derive individual motor input signals from directional and rotational inputs. The algorithm would calculate thrust for a unit of directional input, before normalizing the signals against the total thrust, resulting in thrust inputs as functions of relative power distribution. With these outputs, they can easily be adjusted to whatever available power we have on hand while maintaining your intended heading and directional inputs!

A simple underwater ROV. Our design was to be far more ambitious.

A smaller project was for a bell crank transmission in a control input. As a side project I was looking into making a control yoke for the robotics team, and possibly for video games as well. Looking at the various sensors possible, I decided that control linkage to a linear potentiometer would be the most direct, sturdy, and precise system. However, it would require a bell-crank, which is approximately linear for some of its travel, but as the angle increases it becomes nonlinear. I wrote the script to determine the linear translation of the potentiometer as a function of control input angle. Using this, I was able to determine a range of relatively linear, precise control given the dimensions of the control linkages.

An example of a control yoke. This type is under consideration due to its simple and rugged design.

bellcrank

Blue is the actual translation- green is linear, used for comparison. The red is the difference between the two, and the teal is the restoring moment from a spring on the crankarm.

MATLAB has continued to prove itself as a powerful tool in engineering, and I will likely encounter much more use as my education and potential career continues.

Air Piston Water Gun Mk1 “Gladius”

Air Piston Water Gun Mk1
“Gladius”


This is the Gladius. It is a light, compact water gun that produces extremely high water output for its size. It works like a typical super soaker: drawing water from a reservoir, pressurizing it, and firing it out a front-mounted valve.

IMG_1119

Creating an effective water gun has been on my mind for a while. My family’s competitive nature mingled with my creative side, resulting in an enticing opportunity to one-up people and explore the technical side of propelling water.

28580_630813842147_7170629_n

This is a small part of my competitive family. Three of us brothers and one sister in law are geared up for a water war at camp. I’m near the right with the camouflage dreadlocks hanging off my hat, holding what I consider to be the finest [water] battle implement ever devised: the CPS-1000.

cps1000_05

For those who aren’t strangely well acquainted with super soaker technology, the CPS-1000 was a sweet machine. In numbers, it would hold 2 liters of water in the reservoir, and could shoot up to 600mL of it at a time, with a flow rate of 200mL/second. It was made in 1997 or so, and unfortunately modern water guns are kind of a joke compared to it. A contemporary Super Soaker Lightning Storm can only output 9mL/second.

Anyways, the CPS-1000 is in fact the middle of its product line, staying comfortably light despite its power. There were several super soakers far more powerful, but I consider them too encumbering to be able to stay mobile.

The goal of this whole exercise was to create a water gun with the same design principles: lightweight, compact, yet high performance.


Design

The Gladius was designed to be a high performance water gun. The water gun’s design philosophy as a compact and effective weapon draws similarities to the eponymous Roman sword; in its day a basic, lightweight weapon designed primarily for thrusting attacks.

The CPS-1000, mentioned in a love letter disguised as the introduction, is powered by a thick elastic bladder. Some earlier designs used a similar system, but experience with their use in NERF blaster designs convinced me it would be beyond my fabrication skills.

A simple and reliable pressure system is to pump water into a vertical chamber, compressing the air already inside. However, it is limited in two key ways. First, the water is free to slosh every which way inside of the pressure chamber, and if the water gun is rotated too much, the compressed air will be released instead of the water upon firing. Second, the pressure range is not optimal. Since the air in the chambers is open to the atmosphere after firing, they will pressurize relative to atmospheric pressure. When firing, the pressure drops down to just one atmosphere, and the stream velocity, flow rate, and range all suffer from this dropoff.

Instead, an unusual system was chosen. A moving piston is added to the pressure chamber, providing a permanent seal between air and water. Water slosh is entirely eliminated, providing all-angle capabilities, and since the pressure chamber no longer empties to atmosphere, it is now a self-contained gas system. With that in mind, the opportunity of pre-pressurizing becomes apparent. Pressurizing this gas separately through a schrader valve also eliminates the issue of low-pressure drop off, effectively creating a minimum pressure that is greater than atmospheric.

dagger_design

The design layout was kept mostly the same, with some caveats due to available materials.

The pump and valves were built around 0.5″ PVC pipe and fittings. I had at the time of fabrication a surplus of 1.25″ PVC, so I opted for that as the pressure chamber material. This admittedly limited the volume severely compared to larger diameters, but the chamber was threaded on, and is easily removable in case I produce a larger one.

The water gun separates into two parts: the pump and trigger, and the pressure chamber. The tube out the back leads your reservoir of choice. As you can see, I adjusted the layout of the parts slightly both because of ergonomics and the limitations of PVC fittings. The rod at the bottom of the picture is the pump-shaft.

IMG_1111

You can see here the piston head. It is a 3/4″ PVC Endcap with a small parting put into it via lathe. An O-ring is then fitted into that parting. The second parting was put in there before I had decided on the orientation of the endcap, in case I changed my mind.

IMG_1117

And here is the butt of the pressure chamber, showing the gauge and schrader valve.

IMG_1118

Once assembled, it looked like this. You can see its size, as well. It it somewhat long and tall, but very skinny and light, and proves to be quite comfy.

IMG_1119

IMG_2184


Performance

Well, performance is still under testing.

At the moment I am prepressurizing the air to 30psi, and am pumping until 120psi is achieved.

Current figures rate a pressure chamber volume of 250mL, with a flow rate of about 350mL/second. Its range is nothing special- about 30ft. It takes seven pumps to fill the chamber up to 120psi.

Compared to the CPS-1000, it has nearly double the flow rate, but with under 1 second of firing time it needs to be used with care. Hopefully I will find myself in a water war again someday so I can see how it works there.


Engineering Model

Modeling this water gun has been rather interesting. It relies on a fixed amount of gas within in the piston, becoming a gas cycle of sorts. Unfortunately is not quite a Rankine Cycle, in terms of efficiency, as a good amount of energy is lost to waste heat from compression. To model the ideal gas within the air piston, first we are to simplify these equations.

eq13

Becomes (4), adiabatic pressure equation assuming normal air.

eq4

Now, this can be simplified into a function of volume ratio and pressures, rather than two measured volumes (It can also use specific volume ratio-the two being equivalent- if that floats your boat).

eq5

The pressure model of the piston uses a combination of adiabatic and isothermal compression and expansion.

During compression, the compression is at a relatively low rate, such that the adiabatic effects of temperature increase are quickly eliminated as heat flows out into the environment. Since we then have a constant temperature and amount of gas, we can use the equation (6)

eq6

For safety concerns, I decided on a safe maximum operating pressure of 120psi, with an empty pressure of 30psi. Isothermally, this means a volume ratio (V_i/V_f) of 4. Upon firing, the air pressure is modeled adiabatically. This is due to the extremely fast discharge of water from the piston, lasting only about one second. It is then assumed that there is not enough time for significant heat transfer to occur, meaning there will be significant adiabatic cooling as the gas expands, resulting in a reduced effective pressure at the end of the piston’s travel. Using the previous equation (2) and our initial pressure of 120psi, and inverted volume ratio (as it is now decompressing; V1 is only a quarter of V2)

eq7

We find then that the resultant decompressed pressure to be approximately 17psi, an appreciable loss from the original 30psi. That being said, testing has shown that it is yet still a satisfactory pressure. Once firing is paused or completed, the heat flow into the piston quickly brings the pressure back to its corresponding isothermal levels.

For more information on homemade water guns, see SuperSoakerCentral’s post on the APH (A basic homemade water gun). It was a critical reference in the design and construction of the Gladius.

Water Balloon Launchers

29780_627385322927_6724630_n

I also like the beach. I was very happy in this picture.

I have a thing for water balloon launchers. This has stemmed since around high school, when I participated in large scale water fights on an annual camping trip. Me and my older brother would usually fight together and try and come up with new strategies given our equipment, and he had noticed a gap in water gun capabilities. There were three effective weapons you could use, water balloons, water guns (primarily Super Soaker branded), and 3-person water balloon slingshots.

Water Balloon

A Super Soaker CPS1500

Three-person Water Balloon Slingshot

The first two had an extremely close effective range, around 30 feet was expected, and while the slingshots were of substantially longer range, around 200 or 300 feet, they required three people to operate it, were slow to reload, and difficult to aim.
My brother came up with the idea for a smaller slingshot that would handle like a crossbow for easy aiming and single-person usability. It wouldn’t quite have the range of the larger launchers, but it would substantially increase the effective range for individuals.

This lead to a number of designs and corrections over several years. Sadly, by the time I had produced a working model I was no longer able to attend the camping trip which had inspired the launcher.


wassershrek

“Wassershrek”, lacking its trigger and balloon pouch

This is the first design, the Wassershrek (Water Terror). Senior year of high school I had doodled enough in my notes to go ahead and try fabricating something. A crutch was chosen for the body, given that its original intention was to support a great amount of force while remaining lightweight and ergonomic. Unfortunately, the support posts for the slingshot were made of heavy steel tubes and pulleys, making it incredibly front-heavy. In addition, the tubes proved difficult to drill precisely (I had no jigs or drill press when putting holes in steel. Bad idea in retrospect), and ended up rather asymmetric.

The trigger was a design afterthought, and was simply too prone to getting stuck under loading. It would sometimes work, but it was not easy to operate at all.

And finally, the exercise band used for propulsion could not get enough energy into the projectile in the short draw distance available, and the actual projectile velocity ended up falling far short of expectations.

It was an interesting step in my application of physics, however. I started designing and building it before I had taken any formal physics class, so my calculations were a bit of a mess. In particular, finding the projectile velocity proved daunting. The first approach I did treated it as a differential equation, and with 11th grade knowledge of calculus I really was not able to produce useful algorithms from that. Humorously, I tried integrating force along distance and was dumbfounded at how the dimensions resulted in “foot-pounds”, only for me to scratch my head and wonder why that unit would ever exist practically.


1011639_4705201887837_148826116_n64446_4705202447851_1610202350_n

The Mk1 Wasserfaust (Water Fist) was developed one year later, in the summer after freshman year. Dwelling back on the first launcher prototype I had analyzed what I reckoned to be its functional issues. Tubular metal construction was replaced with plywood and 2×2 wooden beams, a softer material and flat geometry to work with. The exercise band was replaced with a purpose-built 3-man water balloon slingshot, as I was very happy with their design in some aspects. As a result, the main spar was lengthened considerably to match the full draw of the launcher bands. As you may have noted, considerably is not a word I use lightly; the launcher was nearly 10 feet long when completed. The trigger system was reworked considerably, a two-stage sear which resulted in a light trigger pull and reliable firing. It was tested on the earlier model first, before the Mk1 Wasserfaust was constructed around it.

This model was very reliable and powerful, able to launch over 150 feet in range, and turned out to be quite easy to aim. However, its size was its downfall. A 10 foot long launcher is logistically difficult to transport, and very difficult to handle when using it. More specifically, it had huge rotational inertia and a center of gravity nowhere near where one would actually be able to reach with it. You can see me straining to keep it horizontal in one of the pictures.


0716141251

Mk2 Wasserfaust

The Mk2 Wasserfaust was made the next year (Summer of 2014). Again, it was to correct the issues observed earlier. I simplified and strengthened the trigger system, which while reliable, took too much material to produce and felt odd to use. It did slightly elongate the mechanism, but it’s not a huge issue. The launch bands were bought online and cut to size, and I opted for much more powerful bands to allow for a significant shortening of the launcher. These bands proved to have a much greater extension ratio than the store-bought launcher bands, allowing for less length wasted on the slack material.
There were also ergonomic improvements of the buttstock size, shape, and position. Placing one’s cheek on the older Mk1 meant a view of plywood. Doing so on the Mk2’s stock lines up the top of the loaded water balloon with the front forks. A notch was added on the bottom of the main spar at the center of gravity, allowing one to easily rest it on its balance point.

0716141251b

Trigger and handle assembly.

In addition, markings were made along the main spar, denoting various firing angles and their corresponding ranges, allowing more accurate firing at long range. While these were found empirically, a ballistics program was written in MATLAB to test its accuracy. The program would solve for firing solution angles given its muzzle velocity and projectile drag, resulting in the figure below.

wbl_firingsolutions

Mk2 Firing Solutions

It seems these developments happen in short bursts during summer. Chances are there will be a Mk3 in June or July, we will have to see.

-Tim Cuatt

Wool Coat Alterations

Sporterized M-39 Field Jacket

Project began October of 2014, finished in November of 2014.

Freshman year I made an impulse purchase on a coat, wore it maybe four times, and left it in the closet for two years. It had troubled me since and I couldn’t figure out why.

Here is a military surplus garment, the Swedish M-39 Field Jacket

Fit was a bit long and designed for colder climates than Northern California

Shortened the hem by about 5 inches before restitching it.

IMG_0324

Pockets were unfortunately too long and also had to be shortened

I was trying it on another day and found the culprit. Its length, while great in Sweden’s weather, was more of a hindrance in California, and I preferred a lighter jacket style as far as fashion goes. A few sketches and mockups via hem-folding and I found a length I liked, at which point I went ahead with the alterations.

IMG_0323

The completed hem

IMG_0320

Much better! The lower pocket flaps were also shortened to keep proportions appealing.

Proud to have gotten this far, I spent a weekend in a campsite in the mountains nearby. It functioned fantastically! Very warm, yet similarly hard to get too hot in it. However, the collar was an issue. This is, of course, a military surplus coat made of ridiculously rugged wool, and expected to be worn over what I expect to be two or three additional layers, leading to a lackluster lining. These factors worked together to make my exposed neck very itchy and a little bit cold. I then remembered a sweater I’d owned before with what I believe was called sherpa lining. I headed to a thrift store to find something similar and made my way out with $5 of zip-up. A strip was cut out from the material and was sewn onto the upper part of the collar to provide my neck with comfort and warmth.

IMG_0418

Thrift Store Material Donor

Finished Coat

Finished jacket

Having completed it, I had looked back on and noticed I had accidentally made an Ike Jacket, sans waistband. Definitely worse ways for it to have gone. Hand stitching it was a little bit of a pain, as it took about two Saturday’s worth of free time, but definitely worth how it turned out. It has since become my go-to jacket, as far as this winter has fared.

-Tim Cuatt