## LunAero

This week, the University of Oklahoma Aeroecology Biologging group started a crowdfunding campaign for LunAero: an automated lunar bird tracking device. Since this is one of the projects I’m spearheading as part of my postdoctoral position in the lab of Dr. Eli Bridge, I’d like to walk through the current design here. Take a look at the crowdfunding page while you are thinking about it.

LunAero is a robot designed to track the moon as it crosses the sky. This isn’t new. Lots of astronomy mounts can be programmed to follow a specific path of a celestial body across the sky. But LunAero doesn’t do it that way. By using a Raspberry Pi as a brain, LunAero tracks the moon by computer vision. This means that it “sees” the moon and tracks it in real time. By using visual tracking, we can compensate for things like wind and excitable dogs in our backyard (true story) knocking the scope off course.

We are using OpenCV as a platform for LunAero. If you have ever worked with computer vision, you might say to yourself that this seems like overkill for tracking the moon, a body which follows a very well known and predictable path. There is a reason we do it this way. The end goal of LunAero is not to simply track the moon, but the goal is to identify birds crossing in front of the moon.

## Nocturnal Migration

If you are like me, you may not realize how many birds migrate at night. Since they stop chattering and chirping once the sun sets, it is easy to think they all just sleep. But this is not the case. Birds migrate at night to minimize predation on their massive trek. In a single night, LunAero recorded hundreds of birds crossing the full moon. It was amazing! If you do the math, the moon is a small percentage of the sky. Eventually, the massive scale of night migration will begin to dawn on you.

The best method we have for quantifying this event is radar. Our modern weather radars work by detecting water in the air, telling us if that cloud over there is about to rain or not. If you think about it though, all organisms are just bags of water. Don’t think of birds as feathered, flying friends. Instead, think of them like a radar does: as little water balloons. Meteorologists often view our water balloon friends as a source of noise, a nuisance. But a new scientific discipline is emerging called Aeroecology which is very interested in the applications of technologies to study thins living in the air.

Using radar isn’t perfect. There is no real baseline for the fast-moving water balloons the radar detects unless you send an ornithologist out to visually count the birds. Doing this at night is a challenge, since light conditions do not favor observation. So we need to use the silhouettes of birds flying in front of the moon to establish a reasonable estimate.

Now I don’t know about you, but standing outside with my neck crooked and binoculars plastered to my face instead of sleeping does not sound like a fun time. Thus: LunAero.

## Hardware

LunAero is controlled by a Raspberry Pi computer. This computer handles the image capture through a dedicated camera and scope adjustment with the GPIO pins. The GPIO pins communicate directions to a TB6612FNG board, which I have discussed in prior posts. The TB6612FNG provides pulses to 5V gearmotors.

The gearmotors supply power to two large gears. The azimuthal axis (the one that spins like a top) rotates the gear that is supporting the rest of the structure. The altitudinal axis (the one that lifts and lowers) is a partial gear that moves a cradle. We don’t need the whole gear, since the moon will rarely pass directly overhead without deviation. The cradle is what holds our spotting scope.

Since LunAero is meant to be employed by bird-nerds, we designed it to accommodate a spotting scope for the optics. It is a reasonable assessment that a serious birder will probably have access to a spotting scope. This is good, because optics are expensive. A ‘low-cost’ spotting scope can be had for $500, while the one I am using at the moment to capture moon footage is ~$3000. The challenge then becomes, how do we attach a standardized camera? Since all of the eyepieces of scopes are a little different, we had to design a custom adapter for the Raspberry Pi camera which would allow for adjustment in all 3 spatial dimensions. In the end, our adapter looks like a complicated monstrosity, but it works very well. We have a design update planned for it, so I am sure I will discuss more about it later.

## PCB Prep: cut, drill, and liquid tin

In last week’s post, I discussed a method for DIY PCB etching. This week, I will be continuing in that manner by showing you the final preparation steps I used to get this board ready for soldering including cutting, drilling holes, and protecting the copper with liquid tin.

## Cutting and Drilling

Once the boards were completely etched, the holes for through hole parts had to be drilled. These holes were drilled out on a drill press with carbide CNC bits. This part was a challenge, as I did not have a way to punch marks on the copper. Thus, each hole was centered by sight.

It is much easier to transfer and etch multiple boards onto a single piece of copper-clad FR4 than to do each individually. This is exactly what I did. So once the through-holes were drilled, the individual boards were separated from each other. The FR4 was cut on the shop table saw. As I did not leave much room between the individual boards, I took care to keep the kerf of the blade from touching any copper during the cut.

## Protecting the Copper

Copper is a metal which readily undergoes redox reactions in the atmosphere. The copper of a circuit board is no different. If it is left unprotected, the copper will corrode and damage the functionality of the device. Therefore, we must protect it from the atmosphere.

