These Bit Twiddling Tricks Will Make Your Coworkers Hate You

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.

Discussions of bit math are great opportunities to revisit Wikipedia’s superb illustrations

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.

The page contains a variety of nifty tricks. Interview content like counting set bits makes an early appearance.  There’s more esoteric content like this trick for interleaving the bits in two u16’s into a single u32, or rounding up to the next power of two by casting floats. This author has only been forced to turn to Bit Twiddling Hacks on one occasion: to sign extend the output from an unfortunately designed sensor with unusual length registers.

Next time you need to perform an operation with bitmatch, check out Bit Twiddling Hacks. Have you ever needed it in production? How did you use it? We’d love to hear about it in the comments.

Fluorescence Microscope On A Hacker’s Budget

Some of biology’s most visually striking images come from fluorescence microscopes. Their brilliant colors on black look like a neon sign from an empty highway. A brand new fluorescence microscope is beyond a hacker’s budget and even beyond some labs’, but there are ways to upgrade an entry-level scope for the cost of a few cups of coffee. [Justin Atkin] of The Thought Emporium published a scope hacking video which can also be seen below. He is becoming a reputed scope modder.

This video assumes a couple of things for the $10 price tag. The first premise is that you already have a scope, a camera adapter, and a camera capable of shooting long exposures. The second premise is that you are willing to break the seals and open the scope to make some reversible mods. Since you are reading Hackaday, maybe that is a given.

The premise is simple compared to the build, which is not rocket surgery, the light source from below illuminates the subject like a raver, and the filter removes any light that isn’t spectacular before it gets to the camera.

Continue reading “Fluorescence Microscope On A Hacker’s Budget”

Shape Shifting Structures Work With Magnets

In The Dark Knight, Lucius Fox shows Bruce Wayne a neat bit of memory weave fabric. In its resting state, it is a light, flexible material, but when an electrical current is applied, it pops into a pre-programmed shape. That shape could be a tent or a bat-themed paraglider. Science has not caught up to Hollywood in this regard, but the concept has been demonstrated in a material which increases its rigidity up to 318% within one second when placed in a magnetic field. Those numbers do not mean a lot by themselves, but increasing rigidity in a reversible, non-chemical way is noteworthy.

The high-level explanation is that hollow tubes are 3D printed and filled with magnetorheological fluid which becomes more viscous in the presence of a magnet because the ferrous suspended particles bunch up to form chains instead of sliding over one another. Imagine a bike tire filled with gel, and when you need a little extra traction the tire becomes softer, but when you are cruising on a paved trail, the tire becomes as hard as a train wheel to reduce friction. That could be darn handy in more places than building a fast bike.

See Cells In A New Light With A DIY Fluorescence Microscope

Ever since a Dutch businessman peered into the microscopic world through his brass and glass contraption in the 1600s, microscopy has had a long, rich history of DIY innovation. This DIY fluorescence microscope is another step along that DIY path that might just open up a powerful imaging technique to amateur scientists and biohackers.

In fluorescence microscopy, cells are treated with various fluorescent dyes that can be excited with light at one wavelength and emit light at another. But as [Jonathan Bumstead] points out, fluorescence microscopes are generally priced out of the range of biohackers. His homebrew scope levels the playing field a bit. The trick is to use 3D-printed parts to kit out commonly available digital cameras – a USB microscope, a DSLR, or even a smartphone camera. Excitation is provided by a ring of Nexopixel LEDs, while a movable rack holds a filter that blocks the excitation wavelength but allows the emission wavelength to pass through to the camera. He demonstrates the technique by staining some threads with fluorescent ink from a highlighter marker and placing them on a sheet of tissue paper; in conventional bright-field mode, the threads all but disappear into the background, but jump right out under fluorescence.

Ith’s true that the optics are not exactly lab quality, and the microscope is currently only set up to do reflectance imaging as opposed to the more typical transmissive mode where the light passes through the sample. That’s an easy fix, though, and reflectance mode is still useful. We’ve seen fluorescence microscopy get quite complex before, but this simple scope might be enough to get a biohacker started.

Continue reading “See Cells In A New Light With A DIY Fluorescence Microscope”

Disabling GM’s Manual Skip Shift

shift

GM, in an effort to make their cars slightly more eco friendly, added a feature that puts your car in 4th gear when cruising along in 1st under certain conditions. This is apparently despised by many owners. I is despised so much, that you can buy a commercial product to disable it. That product costs between $20 and $40. Jalopnik has posted a simple solution to disable this feature for under $7 .  All you need is a replacement plug and a resistor. It’s really pretty simple.