Software Design Patterns For Real Hardware

Here on Hackaday, we’re generally designers of hacks that live in the real world. Nevertheless, I’m convinced that some of the most interesting feats are at the mercy of what’s possible in software, not hardware. Without the right software, no 3D printer could print and no quadcopter could fly. The source code that drives these machines may take months of refinement to flesh out their structure. In a nutshell, these software packages are complicated, and they don’t happen overnight.

So how do they happen; better yet: how could we make that happen? How do we write software that’s flexible enough to coexist peacefully on all sorts of hardware variations?

What separates the big open-source software projects like ROS, LinuxCNC, and Multiwii from the occastional hackathon code are the underlying principles that govern how they’re written. In object-oriented programming, these principles are called design patterns. In the next couple posts, I’m going to crack the lid on a few of these. What’s more, I’ll package them into real-world examples so that we can see these patterns interact with real hardware. The next time you pop open the source code for a big open source hardware project, I hope you can tease out some of these patterns in the code. Better yet, I hope you carry these patterns into your next robot and machine project. Let’s get started.

For readability, all of the examples run in Python3. The snippets below are truncated for brevity, but the real examples in the repository will work if you’ve got a similar hardware setup.

Continue reading “Software Design Patterns For Real Hardware”

Apple Passwords: They All ‘Just Work’

When the Macintosh was released some thirty-odd years ago, to Steve Jobs’ triumphant return in the late 90s, there was one phrase to describe the simplicity of using a Mac. ‘It Just Works’. Whether this was a reference to the complete lack of games on the Mac (Marathon shoutout, tho) or a statement to the user-friendliness of the Mac, one thing is now apparent. Apple has improved the macOS to such a degree that all passwords just work. That is to say, security on the latest versions of macOS is abysmal, and every few weeks a new bug is reported.

The first such security vulnerability in macOS High Sierra was reported by [Lemi Ergin] on Twitter. Simply, anyone could login as root with an empty password after clicking the login button several times. The steps to reproduce were as simple as opening System Preferences, Clicking the lock to make changes, typing ‘root’ in the username field, and clicking the Unlock button. It should go without saying this is incredibly insecure, and although this is only a local exploit, it’s a mind-numbingly idiotic exploit. This issue was quickly fixed by Apple in the Security Update 2017-001

The most recent password flaw comes in the form of unlocking the App Store preferences that can be unlocked with any password. The steps to reproduce on macOS High Sierra are simply:

  • Click on System Preferences
  • Click on App Store
  • Click the padlock icon
  • Enter your username and any password
  • Click unlock

This issue has been fixed in the beta of macOS 10.13.3, which should be released within a month. The bug does not exist in macOS Sierra version 10.12.6 or earlier.

This is the second bug in macOS in as many months where passwords just work. Or don’t work, depending on how cheeky you want to be. While these bugs have been overshadowed with recent exploits of Intel’s ME and a million blog posts on Meltdown, these are very, very serious bugs that shouldn’t have happened in the first place. And, where there are two, there’s probably more.

We don’t know what’s up with the latest version of the macOS and the password problems, but we are eagerly awaiting the Medium post from a member of the macOS team going over these issues. We hope to see that in a decade or two.

Debouncing The Old-Fashioned Way

If you were given the task of designing a computer at a time when computers weren’t really even a thing, how would you start? How would you take a collection of vacuum tubes, passive components, and a precious few germanium diodes and engineer something to sell to customers looking for an “electronic brain”?

Where there’s a paycheck, there’s a way, and computer archeologist [Ken Shirriff] laid his hands on some old IBM hardware that tells us a lot about how engineers thought in the earliest days of the computer industry. The gear is a pluggable module from IBM, one of hundreds that once went into their Model 705 computer from the mid-1950s. The particular module [Ken] has is a 5-channel contact debouncer, or in Big Blue’s mid-century parlance, a “Contact-Operated Trigger.” It was used to debounce five of the many, many mechanical contacts in the machine, both buttons and relays, and used eight dual triode tubes to do it. Other modules with the exact same footprint formed the flip-flops, inverters, buffers and clocks needed to build a computer.