Most PCB fabrication shops apply a mask to the board, covering up all of the leads which do not need to be directly exposed for soldering. The masking materials I have seen are often UV reactive polymers. The etched board is given a thin film of the polymer precursor (often dyed pretty colors, like green), which is then polymerized by exposing the board to intense UV radiation. Unfortunately, we do not currently have any of this material in our shop, so I omitted this step during my fabrication.

Next, in commercially available boards, the contacts are tinned, while the traces are protected by the polymer. Instead of worrying about the pretty polymer covering, the entirety of the copper on my board was tinned as I did not have the luxury of the polymer coat. Tin plating works well to cover the copper, as the tin protects the copper from water vapor while being very solderable (the solders have roughly a ~50% tin content.)While this method is fine for prototyping a DIY board, it is not suitable for end-products. This is chiefly because tin has some odd properties that cause issues with time.

### Linguistic and History Aside

The name of the process, tinning, is a throwback to the original method used to protect board contacts, application of a tin solution which coats the copper. These days, there are many possible tinning agents to protect your board from the inexpensive bronze amalgam to the costly solid gold plating.

Back in the good old days (ca. 1650 C.E.) when you wanted tin plate, the tinsmith would dip the entire metal part in molten tin. With the advent of electricity, electroplating was (re-)discovered. This is still a preferred method for many applications. But we want the quick and easy shortcut. So we will use liquid tin.

## Chemistry

According to the MSDS, liquid tin is a solution of:

• Stannous fluoroborate – Sn(BF4)2
• Fluoroboric acid – HBF4
• Thiourea – SC(NH2)2

The actual chemical composition is, naturally, not reported by MG Chemicals. There are a few patents available out there for tin immersion solutions such as Liquid Tin, but I make a point of not reading patent literature beyond the title to prevent accidental infringement at a later date. If you wanted to get really DIY, you could probably recreate this solution. Plating solutions follow the same generic formula1. You need a:

• Metal ion source
• Reducing agent
• Complexant
• Buffer
• Exaltant
• Stabilizer

Obviously our metal ion source is Sn(BF4)2 as well as being the buffer source. The acid takes care of the reduction. The thiourea acts as the complexing agent in this case as well as a stabilizer2. All that remains is the exaltant. According to Mellor, an exaltant is a field specific term (I’m guessing based on German) for a reaction accelerator3. While there are several non-toxic organic acids that the makers of liquid tin might use for this purpose, I wonder if the aqueous fluoroborate satisfies this niche.

## Back to the Boards

The boards are submerged in the liquid tin solution for a few minutes. As the solution works, rather quickly thanks to our mystery exaltant, you can enjoy the pretty color change from copper to silver. Since the exchange in a liquid tin immersion is surface limited, theoretically you could leave the board in the solution while you work on other things. I was too excited though, so I popped them out right away.

The boards I made had a white substrate from the copper clad material, so the tin plating doesn’t show up very well in my picture. That’s why I included the picture below of another circuit I tinned that day on flexible Kapton film. The orange really makes that tin pop.

## Finished

With the board tinned, it is time to solder on the components. Since I’m a crazy person, I solder the SMD parts on by hand instead of using the oven. The result looks a bit ugly, but it is what’s inside that counts. My completed TB6612FNG board is finally complete.

Works Cited

## Reasoning

Today, I will be showing you the DIY PCB etching workflow used in the lab where I am working. In the post last week, I discussed the design considerations for a TB6621FNG motor control board. This post will document how the physical PCB was created.

Previously, when I have wanted to produce a PCB, I used a fabrication service. For low-budget projects or personal projects, I used OSH Park. While this service is very cost effective for small prototypes, it takes several weeks for the board to arrive. In projects with a heftier budget where timeliness was an issue, I have used Advanced Circuits’ barebones PCB fabrication service. But what if the project is low-budget and in need of a quick turnaround? Easy: take fate into your own hands with a little DIY PCB etching!

## Materials

For this project, you will need:

• Inkjet Transferring Supplies
• Inkjet Printer
• Glossy photo paper
• Lamination Machine
• Scissors and tape
• Etching Solution Bath
• 1 parts (by volume) Muriatic Acid (12M HCl)
• 3 part (by volume) 3% Hydrogen peroxide
• Disposable container made of PE or PP
• Hot water bath
• Plastic tongs
• Acetone
• Personal protective equipment

## Making an Inkjet Transfer

First, you need we prepare our PCB layout for a transfer process. If you are using KiCAD, this is very simple. Go to “plot” your PCB. When the small screen pops up (see image below), the option “mirrored plot” will be grayed out. So first, you must set the plot type to PDF. Then, the “mirrored plot” option will become available.

Note that I have selected to only plot the front layer of copper. Since we can only put a transfer on one side of the board, we can only select one layer at a time. Thankfully, the board I designed is single sided. Note that if you are also etching a back copper layer, you will not need to mirror that plot.

