Packing Decimal Numbers Easily

While desktop computers have tons of computing power and storage, some small CPUs don’t have a lot of space to store things. What’s more is some CPUs don’t do multiplication and division very well. Same can be said for FPGAs. So suppose we are going to grab a bunch of three-digit decimal numbers from, say, a serial port. We want to store as many as we can, and we don’t want to do a lot of math because we can’t, it is slow, or perhaps it keeps our processor awake longer and we want to sleep to conserve power. We want a way to pack the numbers as close to the theoretical maximum as we can but with little or no math.

The simple approach is to store the numbers as ASCII. Great for processing since they are probably in ASCII already. If they aren’t, you just add 30 hex to each digit and you are done. That’s awful for storage space, though, since we can store 999 in 10 bits if it were binary and now we are using 24 bits! Storing in binary isn’t a good option, if you play by our rules, by the way. You need to multiply by 10 and 100 (or 10 twice) to get the encoding. Granted, you can change that to two shifts and an add (8x+2x=10x) but there’s no easy way to do the division you’ll have to do for the decode.

Of course, there’s no reason we can’t just store decimal digits. That’s call binary coded decimal or BCD and that has some advantages, too. It is pretty easy to do math on BCD numbers and you don’t get rounding problems. Some CPUs even have specific instructions for BCD manipulation. However, three digits will require 12 bits. That’s better than 24, we agree. But it isn’t as good as that theoretical maximum. After all, if you think about it, you could store 16 distinct codes in 4 bits, and we are storing only 10, so that 6 positions lost. Multiply that by 3 and you are wasting 18 codes.

But there is a way to hit that ten-bit target without doing any math. Its called DPD or densely packed decimal. You can convert three decimal digits into ten bits and then back again with no real math at all. You could implement it with a small lookup table or just do some very simple multiplexer-style logic which means it is cheap and easy to implement in software or onboard an FPGA.

Continue reading “Packing Decimal Numbers Easily”

Katrina Nguyen Automates Her Mice

When embarking on a career in the life sciences, it seems like the choice of which model organism to study has more than a little to do with how it fits into the researcher’s life. I once had a professor who studied lobsters, ostensibly because they are a great model for many questions in cell biology; in actuality, he just really liked to eat lobster. Another colleague I worked with studied salt transport in shark rectal glands, not because he particularly liked harvesting said glands — makes the sharks a tad grumpy — but because he really liked spending each summer on the beach.

Not everyone gets to pick a fun or delicious model organism, though, and most biologists have had to deal with the rats and mice at some point. It’s hard to believe how needy these creatures can be in terms of care and feeding, and doubly so when feeding is part of the data you’re trying to collect from them. Graduate student Katrina Nguyen learned this the hard way, but rather than let her life be controlled by a bunch of rodents, she hacked a solution that not only improved her life, but also improved her science. She kindly dropped by the Hackaday Superconference to tell us all about how she automated her research.

Continue reading “Katrina Nguyen Automates Her Mice”

Linux Fu: Controlling The Terminal

A Linux terminal has a lot more features than the TeleType of yore. On a TeleType, text spews out and scrolls up and is gone forever. A real terminal can use escape characters to do navigate around and emulate most of what you like about GUIs. However, doing this at the lowest level is a chore and limits portability. Luckily, all the hard work has already been done.

First, there’s a large database of terminal capabilities available for you to use: terminfo.  And in addition, there’s a high-level library called curses or ncurses that simplifies writing programs to control the terminal display. Digging deep into every nook and cranny of ncurses could take years. Instead, I’m going to talk about using a program that comes with ncurses to control the terminal, called tput. Using these two commands, you can figure out what kind of terminal you’re dealing with, and then manipulate it nearly to your heart’s content. Let’s get started!

Continue reading “Linux Fu: Controlling The Terminal”

Bill Gross On Why Your Startup Will Succeed

Bill Gross is one of the great heros when it comes to technology incubators. Twenty years ago, he founded Idealab, a business whose business plan is to create more businesses. This started out with just a handful of companies in 1996, and has since gone on to found 150 companies, that have collectively raised three and a half billion dollars. Out of these companies, more than half have either gone through successful IPOs and acquisitions, or are currently operating. That investment has generated a 13.5x return, and created more than 10,000 jobs.

Obviously, when you want to talk about what goes into a successful startup, Bill Gross is the person you want to talk to. We were happy to have him Keynote the Hackaday Superconference this year, and the lessons he shared might surprise you, especially if you’re interested in starting your own business.

Continue reading “Bill Gross On Why Your Startup Will Succeed”

Designing Space-Rated PCBs