[Ken]’s analysis of the debouncer is a fascinating look at what was possible with the technology of the day, and the fact that it led to a standardized framework for generic modules that were actually hot-swappable with what essentially was a zero insertion force plug was quite a feat of engineering. And as a bonus, [Ken] and friends actually got the module up in running in the video after the break.

Jonesing for more retro-computer pluggable goodness? Check out this reproduction IBM flip-flop module from the 1940s.

Continue reading “Debouncing The Old-Fashioned Way”

ESP32 Makes Not-So-Smart Lights Smart

Long taken for granted – lights are a basic necessity of modern life. From the time of the first light bulb, we’ve been able to navigate the dark without the use of fire. With the advent of the Internet of Things, it has become somewhat of a requirement to bring a little intelligence to lights before labeling yourself as a hardware hacker. There are many ways to do this; one of the most common being making use of an ESP32. [Luca Dentella] is somewhat of an ESP32 expert, and has written a fantastic tutorial on how to use the chip. The tutorial builds up to making a set of lights controllable from a smartphone web browser as well a light intensity sensor.

Now before you brush this off as simple n0Ob stuff – consider the following. He’s using a Lolin32 lite dev board, a BH1750 light intensity sensor and a relay to interface with mains for the lights. He wrote his own firmware and gets into the gritty details of developing the HTTP interface and flashing code to the correct memory.

We’ve seen a lot of ESP32 projects here at Hackaday, including this most interesting clock. Be sure to check out the video below to see the smart lights in action.

Continue reading “ESP32 Makes Not-So-Smart Lights Smart”

Automating Your Door For $20

We love the doors on Star Trek’s Enterprise. We should have known they were human-operated though because they were too smart. They would wait for people, or fail to open when someone was thrown against them during a fight. [SieuweE] has a much more practical automatic door that he calls ArduDoor.

You might guess from the name it uses an Arduino. It also uses a windshield wiper motor which is perfect since it is high-torque and low speed. You might even be able to pick one up for little or nothing if you frequent the junkyards.

Continue reading “Automating Your Door For $20”

Digital Mouse Trap

Plenty of PC games rely on the mouse for input, and browser games are no exception. Unfortunately though, this isn’t always the most intuitive controller. [Nathan Ramanathan] combined a couple hacks to get the controller he wanted for playing browser games like Agar and Slither. No rodents were harmed in this project.

The games he wanted to dominate were top-down view so there was no need to move the mouse far from the center of the screen. For a more intuitive interface, a Wii nunchuck with its integrated joystick was selected. Nunchucks were notoriously hackable. An Arduino converted the nunchuck’s data into mouse movements. Inside the computer, Autohotkey kept the mouse pointer reined in where it was useful. Autohotkey was a scripting tool for executing keyboard and mouse macros.

The result was a joystick which controlled these browser games exactly the way you would expect a joystick to control a game. Mouse functionality, including standard and fast scrolling, was an added bonus so games like Minecraft aren’t left behind. The ergonomics of the nunchuck make us wonder why it hasn’t been seen in more wearable hacks.

Custom game controllers are no stranger to Hackaday readers. We’ve seen them built from LEGO blocks, automobiles, and even a decorative rug.

Continue reading “Digital Mouse Trap”

3D Printed Hovercraft Takes Flight

Last time we checked in on [Ivan Miranda] he was putting a drill press on the Internet. Lately, he has been trying to 3D print a hovercraft with some success. He made four attempts before arriving at one that works fairly well, as you can see in the video below. We will warn you, though, the screwdriver cam is a bit disconcerting and we suggest waiting at least an hour after you eat to watch.

The starboard impeller broke midway through the test, although with a single impeller it was working pretty well. [Ivan] thinks he can print the impeller frames more strongly to prevent future failures. The design is in Fusion360 and there is enough detail that you can probably duplicate his work if you have the urge. There’s a mount for a headlight and an action camera on the bow.

Continue reading “3D Printed Hovercraft Takes Flight”