Now, we print four copies of my PCB onto a single sheet of glossy paper. It is important to make more than one copy when you produce a board, as sometimes not everything goes perfectly and you have to throw one of them out.

I wish I had information on the paper I used for this project. Unfortunately, my post-doctoral advisor just found some old stuff that was being removed from the department. The packaging of the ream of paper has no identifying information aside from the 90’s era IBM logo. So, I can’t help you pick the right paper to use. What is important to note about this paper is its glossy photo finish. When the ink is printed onto this kind of paper, the ink remains in a top layer of plastic instead of penetrating fully into the paper. This is thin polymer film is what we will use as the transfer.

## Transfer of the transfer

Next, we cut out our prints and tape them upside-down to the copper side of an FR4 board. This material is called “copper clad board”. The material I used in this instance is pictured above. The part number is not available from that supplier at this time, but there are some other versions instead. See here. The type of tape you use does not matter much. I used brown packing tape, but most will be fine. Personally, I would avoid duct tape, because I suspect that would generate gross fumes and make a mess in the next step, but I have no experience to back this suspicion up.

Now, we take the prepared copper clad board and run it through a desktop lamination machine. While other methods for DIY PCB etching might call for a heat gun or hairdryer to affix the transfer to the board, we found that the laminator works best. The board is rotated and passed through the machine multiple times. For our particular materials and equipment, my advisor stated that the transfer must be passed through exactly 7 times, as this is the correct number to affix the transfer to the copper without melting anything.

With the transfer on the copper, we give it time to cool down. Once cooled to room-temperature, the board and paper are submerged into warm water. After a moment of soaking, the paper peels off cleanly from the copper clad board, leaving a nice clean transfer.

## DIY PCB Etching

Now that our ink has been transferred to the copper clad board, we can begin etching. The etching solution is prepared by a volumetric mixture of 1:3 muriatic acid and hydrogen peroxide in consumer concentrations. Note that these chemicals can be substituted with ~12M HCl and 3% HOOH, should you be in a setting without the consumer versions I mentioned. As always, remember your safety rules. Add acid. This means that you should add acid to the hydrogen peroxide, not the other way around.

One way to accelerate a reaction is to increase the temperature of the solution. Since we are doing this in an inexpensive disposable PE or PP container, directly heating the solution with an electric heater or burner is impractical. Thus, the solution is floated in a hot water bath during the reaction. We used an ice chest which was on hand when we performed this reaction. This high tech etching bath is full of dangerous chemicals, so I recommend putting a lid on the reaction vessel.

Once you give the solution a few minutes to equalize in temperature with the water bath, you can place the board in the solution. The exposed copper will begin to bubble, and the solution will begin to turn green. After few minutes, the reaction should be complete. Keep an eye on it though. Once the copper is completely etched from the exposed board, remove it from the solution with your plastic tongs and stop the reaction by submerging the board in the water bath. If you leave it too long, the solution will begin to etch the copper you want to keep for the board.

## Cleanup

Now that the board is etched and the reaction has been stopped, we can clean up our product. In the image below, we can see that the copper has been completely removed from the exposed areas, but the ink from the transfer remains. This can be cleaned with acetone.

Use a minimal amount of acetone and a cloth to wipe the board. You may have to do some scrubbing, but the acetone does a good job removing the ink. This process should not be very difficult. Once you are done, you are left with a copper board that is complete.

Next week, I will be discussing steps I took to make the board from my DIY PCB etching ready for components.

## Dissertation: Development and Applications of Chemical Sensors for the Detection of Atmospheric Carbon Dioxide and Methane

It is a new year, and my dissertation has finally made it past embargoes to publication. Allow me to present: Development and Applications of Chemical Sensors for the Detection of Atmospheric Carbon Dioxide and Methane. You can view the ProQuest entry here. There is a download link to the full text at the bottom of this entry.

## Title

Development and Applications of Chemical Sensors for the Detection of Atmospheric Carbon Dioxide and Methane

## Abstract

This is a description of the design of a low-power, low-cost networked array of sensors for the remote monitoring of carbon dioxide and methane. The goal was to create a scalable self-powered two-dimensional array for the detection of these gases in a large area. The sensor selection, electronic design, and data communication was studied and optimized to allow for multiple units to form a self-assembling network for acre-scale coverage with minimal human intervention. The final electronic design of the solar-powered units is flexible, providing a foundation for future field deployable remote monitoring devices. Sensors were selected for this application from commercially available models based on low-power, low-cost, market availability, detection range, and accuracy around the global baseline criteria. For environmental monitoring, carbon dioxide sensors are characterized near 400 ppm and methane from 2 to 200 ppm. For both gases, exertions up to several 1000 pm were examined to mimic large releases. An Xbee mesh network of radios was utilized to coordinate the individual units in the array, and the data was transferred in real-time over the cellular network to a dedicated server. The system was tested at a site north of the Oklahoma State campus, an unmanned airfield east of Stillwater, OK, and an injection well near Farnsworth, TX. Data collected from the Stillwater test sites show that the system is reliable for baseline gas levels. The gas injection well site was monitored as a potential source of carbon dioxide and methane leaks due to the carbon dioxide injection process undertaken there for carbon sequestration and enhanced oil recovery efforts. The sensors are shown to be effective at detecting gas concentration at the sites and few possible leak events are detected.

