Recent posts (max 10) - Browse or Archive for more

Cooling fan Lego assembly

I have a SeaWit 4-port HDMI KVM switch (similar to this one on Amazon) that I suspected might be overheating. I didn't have any fans blowing across it, and it was in a stack of other electronic devices, so I'm not sure blame attaches. Still, I needed some way to get some air across it.

For this type of application, I prefer a blower fan design rather than a propeller fan.

I found a four-pack of small, inexpensive USB-powered 5V 50mm x 50mm x 15mm fans on Amazon.

fan-picture.jpg

The KVM switch wasn't designed with fan mounting holes or anything, so I needed some sort of frame assembly to hold them. So of course I reached for my mechanical engineering rapid prototyping kit, better known as my Lego collection.

The mounting holes of those are a snug fit for a Technic pin with friction, which can then be used to mount them to a Lego assembly.

fan-dimensions.jpg

The distance between the mounting holes does not quite align with Lego dimensions, but a Technic beam provides the needed adjustment.

I developed two assembly types. If the fan is positioned to draw air from below (so that small random objects don't fall into the fan blades), then the fan can be above (type 1) or below (type 2) the supporting structure.

Type 1: Fan above supporting structure

5v-cooling-fan-lego-assembly-type-1.png

model file and building instructions

The physical build, with the fan installed:

type1-top.jpg

type1-bottom.jpg

Type 2: Fan below supporting structure

5v-cooling-fan-lego-assembly-type-2.png

model file and building instructions

The physical build, with the fan installed:

type2-top.jpg

type2-bottom.jpg

Note that for this build, I adjusted the width of the structure by tacking on a couple extra bricks to the top. It's a trivial change, but made for a better fit around the KVM switch's feet.

This seems to work for cooling the KVM switch, and while two fans is probably overkill, having two assembly types does give me some flexibility.

Sabaton Index updates; new song "Father"

Sabaton released a new song last month related to World War One titled Father and a related history video about Fritz Haber.

I've updated SabatonIndex with the discography and videos they've released of late.

LDraw Parts Library 2022-05 - Packaged for Linux

LDraw.org maintains a library of Lego part models upon which a number of related tools such as LeoCAD, LDView and LPub rely.

I packaged the 2022-05 parts library for Fedora 34 to install to /usr/share/ldraw; it should be straight-forward to adapt to other distributions.

The *.noarch.rpm files are the ones to install, and the .src.rpm contains everything so it can be rebuilt for another rpm-based distribution.

ldraw_parts-202205-ec1.fc34.src.rpm

ldraw_parts-202205-ec1.fc34.noarch.rpm
ldraw_parts-creativecommons-202205-ec1.fc34.noarch.rpm
ldraw_parts-models-202205-ec1.fc34.noarch.rpm

Grid-based Tiling Window Management, Mark II

A few years ago, I implemented a grid-based tiling window management tool for Linux/KDE that drastically improved my ability to utilize screen realestate on a 4K monitor.

The basic idea is that a 4K screen is divided into 16 cells in a 4x4 grid, and a Full HD screen is divided into 4 cells in a 2x2 grid. Windows can be snapped (Meta-Enter) to the nearest rectangle that aligns with that grid, whether that rectangle is 1 cell by 1 cell, or if it is 2 cells by 3 cells, etc. They can be moved around the grid with the keyboard (Meta-Up, Meta-Down, Meta-Left, Meta-Right). They can be grown by increments of the cell size in the four directions (Ctrl-Meta-Up, Ctrl-Meta-Down, Ctrl-Meta-Left, Ctrl-Meta-Right), and can be shrunk similarly (Shift-Meta-Up, Shift-Meta-Down, Shift-Meta-Left, Shift-Meta-Right).

While simple in concept, it dramatically improves the manageability of a large number of windows on multiple screens.

Since that first implementation, KDE or X11 introduced a change that broke some of the logic in the quicktile code for dealing with differences in behavior between different windows. All windows report location and size information for the part of the window inside the frame. When moving a window, some windows move the window inside the frame to the given coordinates (meaning that you set the window position to 100,100, and then query the location and it reports as 100,100). But other windows move the window _frame_ to the given coordinates (meaning that you set the window position to 100,100, and then query the location and it reports as 104,135). It used to be that we could differentiate those two types of windows because one type would show a client of N/A, and the other type would show a client of the hostname. But now, all windows show a client of the hostname, so I don't have a way to differentiate them.

Fortunately, all windows report their coordinates in the same way, so we can set the window's coordinates to the desired value, get the new coordinates, and if they aren't what were expected, adjust the coordinates we request by the error amount, and try again. That gets the window to the desired location reliably.

The downside is that you do see the window move to the wrong place and then shift to the right place. Fixing that would require finding some characteristic that can differentiate between the two types of windows. It does seem to be consistent in terms of what program the window is for, and might be a GTK vs QT difference or something. Alternatively, tracking the error correction required for each window could improve behavior by making a proactive adjustment after the first move of a window. But that requires maintaining state from one call of quicktile to the next, which would entail saving information to disk (and then managing the life-cycle of that data), or keeping it in memory using a daemon (and managing said daemon). For the moment, I don't see the benefit being worth that level of effort.

Here is the updated quicktile script.

To use the tool, you need to set up global keyboard shortcuts for the various quicktile subcommands. To make that easier, I created an importable quicktile shortcuts config file for KDE.

Of late I have also noticed that some windows may get rearranged when my laptop has the external monitor connected or disconnected. When that happens, I frequently wind up with a large number of windows with odd shapes and in odd locations. Clicking on each window, hitting Meta-Enter to snap it to the grid, and then moving it out of the way of the next window gets old very quickly. To more easily get back to some sane starting point, I added a quicktile snap all subcommand which will snap all windows on the current desktop to the grid. The shortcuts config file provided above ties that action to Ctrl-Meta-Enter.

This version works on Fedora 34; I have not tested on other distributions.

Sabaton Index updates

Sabaton released a few new lyric videos and a couple of new history videos. The SabatonIndex is updated with links to that new content.

LDraw Parts Library 2022-03 - Packaged for Linux

LDraw.org maintains a library of Lego part models upon which a number of related tools such as LeoCAD, LDView and LPub rely.

I packaged the 2022-03 parts library for Fedora 34 to install to /usr/share/ldraw; it should be straight-forward to adapt to other distributions.

The *.noarch.rpm files are the ones to install, and the .src.rpm contains everything so it can be rebuilt for another rpm-based distribution.

ldraw_parts-202203-ec1.fc34.src.rpm

ldraw_parts-202203-ec1.fc34.noarch.rpm
ldraw_parts-creativecommons-202203-ec1.fc34.noarch.rpm
ldraw_parts-models-202203-ec1.fc34.noarch.rpm

Sabaton "The War To End All Wars" album released

Sabaton released a new album this week with the theme of World War One titled The War To End All Wars. A previous album The Great War was also about WW1; the new album looks at another set of stories from that era, including "Christmas Truce", the story of a truce made by the ground forces on Christmas Eve. I've updated SabatonIndex with the discography and videos they've released for the new album.

Random Username Generator

Sometimes you need a username for a service, and you may not want it to be tied to your name. You could try to come up with something off the top of your head, but while that might seem random, it's still a name you would think of, and the temptation will always be to choose something meaningful to you. So you want to create a random username. On the other hand, "gsfVauIZLuE1s4gO" is extremely awkward as a username. It'd be better to have something more memorable; something that might seem kinda normal at a casual glance,

You could grab a random pair of lines from /usr/share/dict/words, but that includes prefixes, acronymns, proper nouns, and scientific terms. Even without those, "stampedingly-isicle" is a bit "problematical". So I'd rather use "adjective"-"noun". I went looking for word lists that included parts of speech information, and found a collection of English words categorized by various themes, which are grouped by parts of speech. The list is much smaller, but the words are also going to be more common, and therefore more familiar.

Using this word list, and choosing one adjective and one noun yields names like "gray-parent", "boxy-median", and "religious-tree". The smaller list means that such a name only has about 20 bits of randomness, but for a username, that's probably sufficient.

On the otherhand, we could use something like this for passwords like "correct horse battery staple", but in the form of adjective-adjective-adjective-noun. Given the part-of-speech constraint, 3 adjectives + 1 noun is about 40 bits of entropy. Increasing that to 4 adjectives and 1 noun gets about 49 bits of entropy.

So of course, I implemented such a utility in Python:

usage: generate-username [-h] [--adjectives ADJECTIVES] [--divider DIVIDER] [--bits BITS] [--verbose]

Generate a random-but-memorable username.

optional arguments:
  -h, --help            show this help message and exit
  --adjectives ADJECTIVES, -a ADJECTIVES
                        number of adjectives (default: 1)
  --divider DIVIDER     character or string between words (default: )
  --bits BITS           minimum bits of entropy (default: 0)
  --verbose             be chatty (default: False)

As the word list grows, the number of bits of entropy per word will increase, so the code calculates that from the data it actually has. It allows you to specify the number of adjectives and the amount of entropy desired so you can choose something appropriate for the usecase.

That said, 128 bits of entropy does start to get a little unweildy with 13 adjectives and one noun: "concrete-inverse-sour-symmetric-saucy-stone-kind-flavorful-roaring-vertical-human-balanced-ebony-gofer". Whoo-boy; that's one weird gofer. That could double as a crazy writing prompt.

If the word list had adverbs, we might be able to make this even more interesting. For that matter, it might be fun to create a set of "Mad Libs"-like patterns "The [adjective] [noun] [adverb] [verb] a [adjective] [noun]." Verb tenses and conjugations would make that more difficult to generate, but could yield quite memorable passphrases. Something to explore some other time.

Hopefully this will be useful to others.

LDraw Parts Library 2022-01 - Packaged for Linux

LDraw.org maintains a library of Lego part models upon which a number of related tools such as LeoCAD, LDView and LPub rely.

I packaged the 2022-01 parts library for Fedora 34 to install to /usr/share/ldraw; it should be straight-forward to adapt to other distributions.

The *.noarch.rpm files are the ones to install, and the .src.rpm contains everything so it can be rebuilt for another rpm-based distribution.

ldraw_parts-202201-ec1.fc34.src.rpm

ldraw_parts-202201-ec1.fc34.noarch.rpm
ldraw_parts-creativecommons-202201-ec1.fc34.noarch.rpm
ldraw_parts-models-202201-ec1.fc34.noarch.rpm

Remote Power Switches

Being able to turn a vacuum cleaner or fan on and off from across a room can make life much easier while working on a project. I had previously made an extension cord which incorporated a double lightswitch and had found that I was dragging that box around with the switch and the vacuum cleaner power cord plugged in, and that was getting awkward. So I created a dedicated "remote" switch power cable to make it easier to use.

I'm going to show four designs for such a remote switch. One of them is a reasonable design. Three of them add functionality, but also introduce hazards, and therefore I must recommend against them. But I find those interesting enough to explore.

All components use NEMA5-15 receptacles and plugs.

Basic Remote Switch

Beginning with the simplest design, we have a switch that controls a receptacle:

wiring-diagram-single-switch-hardwired.png

Complete parts list:

Part Qty
single-width deep electrical box 2
electrical box outlet cover plate 1
electrical box switch cover plate 1
conduit clamp grommet 3
heavy-duty extension cord 1
NEMA5-15 power outlet 1
light switch 1
fuse holder 1
fuse 1
wire nut 1
10-12 AWG insulated female spade crimp terminal 2
4-5" of stranded wire 1

Cut the extension cord so you have the plug end connected to about 2 feet of wire, then cut the receptacle off the other part of the extension cord. This will give you a pigtail that can plug into a receptacle, and a length of power cable.

To create a hole in which to mount the fuse holder in the switch module, drill/dremel a hole of matching size in the electrical box knock-out plate opposite the knock-out plate removed for the power cable.

Wire the contraption up following the diagram above. The pigtail with the plug is wired to the receptical in the box, The wire nut is used inside the receptacle box to connect the hot wire from the pigtail to the hot wire in the power cable. The power cable runs from the receptacle box to the switch box. The power cable hot wire connects to the fuse holder in the switch box with a crimp terminal, and then the other lead on the fuse holder connects to the switch using a crimp terminal and the short length of stranded wire. The ground wire connects to the ground terminal on the switch.

Be sure to use a multimeter to check that your wiring is correct and you have not introduced a short before you plug it into power.

This is the reasonable design; it gives you a switch that controls a power outlet up to some number of feet away, depending on the size of the extension cord you started with. It solves the problem at hand. If you're here looking to solve that problem, this is the design to use, and you can skip the rest of the blog post. The remaining designs below, while more functional, introduce hazards that I cannot recommend.

But if you have an engineering mindset, come with me as I explore them anyway.

Extensible Remote Switch

The above design is quite functional, but you have to commit to the distance between the receptacle and the switch. We can add a receptacle and plug into the design between the two like this:

wiring-diagram-single-switch-extensible.png

And now you can put a standard extension cord of almost arbitrary length between the receptacle box and the switch.

But this also introduces a hazard. Now the switch is its own module, and could accidentally be plugged into a regular power outlet and flipped "on", directly creating a short circuit. While doing so should throw a breaker or blow the fuse in the switch module, there is risk of problems, so I recommend against building this.

Complete parts list:

Part Qty
single-width deep electrical box 2
electrical box outlet cover plate 1
electrical box switch cover plate 1
conduit clamp grommet 3
heavy-duty extension cord 1
NEMA5-15 power outlet 1
light switch 1
fuse holder 1
fuse 1
wire nut 1
NEMA5-15 receptacle 1
NEMA5-15 plug 2
10-12 AWG insulated female spade crimp terminal 2
4-5" of stranded wire 1

For this design, you make a different set of cuts on the power cord. Cut the extension cord so you have the plug end connected to about 2 feet of wire. From the other portion of the extension cord, cut two 2-foot lengths from the cut end to give you two 2-foot sections of power cable, with the remainder of the power cable still connected to the original receptacle.

Build a (shorter) extension cord:

wiring-diagram-extension-cord.png

Sub-assembly parts list:

Part Qty
heavy-duty extension cord receptacle + wire 1
NEMA5-15 plug 1

Wire one of the plugs to the remaining part of the extension cord (which has the extension cord's original receptacle on it) to give you a (shortened) extension cord.

Build the receptacle module:

wiring-diagram-single-switch-extensible-receptacle-module.png

Sub-assembly parts list:

Part Qty
single-width deep electrical box 1
electrical box outlet cover plate 1
conduit clamp grommet 2
heavy-duty extension cord plug + 2' wire 1
heavy-duty extension cord 2' wire 1
NEMA5-15 power outlet 1
wire nut 1
NEMA5-15 receptacle 1

The wire nut is used inside the receptacle box to connect the hot wire from the short plug pigtail to the hot wire going to the receptacle.

Build the switch box module:

wiring-diagram-single-switch-extensible-switch-module.png

Sub-assembly parts list:

Part Qty
single-width deep electrical box 1
electrical box switch cover plate 1
conduit clamp grommet 1
heavy-duty extension cord 2' wire 1
light switch 1
fuse holder 1
fuse 1
NEMA5-15 plug 1
10-12 AWG insulated female spade crimp terminal 2
4-5" of stranded wire 1

Be sure to use a multimeter to check that your wiring is correct and you have not introduced a short before you plug any of this into power.

Double Remote Switch

A different functionality enhancement is to make the two receptacles in the receptical box independent of each other and put two switches in the control box, giving two controls in one device.

wiring-diagram-double-switch-hardwired.png

This also introduces a hazard, though a more subtle one; in this case we use the ground wire between the receptacle box and the control box to carry load current. The ground wire may be a smaller gauge wire than the neutral and hot conductors, and thus risk overheating. Additionally, the control box which you will be handling is no longer grounded; if something goes wrong electrically, you risk electrocution.

Part Qty
single-width deep electrical box 2
electrical box cover plate 2
conduit clamp grommet 3
heavy-duty extension cord 1
NEMA5-15 power outlet 1
double light switch 1
fuse holder 1
fuse 1
spray paint, white 1
spray paint, black 1
wire nut 1
10-12 AWG insulated female spade crimp terminal 2
4-5" of stranded wire 1

Lightly sand the faceplates,

sanded-faceplates.jpg

and paint one half white and one half black.

painted-faceplates.jpg

For this design, you make the same cuts in the extension cord as for the single remote switch design. Cut the extension cord so you have the plug end connected to about 2 feet of wire, then cut the receptacle off the other part of the extension cord. This will give you a pigtail that can plug into a receptacle, and a length of power cable.

Wire the contraption up following the diagram above. The wire nut is used to connect the hot wire inside the receptacle box.

open-assembly.jpg

Note that you will likely need to snap off a metal tab connecting the hot terminals of the receptacles to make them independently controllable.

Be sure to use a multimeter to check that your wiring is correct and you have not introduced a short before you plug it into power.

Once the painted faceplates have dried, install them so that the white switch controls the white receptacle, and the black switch controls the black receptacle.

fully-assembled.jpg

Double Extensible Remote Switch

The two previous enhancements can be combined to yield the most functional, but also the most hazardous version of this remote power switch:

wiring-diagram-double-switch-extensible.png

Part Qty
single-width deep electrical box 2
electrical box cover plate 2
conduit clamp grommet 3
heavy-duty extension cord 1
NEMA5-15 power outlet 1
double light switch 1
fuse holder 1
fuse 1
spray paint, white 1
spray paint, black 1
wire nut 1
NEMA5-15 receptacle 1
NEMA5-15 plug 2
10-12 AWG insulated female spade crimp terminal 2
4-5" of stranded wire 1

Paint the faceplates as for the previous build.

In an effort to mitigate one of the hazards of this design, I took the plug and receptacle in the middle of this system and painted them to make them stand out as somehow different from normal plugs and receptacles. Before building everything, I plugged them into each other and wrapped two pieces of electrical tape around them in a spiral to create something resembling a warning stripe. Since they were yellow plastic, I sprayed them with black paint, then removed the electrical tape. That gave a visually striking touch to those connectors:

extendable-version.jpg

For this design, you make the same cuts in the extension cord as for the single extensible remote switch design. Cut the extension cord so you have the plug end connected to about 2 feet of wire. From the other portion of the extension cord, cut two 2-foot lengths from the cut end to give you two 2-foot sections of power cable, with the remainder of the power cable still connected to the original receptacle.

Build a (shorter) extension cord:

wiring-diagram-extension-cord.png

Sub-assembly parts list:

Part Qty
heavy-duty extension cord receptacle + wire 1
NEMA5-15 plug 1

Wire one of the plugs to the remaining part of the extension cord (which has the extension cord's original receptacle on it) to give you a (shortened) extension cord.

Build the receptacle module:

wiring-diagram-double-switch-extensible-receptacle-module.png

Sub-assembly parts list:

Part Qty
single-width deep electrical box 1
electrical box outlet cover plate 1
conduit clamp grommet 2
heavy-duty extension cord plug + 2' wire 1
heavy-duty extension cord 2' wire 1
NEMA5-15 power outlet 1
wire nut 1
NEMA5-15 receptacle 1

The wire nut is used inside the receptacle box to connect the hot wire from the short plug pigtail to the hot wire going to the receptacle.

Note that you will likely need to snap off a metal tab connecting the hot terminals of the receptacles to make them independently controllable.

Build the switch box module:

wiring-diagram-double-switch-extensible-switch-module.png

Sub-assembly parts list:

Part Qty
single-width deep electrical box 1
electrical box outlet cover plate 1
conduit clamp grommet 1
heavy-duty extension cord 2' wire 1
double light switch 1
fuse holder 1
fuse 1
NEMA5-15 plug 1
10-12 AWG insulated female spade crimp terminal 2
4-5" of stranded wire 1

Be sure to use a multimeter to check that your wiring is correct and you have not introduced a short before you plug any of this into power.

And here is the completed contraption in all its hazardous glory:

extended-remote.jpg

(A couple of notes regarding the photo: I started with an extension cord on which I had previously replaced the original receptacle. Further, I made my cuts "backward" from what is described here; I used the plug end of the original extension cord for the build of the shortened extension cord. I've attempted to refine the designs given here based on my trial-and-error build experience.)

Conclusion

As always, the above should be used at your own risk, but hopefully you can see that there are risks and weigh them appropriately. And once again, the simplest answer is frequently the best answer.