We’ve reduced printed circuit board design to practice so much that we hardly give a thought to the details anymore. It’s so easy to bang out a design, send it to a fab house, and have ten boards in your hands in no time at all. All the design complexities are largely hidden from us, abstracted down to a few checkboxes on the vendor’s website.

There’s no doubt that making professional PCB design tools available to the hobbyist has been a net benefit, but there a downside. Not every PCB design can be boiled down to the “one from column A, one from column B” approach. There are plenty of applications where stock materials and manufacturing techniques just won’t cut it. PCBs designed to operate in space is one such application, and while few of us will ever be lucky enough to have a widget blasted to infinity and beyond, learning what’s behind space-rated PCBs is pretty interesting.

Continue reading “Designing Space-Rated PCBs”

Hackaday Links Column Banner

Hackaday Links: November 25, 2018

Bad Obsession Motorsport have been stuffing the engine and suspension from a 4WD Celica into an old Mini since forever. It is a wonderful homage to Police Squad and some of the best machining and fabrication you’ll see on YouTube. The latest episode tackled the electrical system and how to drive an alternator in an extremely cramped engine bay. The solution was a strange flex-shaft confabulation, and now the Bad Obsession Motorsport guys have a video on how they attached an alternator to a car where no alternator should go. It’s forty minutes of machining, go watch it.

Last Friday was Black Friday, and that means it’s time to CONSUME CONSUME CONSUME. Tindie’s having a sale right now, so check that out.

I’m the future of autonomous flight! This week, I got a market research survey in my email from Uber, wanting me to give my thoughts on autonomous ridesharing VTOL aircraft. Uber’s current plan for ridesharing small aircraft involves buying whatever Embraer comes up with (Uber is not developing their own aircraft), not having pilots (this will never get past the FAA), and turning a random parking lot in LA into the busiest airport in the world (by aircraft movements, which again is something that will never get past the FAA). Needless to say, this is criminally dumb, and I’m more than happy to give my thoughts. Below are the relevant screencaps of the survey:

The crux of this survey is basic market research; how much would I pay for a VTOL ride sharing service versus buying a new (autonomous) car versus using an autonomous Uber. You’ve also got a Likert scale thingy asking me if I’m comfortable flying in a battery-powered aircraft. Protip: I highly doubt anyone given this survey has flown in a battery-powered aircraft. Proprotip: the easiest way to screw up the scoring for a Likert scale is to answer ‘1’ for the first question, ‘2’ for the second, etc., and wrap back around to ‘1’ for the sixth question.

Don’t worry, though: I answered all the questions truthfully, but Uber Air will never happen. The FAA won’t let this one fly, and no company will ever carry passengers without a licensed pilot on board.

Fail Of The Week: Did My Laser Cutter Tube Really Burn Out?

All the cool kids are doing it these days, or more like for many years now: you can get a laser cutter for a song if you don’t mind doing your own repairs and upgrades — you know, being a hacker. The downside is that some failures can really ruin your day. This is what [Erich Styger] encountered with his cutter that is just a bit more than a year old. This Fail of the Week looks at the mysterious death of a CO2 laser tube.

This is the infamous K40 laser cutter. Our own [Adam Fabio] just took one on a couple of months back and [Erich] even references Hackaday coverage of the K40 Whisperer project as what pushed him over the edge to make the purchase. We’ve followed his blog as he acquired the cutter and made upgrades along the way, but after an estimated 500 hours of use, a horrible teeth-gnashing screech sprung forth from the machine. [Erich’s] reaction was to hit the e-stop; that’s certainly why it’s there.

Chasing down the problem is a story well-told, but as is often the case with these FotW articles, in the end what caused the failure is not entirely known. We’d love to hear what you think about it in the comments below.

The investigation began at the power supply for the laser, but that didn’t yield any answers. Next he moved to the tube itself, noticing that the wire connection to the tube’s anode wasn’t soldered. The anode is an unknown material he suspects to be graphite and he found a video showing the “soldering” process for connecting a wire. (We added quotes to that as the video he linked doesn’t actually solder anything but the wrapped wire strands themselves.) The solution he found is a great tip to take away from the story. It’s a socket by TE Connectivity to which he soldered the wire. Assuming it’s power rated for the task, and won’t fall off during normal operation, this is a great way to do it.

But we digress. Even with the connection made, the old tube had to be replaced with a new one. It’s also notable that the portion of that anode inside the bad tube is orange in color when a new tube would be black like the part on the outside. Does this hint at why that tube died, and could this have been avoided? If you have insight, help us learn from this failure by leaving a comment below.