## Reference Information

 Subject Classification 0485: Chemistry 0486: Analytical chemistry 0494: Physical chemistry Identifier / keyword Pure sciences Carbon dioxide Detection Enhanced oil recovery Methane Remote monitoring Sensing Author Honeycutt, Wesley T. Number of pages 196 Publication year 2017 Degree date 2017 ISBN 9780355396188 Dissertation/thesis number 10276467 ProQuest document ID 1965485293 Advisor Materer, Nicholas F. Committee members Apblett, Allen W. Fennell, Christopher J. Ley, M. Tyler White, Jeffrey L. University/institution Oklahoma State University Department Chemistry University location United States — Oklahoma Degree Ph.D.

NOTE: This file is a 166.7MB PDF document. Since I am not a rich man, my website is hosted on a slow, inexpensive server. This download may take some time. It may be quicker to download from a library site, but I want to make sure the document is available to everyone.

Two weeks ago, I discussed the inspirations for a Greek Philospher mask. Last week, I showed how this mask was built up. This week, my Greek Philosopher mask will be completed with the addition of paint and lacquer.

The ‘stone’ surface of the Greek Philosopher mask was painted to look similar to marble. To do this, I first set about finding what sort of marble I wished to imitate. In keeping with the faux-historicity of the mask, I decided to base the colors in the marble off of that which was available in the Hellenistic period. Additionally, I wanted to give the stone an aged appearance which fits with the thematic elements discussed in the inspirations post. My Greek Philosopher mask was to be made of material which imitates discolored Parian marble. Marble from the island of Paros is recognizable as a uniform, crystalline white marble (Washington 1898). The picture below depicts a magnified image of Parian marble.

While no marble ages the same, generally Parian marble ages in such a manner to produce a distinctly orange-hued discoloration. This is possibly due to sub-surface oxalate migration or formation (Pinna 2015). Below are some pictures of discolored Parian marble. The first is a bust of Alexander. The second is Nike of Samothrace.

The hues present in Parian marble statues is distinct from other sources from the area such as Carrara marble. This is the material used in several recognizable sculptures, such as Michelangelo’s Pietà (pictured below) and the Elgin Marbles. These figures often take on a more gray-hued discoloration with age. This is possibly due to fungal and/or bacterial growth on the surface (Marvasi 2008, Konkol 2009).

## Stone in Paint

To produce the marble effect I wanted, I used a variant of a technique called Scagliola. To employ this traditional method for my modern Greek Philosopher mask, I mixed white latex paint with plaster of paris and acrylic paints which acted as pigments. While the surface was wet with the paint, I drew in paints of another pigment to form lines. Then, the light tone of the first few coats was given a dabbed on patina with warm-toned grays and browns to mimic approach the aged Parian marble look I wanted. Finally, carbon soot was rubbed on the dried paint.

After the painting was complete, I added highlighting by marring the surface. A nail was used to scratch the painted surface down to the bottom layers of the scagliola (beneath the dabbed gray, brown, and carbon). These scratches were added in the recessed corners of the surface such as the beard and hair. Additional scratches were added in a haphazard fashion to the smoother surfaces. By using the scratches on the surface, a more aged look is achieved. Applying the scratches to recesses of the surface of the mask mimics the patterns of marble which has been discolored due oils from the skin rubbing on the surface.

## Sealed and Shined

As the Greek Philosopher mask was intended to be functional, the completed surface needed a sealant to prevent the paint from being removed or damaged during wear. Several coats of a water-tight lacquer was applied to the mask. This would prevent spills or rain from damaging the surface, and it would prevent sweat from damaging the interior. The lacquer I used gave the mask the appearance of a polished sheen. If I was to attempt this again, I am not certain I would use a glossy lacquer, as a matte coat might have been more appropriate for a stony surface.

The complete mask was officially shown to the public at Halloween party. Accommodating the wish of my date for a couple’s costume, I dressed as Hades and she as Persephone. The entire costume was a hit, the mask especially. I admit, I still wear the mask from time to time. Since this is one of my favorite works, I find it hard to resist popping it on for a good session of pondering.

## Works Cited

Washington, Henry S. “The Identification of the Marbles Used in Greek Sculpture.” American Journal of Archaeology, vol. 2, no. 1/2, 1898, pp. 1–18. JSTOR, JSTOR, www.jstor.org/stable/496773.

Pinna, D., Galeotti, M. & Rizzo, A. herit sci (2015) 3: 7. https://doi.org/10.1186/s40494-015-0038-1

