Rewriting WS2812 Driver Libraries for Optimization

ws2812_compared

We like [Tim's] drive for improvement. He wrote a WS2812 driver library that works with AVR and ARM Cortex-M0 microcontrollers, but he wasn’t satisfied with how much of the controller’s resources the library used to simply output the required timing signal for these LED modules. When he set out to build version 2.0, he dug much deeper than just optimizing his own code.

We remember [Tim] from his project reverse engineering a candle flicker LED. This time, he’s done more reverse engineering by comparing the actual timing performance of the WS2812(B) module with its published specs. He learned that although several timing aspects require precision, others can be fudged a little bit. To figure out which ones, [Tim] used an ATtiny85 as a signal-generator and monitored performance results with a Saleae logic analyzer. Of course, to even talk about these advances you need to know something about the timing scheme, so [Tim] provides a quick run-through of the protocol as part of his write-up.

Click the top link to read his findings and how he used them to write the new library, which is stored in his GitHub repository.

Saleae Logic Analyzer knockoff hacking

Despite what this module says on the case, it’s certainly not official Saleae Logic Analyzer hardware. [Jack Andrews] picked up this Chinese knockoff on eBay for about $18. When plugged into the computer the Saleae software picks it up as the official hardware. But [Jack] has seen other knockoffs which have a jumper to select between Saleae cloning and USBee cloning so he found a way to switch software with this dongle.

He pulled the board out of the case and discovered a Cypress CY7C68013A microcontroller on a poorly-soldered board (imagine that). This is an 8051-compatible processor that includes USB functionality. There’s also an EEPROM on the bottom of the board which stores the VID/PID pair identifying it as Saleae Logic hardware. The trick to getting this working with the USBee software is to change that pair. [Jack] managed to do this without an external programmer. He uninstalled the Saleae driver and installed a Cypress driver. Then he wrote a bit of code for the CY7C68013A to rewrite the EEPROM and flashed it via the USB connection. Now the dongle enumerates as USBee Logic Analyzer hardware.

Turn a logic analyzer into a signal generator using only software

One thing we learned by watching [Alton Brown] on all of those Good Eats episodes is that a multitasker is way better than a unitasker. [Joost] is thinking along the same lines by taking a fantastic tool and adding a useful function to it. His software project turns a USB Saleae Logic Analyzer into a signal generator.

There are already a multitude of reasons to own one of these fantastic tools. But the ability to use it to generate up to 8 channels of PWM signals is a welcome addition. It is capable of producing frequencies from 1Hz up to 1MHz at a sample rate of 4 MHz. It uses the original SDK and doesn’t require any changes to the hardware (we would’ve thought new firmware was necessary, but happily that’s not the case). The one caveat is that right now this only works with Windows machines running the .NET version 3.5 or higher. It looks like an MSI installer package is all that’s available for download so the thoughts of easily porting this to other operating systems have been dashed unless [Joost] decides to share his source code.

Diving deep into the Game Boy LCD protocol

[Craig] wanted to make the original Game Boy LCD screen do his bidding so he sniffed out the data protocol that it uses. We were amused when he mentions that there’s an army of people out there looking to build pointless crap as part of a hobby. Guilty. And he goes on to outline why this LCD screen is a great resource for hobbiests.

As you can see in the pinout above, it uses 5V logic, with a 4 MHz data clock. These traits are both very friendly to a wide range if inexpensive microcontrollers. If you know how to address the display it should be very easy to use. Furthermore, the low pin count is thanks the to a 4-shade grayscale screen, limiting the data pins to just two. [Craig] hooked up his Saleae Logic probe to capture communications and walks us through what he discovered. During this process he proved to himself that he had figured out the protocol by exporting captured data from the logic probe and reassembling it into an image on his computer.

Tools: Saleae Logic, logic analyzer

cover1

A logic analyzer records bus communications between two chips. If you’ve ever had a problem getting two chips to talk, or wanted to reverse engineer a protocol, a logic analyzer is the tool you need to spy on the bus.

The Logic is a USB logic analyzer with eight channels and sampling rates up to 24MHz. Among hobby-level logic analyzers, the Logic has a good mix of features and decent sampling rates. We’ve been following Joe Garrison’s work on the Logic for a long time. If you’ve ever considered bringing a product to market, you can learn a lot from Joe’s blog that documents his development process.

When it debuted, the Logic was so popular that it was hard to buy one. It’s now widely available, and Saleae gave us one to try. Read our review below.

[Read more...]

Follow

Get every new post delivered to your Inbox.

Join 98,524 other followers