In the embedded world, twiddling a few bits is expected behavior. Firmware is far enough down the stack that the author may care about the number of bits and bytes used, or needs to work with registers directly to make the machine dance. Usually these operations are confined to the typical shifting and masking but sometimes a problem calls for more exotic solutions. If you need to descend down these dark depths you invariably come across the classic Bit Twiddling Hacks collected by [Sean Eron Anderson]. Here be dragons.
Bit Twiddling Hacks is exactly as described; a page full of snippets and suggestions for how to perform all manner of bit math in convenient or efficient ways. To our surprise upon reading the disclaimer at the top of the page, [Sean] observes that so many people have used the contents of the page that it’s effectively all been thoroughly tested. Considering how esoteric some of the snippets are we’d love to know how the darkest corners found use.
Most Hackaday readers are familiar with computers from the 70s and 80s, but what about ones even older than that? The Digi Comp 1 was a commercially available computer from the 1960s that actually cost less than a modern-day microcontroller. The catch? It was mechanical rather than electrical. Thanks to retro-wizard [Mike Gardi], now anyone can build a replica of one.
Admittedly the Digi Comp 1 was more of a toy than a tool, but it was still a working computer. It contained three flip-flops (memory) and had a lever that acted as a clock, allowing the user to perform boolean operations and some addition and subtraction. Certainly not advanced, but interesting nonetheless. [Mike]’s version of the Digi Comp 1 has an extra bit when compared to the original and includes some other upgrades, but largely remains faithful to the original design.
[Laura Kampf] found a new use for an old Zippo lighter by turning it into a carrier for her screwdriver bits. There are several multitools out there which can accept standard screwdriver bits. The problem is carrying those bits around. Leaving a few bits in your pocket is a recipe for pocket holes and missing bits.
[Laura’s] solution uses her old Zippo lighter. All she needs is the case, the lighter element itself can be saved for another project. A block of aluminum is cut and sanded down to a friction fit. Laura uses a band saw and bench sander for this. The aluminum block is then drilled out to fit four bits. Small neodymium magnets are taped into the holes with double-sided tape. These magnets retain the bits, ensuring none will fall out when the lighter is opened.
This is a great quick project and an excellent way to carry four bits. We’re curious if the second set of holes (and a shorter bar) could expand this carrier to 8 bits – 4 on top and 4 on the bottom. [Laura] noticed this too, but decided to keep the build simple with 4 bits.
If you are curious about reading all the bits on a DVD, [tmbinc] has devised a hardware hack that uses a Pioneer DVD drive with leads soldered onto it and a Cypress FX2 microcontroller board to grab the flow of bits and push them over USB2.0. My favorite part of this tutorial is when you slow the spinning DVD down very slightly with your finger with a scope hooked up over what you believe to be the raw data stream from the disk. If the data rate slows when you physically slow down the disk, you probably are grabbing data from the correct pin. [tmbinc] even put together a software tool to process the resulting raw DVD data.