M. Marvasi, F. Donnarumma, A. Frandi, G. Mastromei, K. Sterflinger, P. Tiano, B. Perito, Black microcolonial fungi as deteriogens of two famous marble statues in Florence, Italy, In International Biodeterioration & Biodegradation, Volume 68, 2012, Pages 36-44, ISSN 0964-8305, https://doi.org/10.1016/j.ibiod.2011.10.011.

Nick Konkol, Chris McNamara, Joe Sembrat, Mark Rabinowitz, Ralph Mitchell, Enzymatic decolorization of bacterial pigments from culturally significant marble, In Journal of Cultural Heritage, Volume 10, Issue 3, 2009, Pages 362-366, ISSN 1296-2074, https://doi.org/10.1016/j.culher.2008.10.006.

Last week, I discussed the inspiration and first few layers of my Greek Philosopher mask. This week, I will be showing a bit more of the build process.

## Building Up

The process I used to make my Greek Philosopher mask is very similar to what was used in the Witch mask design. The bulk of the body of the mask was constructed from my special paper mache material composed of shredded and chopped paper, plaster of paris, PVA glue, and water. The material is layered on in a rather slow process, considering the lengthy drying times for the thick material. Between each layer, I coat the mask in Mod Podge PVA glue to provide extra strength.

The Greek Philosopher mask is thickened with each layer, and elongated at the same time as the beard is constructed. The original holes cut for the eyes are over-expanded to give ample viewing room for the wearer and give room for a upper cheekbones. The nose is broadened from the cranial ridge from the first few layers. The cranial ridge is a design consideration to give additional strength to the build. A mouth is cut, and material is added to the edge to form the lips and mustache. The lips are flared outwards to mimic the shapes used in traditional Greek masks. This flared end is intended to increase the intensity of a sonorous voice for theater that predates many auditory enhancements we see today.

The top of the head is built up with more material to give the illusion of voluminous hair in the finished piece. The Greek Philosopher mask is given an intense demeanor with the shape of material added to the forehead and eye sockets. The mask’s character is given heavy eyebrows and deep-set cheekbones to that effect. The shape of the eyes is triangular to give a more threatening or admonishing tone to the character.

## Sanding Down

Finally, the mask is built up in the manner which I want. The surface is rough and oddly colored, but expression and characteristics for my Greek Philosopher mask are set. The next step is to sand out many off the imperfections to prepare for more detailed work. Since the material is composed of plaster, I would prefer not to inhale the dust. Sanding was performed outside on a day with an adequate breeze.

After the mask was sanded, more material was added to coat the smoothed surface. This time, I used pure plaster of paris to form the more detailed and smooth bits. A watery mix of plaster was added to the face and beard, giving a smooth, finished look.

The hair was constructed from a dryer plaster mix. Strands of hair were shaped with a nail from this more solid mixture. The Greek Philosopher mask was given wavy hair. Many of the original Greek masks have curled hair to fit with the traits of the people in the region, but I opted to not use that. The logic is that the character is a hoary old thinker with less concern for his appearance. The weight of years of extra hair growth while consumed by meditation and thought would have naturally straightened the hair of the individual.

Finally, everything was sanded down again with a finer grained sandpaper to prepare the surface for paint.

Next week, I will be showing the painting inspirations and methods to produce an appropriate look for the Greek Philosopher mask and finishing the build.

One of my favorite creations of late has been my Greek Philosopher mask. For the next three posts, I’m going to go over the construction process I used for it.

The inspiration for the design of the Greek Philosopher mask came from three sources. The first source, and perhaps the most subtly influential one, is The Frogs by Aristophanes. From the wikipedia article, the plot centers around “the god Dionysus, who, despairing of the state of Athens’ tragedians, travels to Hades (the underworld) to bring the playwright Euripides back from the dead. (Euripides had died the year before, in 406 BC.) He brings along his slave Xanthias, who is smarter and braver than Dionysus.” The play is a comedy of language, as many of the period were, and pulls weighty issues to light with a certain levity. I had the opportunity to play a portion of this back in the day with my dramatic other half. As such, I have fond memories of playing Dionysus against my matched foil. This inspiration is something which, I suspect, hid beneath my conscious thought as I came across my other sources.

Near the time of its remastered release, I became enraptured by the album Stone’s Reach by Be’lakor. I was still delving into the melodic death metal scene at that time, and this album had a profound effect on my current musical preferences. The lyrical content of the songs varies, and no cohesive theme runs through the complete work. However, the mind is a beast of patterns. Where there are stripes, reason first seeks a tiger. Lyrics I heard (and occasionally misheard) led me to find commonalities among other songs on the album, and a personal narrative was formed. This was influenced by the album cover, pictured above, which is a purposefully framed shot of the classic sculputre “Perseus with the Head of Medusa“. With my head in a darkened world of chthonic crypts and my eyes pointed toward the perfectly-hewn form gracing the front, I heard the essential lyric:

