I recently bought a very low cost electronic dice kit on an impulse. Assembling it was good retro-fun for a while. The circuit design is was purely 70ies style: A CD4017, a NE555 and a couple of transistors. Of course, this got me thinking: How would it be done today in a most efficient way? Of course this means using a microcontroller, and, of course this means using as few resources as possible. Will an ATiny10 with 3 I/Os pins do?
A couple of weeks ago I reported about a new type of RGB-LED with integrated controller, the APA102. One of the interesting new features of this device is a two-wire SPI interface instead of the proprietary one-wire protocol of the more common WS2812. Many microcontrollers have hardware SPI functions, which allow easy control of these LEDs, as opposed to timing critical bit banging. But it turned out this was not the end of the story. As pointed out by Bernd in a comment, there is some discrepancy between the datasheet and the actual behavior of the devices when it comes to the “end frame”. Reason enough to subject the APA102 to more scrutiny.
The diagram below summarizes the APA102 protocol as found in the data sheet.
Recently, I encountered an interesting problem: How do you measure the length of a WS2812 programmable RGB-LED string electronically? That is, just using signals that are already there. This can be useful if you want a LED controller to adapt its pattern according to the string that is connected to it, or simply for diagnostic reasons.
WS2812 strings are usually controlled by using one serial output signal only. The LEDs are daisy chained and you simply push out data for all LEDs without any feedback. If there are fewer LEDs on the string, the data for the last LEDs is ignored.
An intuitive approach to counting the number of LEDs is to feed the output of the last LED of the string back into the microcontroller. According to the WS2812 protocol, the output of LED number n is low until data for n+1 LEDs has been pushed to the string. To count the number of LEDs, data is fed to the string until a rising transition is detected on the output. A relatively easy way to implement this is by using a pin change interrupt on the AVR, or a similar feature on other microcontrollers.
While this works nicely, it has the disadvantage of requiring another wire. Can we do it without introducing any additional connections? Continue reading “Measuring the length of a WS2812 string”
After clones and variations of the venerable WS2812, there finally seems to be a new RGB-LED with integrated controller that actually improves on several characteristics: The APA102, also known as “Superled”. There are two versions on the market, the APA102 and the APA102C, as shown below.
The WS2812 RGB LEDs with integrated controller are fairly successful devices that come in a variety of packages. Recently, similar devices by other manufacturers started to appear.
I managed to get my hands on a few samples of LEDs with PD9823 controller, courtesy of Soldering Sunday, and was able to subject them to more scrutiny. The manufacturer of the IC seems to be “BaiCheng”. You can find it in several LEDs with different package types. There is a single page “datasheet”, linked here, but little else is known to me.
The given timing values are, again, completely different from any other device. So are these really compatible to the WS2812? Only one way to find out: I used the same setup to extract the timing as described earlier for the WS2812. You can find the results below.
Possibly the smallestest ATtiny85 based ‘duino derivative.
Recently, Olimex anncounced the Olimexino 85s, claimed to be the “World’s smallest Arduino ever“. Now, that looks like a challenge. I guess it is about time to show off what has been on my desk since some time last year: The Nanite, pictured below.
I recently received an external USB battery as a promotional gift (see image below). While I always thought of these as a superfluous gimmick, I realized that these devices could be quite useful as mobile power source for various projects. After all, dealing with lithium ion batteries in your own projects can be dangerous and you need additional circuitry to ensure charging and voltage conversion.
External USB batteries can be charged with a normal micro-b USB charger and are supposed to output stabilized 5V at above 1A. And they come fully integrated at a price point where it is difficult to get even the battery alone. See Aliexpress for example and many others. Since there is little reason to trust hardware at this price point, I decided to tear the device down to see whether all the necessary parts are there.
Atmels AVR ATtiny10 are surprisingly powerful devices that come in an extremely tiny SOT23 package with only 6 pins. The have 1kb of flash, 32 bytes of SRAM and use the reduced AVR core which only supports 16 instead of 32 register. It seems like Atmels idea of these devices is to use them as an advanced blinker, and to replace tiny logic circuits. But other people have shown that much more is possible. For example the noiseplug (video), a chiptune player, and a Simon Says game.
I previously used the ATtiny10 in the TinyTouchbutton, a touchbutton controlled light with WS2812 LEDs. This time I aimed higher: Is it possible to turn the ATtiny10 into a USB compatible device? My goal was to implement a subset of the little-wire functionality to control a WS2812 LED by USB. This takes 3 I/O lines, which is exactly the number of free pins on the ATtiny10.
Littlewire supports several functions to control WS2812 LEDs on arbitrary I/O ports. I simplified this to only supporting a single LED on a specific pin, however still retained protocol compatibility. This means that all the little-wire host-programs still work. The finished device can, for example, be used as an RGB indicator LED similar to the Blink(1).
My test setup is shown below. The ATtiny10 is almost the smallest part of the circuit. There are some discrete components on the rear-side of all PCBs, so do not be surprised about missing decoupling capacitors, zener diodes and resistors.
Starting with V2.0, Micronucleus is going to use an interrupt free modification of the software USB implementation V-USB. This provides significant benefits for the bootloader, as it is not necessary anymore to patch the interrupt vector of the user program. A surprising side effect was a speed up of the V-USB data transmission, which may also be helpful in other applications. Here, I try to give a rough overview about the meandering work that led to this achievement.
Previous versions of Micronucleus (and also the Trinket bootloader) use an ingenious mechanism devised by Louis of embedded creations to patch the interrupt vector transparently to the user program. Although this approach works very well, it still adds a lot of complexity to the bootloader, will add a couple of cycles of interrupt delay, and carries the risk of breaking the user program in a few rare cases. Removing this burden allows for a drastic reduction in code size and improved robustness. Continue reading “Interrupt free V-USB”
I previously reported on reverse engineering a candle flicker LED. My approach was to extract the “flicker” pattern from the input current variation and to deduce the algorithm from statistical analysis.
Reverse engineering the controller chip
Of course there is another, more involved, approach. And that is to reverse engineer the circuit directly from the die. Andrew Zonenberg from Siliconpr0n decapsulated and imaged the controller chip from one of my LEDs. You can find his report here.
He managed to obtain very high-resolution optical microscopy images of the top-level metal. It turns out that the controller chip is manufactured in a relatively coarse CMOS process with one metal layer and 1-2 µm resolution. This is 1980ies technology. But of course, that is all that is needed for a circuit as simple as a flicker-LED.