The Basics Of Persistence Of Vision Projects

Persistence of Vision (POV) is a curious part of the human visual system. It’s the effect by which the perception of an image lingers after light has stopped entering the eye. It’s why a spinning propeller appears as a disc, and why a burning sparkler appears to leave a trail in the air. It’s also commonly used as a display technology, where a series of flashing LEDs can be used to create messages that appear to float in the air. POV displays are a popular microcontroller project, and today, we’ll explore the basic techniques and skills required in such builds.

Continue reading “The Basics Of Persistence Of Vision Projects”

Grind Your Welds With Pride, If That’s The Way You Do It

To grind or not to grind? What a question! It all depends on what you’re really trying to show, and in the case of welded joints, I often want to prove the integrity of the weld.

My ground-back piece of welded tube. Eagle-eyed readers will spot that the grinding reveals a weld that isn't perfect.
My ground-back piece of welded tube. Eagle-eyed readers will spot that the grinding reveals a weld that isn’t perfect.

Recently, I wrote a piece in which I talked about my cheap inverter welder and others like it. As part of it I did a lower-current weld on a piece of thin tube and before snapping a picture of the weld I ground it back flat. It turns out that some people prefer to see a picture of the weld bead instead — the neatness of the external appearance of the weld — to allow judgment on its quality. Oddly I believe the exact opposite, that the quality of my weld can only be judged by a closer look inside it, and it’s this point I’d like to explore.

Continue reading “Grind Your Welds With Pride, If That’s The Way You Do It”

DSP Spreadsheet: FIR Filtering

There’s an old saying: Tell me and I forget, teach me and I may remember, involve me and I learn. I’m guilty of this in a big way — I was never much on classroom learning. But if I build something or write some code, I’m more likely to understand how it works and why.

Circuit simulation and software workbooks like Matlab and Jupyter are great for being able to build things without a lot of overhead. But these all have some learning curve and often use clever tricks, abstractions, or library calls to obscure what’s really happening. Sometimes it is easier to build something in a spreadsheet. In fact, I often do little circuit design spreadsheets or even digital design because it forces me to create a mathematical model which, in turn, helps me understand what’s really going on.

In this article I’m going to use Google Sheets — although you could do the same tricks in just about any spreadsheet — to generate some data and apply a finite impulse response (FIR) filter to it. Of course, if you had a spreadsheet of data from an instrument, this same technique would work, too.

Continue reading “DSP Spreadsheet: FIR Filtering”

Fried Desk Lamp Reborn: How To Use ESP8266 To Build Connected Devices

Some hacks are born of genius or necessity, and others from our sheer ham-fisted incompetence. This is not a story about the first kind. But it did give me an excuse to show how easy it is to design WiFi-connected devices that work the way you want them to, rather than the way the manufacturer had in mind.

It started out as a sensible idea – consumer electronics in Vietnam have many different electric plug types for mains AC power: A, C, G, F, and I are fairly present, with A and C being most common. For a quick review of what all those look like, this website sums it up nicely. There are universal power adapters available of course, but they tend to fit my most common type (C) poorly, resulting in intermittent power loss whenever you sneeze. So I figured I should replace all the plugs on my devices to be A-type (common to those of you in North America), as it holds well in all the power bar types I have, mainly leftover server PDUs.

This was very straightforward until I got to my desk lamp. Being a fancy Xiaomi smart lamp, they had opted to hide a transformer in the plug with such small dimensions that I failed to notice it. So instead of receiving a balmy 12 volts DC, it received 220 volts AC. With a bright flash and bang, it illuminated my desk one final time.

Continue reading “Fried Desk Lamp Reborn: How To Use ESP8266 To Build Connected Devices”

Tool Rolls, The Fabric Design Challenge That Can Tidy Up Any Workshop

You’ve designed PCBs. You’ve cut, drilled, Dremeled, and blow-torched various objects into project enclosurehood. You’ve dreamed up some object in three dimensions and marveled as the machine stacked up strings of hot plastic, making that object come to life one line of g-code at a time. But have you ever felt the near-limitless freedom of designing in fabric?

I don’t have to tell you how satisfying it is to make something with your hands, especially something that will get a lot of use. When it comes to that sweet cross between satisfaction and utility, fabric is as rewarding as any other medium. You might think that designing in fabric is difficult, but let’s just say that it is not intuitive. Fabric is just like anything else — mysterious until you start learning about it. The ability to design and implement in fabric won’t solve all your problems, but it sure is a useful tool for the box.

WoF? Fat quarter? How much is a yard of fabric, anyway?

To prove it, I’m going to take you through the process of designing something in fabric. More specifically, a tool roll. These two words may conjure images of worn, oily leather or canvas, rolled out under the open hood of a car. But the tool roll is a broad, useful concept that easily and efficiently bundles up anything from socket wrenches to BBQ utensils and from soldering irons to knitting needles. Tool rolls are the best in flexible, space-saving storage — especially when custom-designed for your need.

In this case, the tools will be pens, notebooks, and index cards. You know, writer stuff. But the same can just as easily organize your oscilloscope probes. It’s usefully and a great first foray into building things with fabric if this is your first time.

Continue reading “Tool Rolls, The Fabric Design Challenge That Can Tidy Up Any Workshop”

Linux Fu: Shell Scripts In C, C++, And Others

At first glance, it might not seem to make sense to write shell scripts in C/C++. After all, the whole point to a shell script is to knock out something quick and dirty. However, there are cases where you might want to write a quick C program to do something that would be hard to do in a traditional scripting language, perhaps you have a library that makes the job easier, or maybe you just know C and can knock it out faster.

While it is true that C generates executables, so there’s no need for a script, usually, the setup to build an executable is not what you want to spend your time on when you are just trying to get something done. In addition, scripts are largely portable. But sending an executable to someone else is fairly risky — but your in luck because C shell scripts can be shared as… well, as scripts. One option is to use a C interpreter like Cling. This is especially common when you are using something like Jupyter notebook. However, it is another piece of software you need on the user’s system. It would be nice to not depend on anything other than the system C compiler which is most likely gcc.

Luckily, there are a few ways to do this and none of them are especially hard. Even if you don’t want to actually script in C, understanding how to get there can be illustrative.

Continue reading “Linux Fu: Shell Scripts In C, C++, And Others”

Lambdas For C — Sort Of

A lot of programming languages these days feature lambda functions, or what I would be just as happy to call anonymous functions. Some people make a big deal out of these but the core idea is very simple. Sometimes you need a little snippet of code that you only need in one place — most commonly, as a callback function to pass another function — so why bother giving it a name? Depending on the language, there can be more to it that, especially if you get into closures and currying.

For example, in Python, the map function takes a function as an argument. Suppose you have a list and you want to capitalize each word in the list. A Python string has a capitalize method and you could write a loop to apply it to each element in the list. However, map and a lambda can do it more concisely:

map(lambda x: x.capitalize(), ['madam','im','adam'])

The anonymous function here takes an argument x and calls the capitalize method on it. The map call ensures that the anonymous function is called once for each item.

Modern C++ has lambda expressions. However, in C you have to define a function by name and pass a pointer — not a huge problem, but it can get messy if you have a lot of callback functions that you use only one time. It’s just hard to think up that many disposable function names. However, if you use gcc, there are some nonstandard C features you can use to get most of what you want out of lambda expressions.

Continue reading “Lambdas For C — Sort Of”