#### “The carvings have outlived the hand Which bled to first begin them”

The final bit of inspiration for the Greek Philosopher mask was taken from an reproduction Greek “philosopher” mask. I originally went on a Google spree looking for the right work to inspire mine. There are some lovely collections out there of originals, such as the British Museum. You can view the pieces online, such as the ones pulled out by the linked advanced search. I ended up being attracted to a modern reproduction from a (now defunct) website. It can still be accessed via The Wayback Machine. The mask in question was entitled “Philosopher”, whence mine inherited the name.

## The Make

The first layer of the Greek Philosopher mask was produced in a bowl. The interior was contoured in such a way that it would roughly match my facial features. This method differs from the mask creation detailed in the Witch project. In the Witch mask, the back side was built upon from a flat surface, with less regard to a good fit against the face. For the Greek Philosopher mask, I wanted something which would fit well for long periods with heavy movement, similar to the expectations of a good theater mask.

After a bit more material was added to the face, a head covering was added. Simple eye slits were cut which would later be broadened with further building.

Next week, I will cover the construction a bit more, and the mask will begin to resemble it’s final form.

## Giant Robber Fly Eating a Cicada

I took a lovely picture this summer of a giant robber fly eating a cicada. The picture was taken in Washington county, Oklahoma. I observed the take-down myself while working in the garage. The robber fly ambushed the cicada while it was sitting on an overhanging branch of the nearby hackberry tree.

In the above picture, the cicada is still alive. The panicked trills and beating of the wings allowed for me to easily find where the pair landed. The giant robber fly eating a cicada in this picture is of the genus Promachus. The species is difficult to know for certain without detailed observation of the specimen, but it appears to bear similar traits to Promachus hinei based on information available from BugGuide. Promachus hinei’s range extends through Oklahoma, making this a reasonable candidate. The yellow and black pattern, detailed in this picture, appears to be a distinctive trait.

## Back from Hiatus

I have returned from the dead and am back from hiatus. This brief intermission was due to moving and real-life delays. Please enjoy this entertaining image of my cat carrying his favorite toy as a gesture, re-welcoming you to this blog now that I am back from hiatus.

## LaTeX: Drawing MOSFET in TikZ – Labels and Animation

Continuing from last week’s post, this week we will be adding labels to our MOSFET in TikZ and adding slide animations with Beamer.

As a reminder, last week we drew our image of a MOSFET in Tikz before adding colors. The colors we added were based on the materials used in each part of the n-type MOSFET. Now let’s add some labels to make sure that anyone we present this image to can understand what is going in.

## Centered Labels

Now we take the code from last week and add “nodes” to certain of our shapes. We tell these nodes to have certain text and compile.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{patterns}

\title{\LaTeX~Surface Science and Electronics}
\author{Wesley T. Honeycutt}
\date{\today}

\newcommand{\metalone}{[pattern= horizontal lines, pattern color=blue]}
\newcommand{\metaltwo}{[pattern= vertical lines, pattern color=purple]}
\newcommand{\poly}{[pattern= grid, pattern color=red]}
\newcommand{\pdiff}{[pattern= north east lines, pattern color=orange]}
\newcommand{\ndiff}{[pattern= north west lines, pattern color=green]}
\newcommand{\pwell}{[pattern= crosshatch dots, pattern color=orange]}
\newcommand{\nwell}{[pattern= crosshatch dots, pattern color=green]}
\newcommand{\oxide}{[pattern = bricks, pattern color = olive]}
\newcommand{\silicon}{[fill = white]}
\newcommand{\metalthree}{[fill = teal]}

\begin{document}

\frame{\titlepage}

\frame{\frametitle{MOSFET}
% General n-type mosfet
\begin{tikzpicture}
\draw \pdiff (0,.25) -- (0,3) -- (1,3) -- (1,2.5) to [out=270,in=180] (1.5,2) -- (3.75,2) to [out=0,in=270] (4.25,2.5) -- (4.25,3) -- (6.75,3) -- (6.75,2.5) to [out=270,in=180] (7.25,2) -- (9.5,2) to [out=0,in=270] (10,2.5) -- (10,3) -- (11,3) -- (11,.25) -- (0,.25) node {p-type};
\draw \metalthree (0,0) rectangle (11,.25) node {Si Substrate};
\draw \oxide (4,3) rectangle (7,4) node {oxide};
\draw \metalone (4,4) rectangle (7,4.5);
\draw \ndiff (4.25,3) -- (1,3) -- (1,2.5) to [out=270,in=180] (1.5,2) -- (3.75,2) to [out=0,in=270] (4.25,2.5) -- (4.25,3) node {n-type};
\draw \ndiff (10,3) -- (6.75,3) -- (6.75,2.5) to [out=270,in=180] (7.25,2) -- (9.5,2) to [out=0,in=270] (10,2.5) -- (10,3) node {n-type};
\draw \metalone (1.25,3) rectangle (3,3.5);
\draw \metalone (8,3) rectangle (9.75,3.5);
\end{tikzpicture}
}

