Samsung’s Leap Month Bug Teaches Not To Skimp On Testing

Date and time handling is hard, that’s an ugly truth about software development we’ll all learn the hard way one day. Sure, it might seem like some trivial everyday thing that you can easily implement yourself without relying on a third-party library. I mean, it’s basically just adding seconds on top of one another, roll them over to minutes, and from there keep rolling to hours, days, months, up until you hit the years. Throw in the occasional extra day every fourth February, and you’re good to go, right?

Well, obviously not. Assuming you thought about leap years in the first place — which sadly isn’t a given — there are a few exceptions that for instance cause the years 1900 and 2100 to be regular years, while the year 2000 was still a leap year. And then there’s leap seconds, which occur irregularly. But there are still more gotchas lying in wait. Case in point: back in May, a faulty lunar leap month handling in the Chinese calendar turned Samsung phones all over China into bricks. And while you may not plan to ever add support for non-Gregorian calendars to your own project, it’s just one more example of unanticipated peculiarities gone wild. Except, Samsung did everything right here.

So what happened?

Continue reading “Samsung’s Leap Month Bug Teaches Not To Skimp On Testing”

Error Correction Of 3D Printers

From the very first RepRaps to the newest and latest printers off the Makerbot assembly line, nearly every consumer 3D printer has one significant shortcoming: it cannot recover from missed steps, slipped belts, or overheating stepper drivers. Although these are fairly rare problems, it does happen and is purely a product of the closed open-loop control system used in 3D printer firmware.

[Chris Barr] has come up with a rather clever solution to this problem. He’s designed a system that will detect and correct problems with the mechanics of 3D printers. It’s technically not a closed-loop control system, but it does allow him to get the absolute position of a nozzle on the build plate, detects error states, and can automatically calculate the number of motor steps per millimeter. It’s also much simpler than other closed loop control systems we’ve seen in the past, requiring only a few bits and bobs attached to the axes and to the printer controller board.

[Chris]’ system uses a magnetic encoding strip, a single chip, and a little bit of support circuitry. It’s actually not that much different from the moving axis on a desktop inkjet printer. It’s not closed loop, though; the firmware hack is only a ‘basic error correction’ that moves the nozzle back to where it should be. Although this is somewhat of a kludge, it is much simpler than refactoring the entire printer firmware.

In the video below, [Chris] demonstrates his solution for error correcting the printer by jerking his axis around during a print. The nozzle miraculously returns to where it should be, producing a usable part.

Continue reading “Error Correction Of 3D Printers”

Error Detection And Correction: Reed-Solomon, Convolution And Trellis Diagrams

Transferring data without error when there is a lot of background noise is a challenge. Dr. Claude E. Shannon in 1948 provided guidance with his theory addressing the capacity of a communications channel in the presence of noise. His work quickly spread beyond communications into other fields. Even other aspects of computer use were impacted. An example is the transfer of data from a storage medium, like a hard drive or CD-ROM. These media and their sensors are not 100% reliable so errors occur. Just as Shannon’s work defines communication channel capacity it defines the transfer rate from a media surface to the read head.

Shannon told us how much could be passed through a channel but didn’t say how. Since 1948 a lot of research effort went into accurately detecting errors and correcting them. Error correction codes (ECC) add extra bits to messages, but their cost pays off in their ability to work around errors. For instance, without ECC the two Voyager spacecraft, now leaving our solar system, would be unable to phone home with the information they’ve gathered because noise would overwhelm their signals. Typically in hardware, like memory, error correction is referred to as ECC. In communications, the term forward error correction (FEC) is used.

Robust communication, or data transfer, is a combination of fancy software and tricky signal processing. I’m going to focus on the software side in this article. You may find some of these techniques useful in communicating data among your devices. While I’ll be using the term communications keep in mind this is applicable to transferring data in general.

Continue reading “Error Detection And Correction: Reed-Solomon, Convolution And Trellis Diagrams”