Linux Fu: Better Bash Scripting

It is easy to dismiss bash — the typical Linux shell program — as just a command prompt that allows scripting. Bash, however, is a full-blown programming language. I wouldn’t presume to tell you that it is as fast as a compiled C program, but that’s not why it exists. While a lot of people use shell scripts as an analog to a batch file in MSDOS, it can do so much more than that. Contrary to what you might think after a casual glance, it is entirely possible to write scripts that are reliable and robust enough to use in many embedded systems on a Raspberry Pi or similar computer.

I say that because sometimes bash gets a bad reputation. For one thing, it emphasizes ease-of-use. So while it has features that can promote making a robust script, you have to know to turn those features on. Another issue is that a lot of the functionality you’ll use in writing a bash script doesn’t come from bash, it comes from Linux commands (or whatever environment you are using; I’m going to assume some Linux distribution). If those programs do bad things, that isn’t a problem specific to bash.

One other limiting issue to bash is that many people (and I’m one of them) tend to write scripts using constructs that are compatible with older shells. Often times bash can do things better or neater, but we still use the older ways. For example:

Continue reading “Linux Fu: Better Bash Scripting”

Serious DX: The Deep Space Network

Humanity has been a spacefaring species for barely sixty years now. In that brief time, we’ve fairly mastered the business of putting objects into orbit around the Earth, and done so with such gusto that a cloud of both useful and useless objects now surrounds us. Communicating with satellites in Earth orbit is almost trivial; your phone is probably listening to at least half a dozen geosynchronous GPS birds right now, and any ham radio operator can chat with the astronauts aboard the ISS with nothing more that a $30 handy-talkie and a homemade antenna.

But once our spacecraft get much beyond geosynchronous orbit, communications get a little dicier. The inverse square law and the limited power budget available to most interplanetary craft exact a toll on how much RF energy can be sent back home. And yet the science of these missions demands a reliable connection with enough bandwidth to both control the spacecraft and to retrieve its precious cargo of data. That requires a powerful radio network with some mighty big ears, but as we’ll see, NASA isn’t the only one listening to what’s happening out in deep space. Continue reading “Serious DX: The Deep Space Network”

Books You Should Read: The Idea Factory

You’ve heard of Bell Labs, but likely you can’t go far beyond naming the most well-known of discoveries from the Lab: the invention of the transistor. It’s a remarkable accomplishment of technological research, the electronic switch on which all of our modern digital society has been built. But the Bell Labs story goes so far beyond that singular discovery. In fact, the development of the transistor is a microcosm of the Labs themselves.

The pursuit of pure science laid the foundation for great discovery. Yes, the transistor was conceived, prototyped, proven, and then reliably manufactured at the Labs. But the framework that made this possible was the material researchers and prototyping ninjas who bridged the gap between the theory and the physical. The technology was built on what is now a common material; semiconducting substances which would not have been possible without the Labs refinement of the process for developing perfectly pure substances reliably doped to produce the n-type and p-type substances that made diode and transistor possible.

Continue reading “Books You Should Read: The Idea Factory”

Beyond A Boot Print: The Lasting Effect Of Apollo On Humanity

July 20th, 1969 was the day that people from Earth set foot on different soil for the first time. Here we are 48 years later, and the world’s space programs are — well — not very close to returning to the moon. If you aren’t old enough to remember, it was really amazing. The world was in a lot of turmoil in the 1960s (and still is, of course) but everyone stopped to look at the sky and listen to the sound of [Neil Armstrong] taking that first step. It was shocking in a good way and almost universally observed. Practically everyone in the world was focused on that one event. You can see some of that in the NASA video, below.

Space flight was an incredible accomplishment, but it paled in comparison with the push to actually landing a person on the moon and bringing them home safely. The effort is a credit to the ability of people to work together (on the order of thousands of minds) to overcome a difficult challenge. We can learn a lot from that alone, and it makes a compelling argument to continue taking on tough problems. Today, as we remember the Apollo landings, let’s take a moment to recognize what came of it beyond an iconic boot-print in the floury lunar soil.

Continue reading “Beyond A Boot Print: The Lasting Effect Of Apollo On Humanity”

The 4-20 MA Current Loop

The I/O capabilities built into most microcontrollers make it easy to measure the analog world. Say you want to build a data logger for temperature. All you need to do is get some kind of sensor that has a linear voltage output that represents the temperature range you need to monitor — zero to five volts representing 0° to 100°C, perhaps. Hook the sensor up to and analog input, whip up a little code, and you’re done. Easy stuff.

Now put a twist on it: you need to mount the sensor far from the microcontroller. The longer your wires, the bigger the voltage drop will be, until eventually your five-volt swing representing a 100° range is more like a one-volt swing. Plus your long sensor leads will act like a nice antenna to pick up all kinds of noise that’ll make digging a usable voltage signal off the line all the harder.

Luckily, industrial process engineers figured out how to deal with these problems a long time ago by using current loops for sensing and control. The most common standard is the 4-mA-to-20-mA current loop, and here we’ll take a look at how it came to be, how it works, and how you can leverage this basic process control technique for your microcontroller projects.

Continue reading “The 4-20 MA Current Loop”

Paul Horowitz And The Search For Extra Terrestrial Intelligence

I recently had the opportunity to attend a lecture by Harvard Professor Paul Horowitz. It’s a name you likely recognize. He is best known for his iconic book the Art of Electronics which is often referred to not by its name but by the last names of the authors: “Horowitz and Hill”.

Beyond that, what do you know about Paul Horowitz? Paul is an electrical engineer and physicist and Paul has spent much of his storied career learning and practicing electronics for the purpose of finding intelligent extra terrestrial life.

Continue reading “Paul Horowitz And The Search For Extra Terrestrial Intelligence”

Hitching A Ride On A Missile

Before the Saturn V rocket carried men to the moon, a number of smaller rockets carried men on suborbital and orbital flights around the Earth. These rockets weren’t purpose-built for this task, though. In fact, the first rockets that carried people into outer space were repurposed ballistic missiles, originally designed to carry weapons.

While it might seem like an arduous task to make a ballistic missile safe enough to carry a human, the path from a weapons delivery system to passenger vehicle was remarkably quick. Although there was enough safety engineering and redundancy to disqualify the space program as a hack, it certainly was a clever repurposing of the available technology. Read on for the full story.

Continue reading “Hitching A Ride On A Missile”