\end{document}


This gives us the following image with ill-placed text:

The text looks odd because the node location in TikZ defaults to the last point in the drawing. We can tell it to place the node in a certain location with respect to this anchor point. Additionally, I might want to change some other properties such as text color for my labels. This can all be done in brackets after declaring the node. Now my code becomes:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{patterns}

\title{\LaTeX~Surface Science and Electronics}
\author{Wesley T. Honeycutt}
\date{\today}

\newcommand{\metalone}{[pattern= horizontal lines, pattern color=blue]}
\newcommand{\metaltwo}{[pattern= vertical lines, pattern color=purple]}
\newcommand{\poly}{[pattern= grid, pattern color=red]}
\newcommand{\pdiff}{[pattern= north east lines, pattern color=orange]}
\newcommand{\ndiff}{[pattern= north west lines, pattern color=green]}
\newcommand{\pwell}{[pattern= crosshatch dots, pattern color=orange]}
\newcommand{\nwell}{[pattern= crosshatch dots, pattern color=green]}
\newcommand{\oxide}{[pattern = bricks, pattern color = olive]}
\newcommand{\silicon}{[fill = white]}
\newcommand{\metalthree}{[fill = teal]}

\begin{document}

\frame{\titlepage}

\frame{\frametitle{MOSFET}
% General n-type mosfet
\begin{tikzpicture}
\draw \pdiff (0,.25) -- (0,3) -- (1,3) -- (1,2.5) to [out=270,in=180] (1.5,2) -- (3.75,2) to [out=0,in=270] (4.25,2.5) -- (4.25,3) -- (6.75,3) -- (6.75,2.5) to [out=270,in=180] (7.25,2) -- (9.5,2) to [out=0,in=270] (10,2.5) -- (10,3) -- (11,3) -- (11,.25) -- (0,.25) node [midway,above] {p doped Si};
\draw \metalthree (0,0) rectangle (11,.25) node [midway, color=white]
{Si Substrate};
\draw \oxide (4,3) rectangle (7,4) node [pos=.5,font=\bf\Large] {oxide};
\draw \metalone (4,4) rectangle (7,4.5);
\draw \ndiff (4.25,3) -- (1,3) -- (1,2.5) to [out=270,in=180] (1.5,2) -- (3.75,2) to [out=0,in=270] (4.25,2.5) -- (4.25,3) node at (2.625,2.5) [align=center] {n-type};
\draw \ndiff (10,3) -- (6.75,3) -- (6.75,2.5) to [out=270,in=180] (7.25,2) -- (9.5,2) to [out=0,in=270] (10,2.5) -- (10,3) node at (8.375,2.5) [align=center] {n-type};
\draw \metalone (1.25,3) rectangle (3,3.5);
\draw \metalone (8,3) rectangle (9.75,3.5);
\end{tikzpicture}
}

\end{document}


In this case, I have added some alignment options for different locations.

• For the silicon substrate, I have told the node [midway, color=white] so the text appears in the middle of the rectangle and white to show up against the color of metalthree
• For the p doped region, I have told the node [midway,above] so that the text is in the middle of the picture and at the bottom. Notice how midway does not place the text at the true center of custom shapes. It only knows to place it relative to the previous line.
• For the n doped regions, I did not want the text to sit relative to the line, I wanted it to be in the center of the shape. Thus, I told the node to be at a certain set of coordinates which I calculated to be the center of that shape, and set [align=center].
• For the oxide layer, I wanted the text to show up against the oddly colored bricks. Therefore, I used [pos=.5,font=\bf\Large]. The “pos=.5” argument is functionally the same as “midway”, but offers greater freedom to customize. The font arguments tell the node to use text in boldface with a Large size.

The image ends up looking like this:

## Labels on Arrows

I’ve decided that I want to label the metal connections on our MOSFET, but I don’t want to place the text directly over the shape. Instead, I want to tell TikZ to draw little arrows pointing to what is labeled. This is easy. We just draw a line, which we tell to have an arrowhead, from a point to another point. At the first point, we tell it to have a label. I have used:

\draw [->] (1,5) node [above] {Source} -- (2.125,3.5);
\draw [->] (10,5) node [above] {Drain} -- (8.975,3.5);
\draw [->] (5.5,5) node [above] {Gate} -- (5.5,4.5);


Which when implemented, looks like this:

## Animation with Beamer

Did you know that the same person that wrote TikZ wrote Beamer, the LaTeX slideshow creator? It’s true. This makes things quite convenient, as the author has designed it such that it is easy to integrate slide animations into your TikZ code.

For the final part of our MOSFET in TikZ, I’m going to add some animation. I want to make it obvious to the viewer how my MOSFET works going from the off state to saturation mode. I will do this by adding nodes to present the voltage relationship of each state on the screen, then pop up an image of the electron rich areas of the MOSFET. This is very easy to do with \only. Check out the final code below:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{patterns}

\title{\LaTeX~Surface Science and Electronics}
\author{Wesley T. Honeycutt}
\date{\today}

\newcommand{\metalone}{[pattern= horizontal lines, pattern color=blue]}
\newcommand{\metaltwo}{[pattern= vertical lines, pattern color=purple]}
\newcommand{\poly}{[pattern= grid, pattern color=red]}
\newcommand{\pdiff}{[pattern= north east lines, pattern color=orange]}
\newcommand{\ndiff}{[pattern= north west lines, pattern color=green]}
\newcommand{\pwell}{[pattern= crosshatch dots, pattern color=orange]}
\newcommand{\nwell}{[pattern= crosshatch dots, pattern color=green]}
\newcommand{\oxide}{[pattern = bricks, pattern color = olive]}
\newcommand{\silicon}{[fill = white]}
\newcommand{\metalthree}{[fill = teal]}

\begin{document}

\frame{\titlepage}

\frame{\frametitle{MOSFET}
% General n-type mosfet
\begin{tikzpicture}
\draw \pdiff (0,.25) -- (0,3) -- (1,3) -- (1,2.5) to [out=270,in=180] (1.5,2) -- (3.75,2) to [out=0,in=270] (4.25,2.5) -- (4.25,3) -- (6.75,3) -- (6.75,2.5) to [out=270,in=180] (7.25,2) -- (9.5,2) to [out=0,in=270] (10,2.5) -- (10,3) -- (11,3) -- (11,.25) -- (0,.25) node [midway,above] {p doped Si};
\draw \metalthree (0,0) rectangle (11,.25) node [midway, color=white]
{Si Substrate};
\draw \oxide (4,3) rectangle (7,4) node [pos=.5,font=\bf\Large] {oxide};
\draw \metalone (4,4) rectangle (7,4.5);
\draw \ndiff (4.25,3) -- (1,3) -- (1,2.5) to [out=270,in=180] (1.5,2) -- (3.75,2) to [out=0,in=270] (4.25,2.5) -- (4.25,3) node at (2.625,2.5) [align=center] {n-type};
\draw \ndiff (10,3) -- (6.75,3) -- (6.75,2.5) to [out=270,in=180] (7.25,2) -- (9.5,2) to [out=0,in=270] (10,2.5) -- (10,3) node at (8.375,2.5) [align=center] {n-type};
\draw \metalone (1.25,3) rectangle (3,3.5);
\draw \metalone (8,3) rectangle (9.75,3.5);
\draw [->] (1,5) node [above] {Source} -- (2.125,3.5);
\draw [->] (10,5) node [above] {Drain} -- (8.975,3.5);
\draw [->] (5.5,5) node [above] {Gate} -- (5.5,4.5);
\only<1> {\node at (5.5,-.5) [align=center] {$V_{GS} < V_{threshold}$};}
\only<2-3> {\node at (5.5,-.5) [align=center] {$V_{GS} \geq V_{threshold}$};
\node at (5.5,-1) [align=center] {$V_{DS} < V_{GS} - V_{threshold}$};
}
\only<3> {\draw [fill=white] (4.25,3) rectangle (6.75,2.5);
\draw \ndiff (4.25,3) rectangle (6.75,2.5);
}
\only<4-5> {\node at (5.5,-.5) [align=center] {$V_{GS} \geq V_{threshold}$};
\node at (5.5,-1) [align=center] {$V_{DS} = V_{GS} - V_{threshold}$};
}
\only<5> {\draw [fill=orange,orange] (4.25,3) rectangle (6.75,2.5);
\draw [fill=white] (4.25,3) -- (4.25,2.65) -- (6.75,3) -- (4.75,3);
\draw \ndiff (4.25,3) -- (4.25,2.65) -- (6.75,3) -- (4.75,3);
}
\only<6-7> {\node at (5.5,-.5) [align=center] {$V_{GS} \geq V_{threshold}$};
\node at (5.5,-1) [align=center] {$V_{DS} > V_{GS} - V_{threshold}$};
}
\only<7> {\draw [fill=orange,orange] (4.25,3) rectangle (6.75,2.5);
\draw [fill=white] (4.25,3) -- (4.25,2.85) -- (6.75,3) -- (4.75,3);
\draw \ndiff (4.25,3) -- (4.25,2.85) -- (6.75,3) -- (4.75,3);
}
\end{tikzpicture}
}

\end{document}


Each time I add an \only, I put slide numbers in pointed braces. The code between the curly braces will “only” show up on the slides listed in the pointed braces. The result of this code is shown in the following gif:

## Wrap Up

I know that creating a MOSFET in TikZ is a bit specific. Still, I hope that this little tutorial gives everyone a feel for how to take make nice scale-able images in LaTeX using TikZ.