Blog Posts

Audio Spectrum Analyzer LED Matrix

Nick Metchalfe built his own audio spectrum analyzer that produces a detailed picture of what you are listing to in real time, showing the changing spectrum of live input signals up to 16 kHz.  By using 2 16×32 LED matrixes, the spectrum displays 64 bands.

This video show the spectrum analyzer in action.

Nick says that the Teensy Audio Library is at the heart of the design, providing audio capture and high resolution FFT routines. Audio frequency data is scaled and binned into logarithmic frequency response groupings and is plotted using a custom fast display driver into a spectrum that approximates the human auditory response for a balanced visual aesthetic.

Nick says that the Teensy Audio Library is at the heart of the design, providing audio capture and high resolution FFT routines. Audio frequency data is scaled and binned into logarithmic frequency response groupings and is plotted using a custom fast display driver into a spectrum that approximates the human auditory response for a balanced visual aesthetic.

He’s posted his spectrum analyzer code on GitHub.

Box of Clicky Light Awesomeness

Jeremy Gilbert made an awesome clicky toy.  The goal of the project was to create a toy that is fun to use, be tactile, light up, and make fun and satisfying noises.

After looking at different options to get the right “clicky-ness”, a 5V relay was used.  Jeremy discovered that you get get louder clicks if you overdrive the voltage.  While this probably isn’t so good for the relay, he felt that since the actual duty cycle is so short it was worth the risk.

The clicky box of awesomeness is  field programmable so that when new suggestions come up during user acceptance testing (performed by his 3-year old daughter) they can be implemented right away.

The write up on Jeremy’s Hackaday project offers a good narrative of how he approached the challenge of getting the right clicky sound and feel.

 

The Kyub: 3D Feather Touch MIDI Keyboard

Keith Baxter made a hand held MIDI keyboard called The Kyub.  This device using capacitive sensing and has an internal accelerometer for controlling the volume.

This video from their Kickstarter campaign gives a good overview and explanation of how the Kyub works.

This is a pretty cool video demoing the Kyub configured as a set of drum pads.

The software and details about how to build and use the Kyub are available on the Kyub website.

Why APA102 LEDs Have Trouble At 24 MHz

It’s well known long APA102 LEDs strips have have trouble at 24 MHz, usually after 150 to 250 LEDs.  But why?  Here’s my attempt to investigate.

One tempting explanation is signal quality problems due to horribly messy unterminated wiring carrying high speed signals, as in this photo!  But it turned out to be a more fundamental timing problem.

In this test, a Teensy 3.2 runs the FastLED “Cylon” example with this line:

 LEDS.addLeds<APA102,11,13,RGB,DATA_RATE_MHZ(24)>(leds,NUM_LEDS);

NUM_LEDs was set to 160, and I connected a strip of 144.  The oscilloscope traces are the signals which arrive at the end of the 144 LED strip.

First, I set the clock speed to only 2 MHz to see the “normal” waveforms output by the last APA102 LED.

The main thing to observe here is the APA102 output changes its data line (blue) at the falling edge of the clock (red).  You might notice a slight delay from the falling edge of the clock to the change in data, but it’s tiny relative to the slow 2 MHz clock cycle.

At 24 MHz, the delay is much more significant.  In this case I measured approximately 15 ns delay from clock to the data changing.

You might also notice the red trace doesn’t look like the 50% duty cycle SPI clock signal.  I believe this, together with the data delay, is the main cause of APA102 issues on long LED strips.

Here’s another measurement of the clock.

Each APA102 LED is supposed to regenerate the clock signal.  Ideally this is supposed to allow a very long LED strip.  But it appears each APA102 lengthens the clock high time and shortens the clock low time slightly.  This might be internal to the APA102 control chip, or it could be simply due to the clock output driver having a faster fall time than rise time, causing the following APA102 to receive a slightly different clock high time.  Perhaps the APA102 controller chip has a better N-channel transistor for pulling the clock output low than the P-channel transistor for driving it high?

After 144 LEDs, the clock low time on this strip has shrunk from 20.83 ns to approximately 18 ns.

With the data output delayed 15 ns after the falling edge, this leaves only 3 ns before the next APA102 LED captures the data on the rising edge of the clock.  As the strip gets longer, each APA102 reduces the clock low time, until it’s shorter than the clock to data delay.

FastLED defaults to 12 MHz SPI clock for APA102 LEDs on Teensy 3.x, which should allow for several hundred LEDs before this clock duty cycle change becomes a problem.

This test was just one APA102 strip I purchased about a year ago.  The Chinese semiconductor manufacturers making these LEDs have a history of changing the silicon without any notice.  I also only tested at room temperature, using only 1 example program which doesn’t drive the LEDs anywhere near 100% duty cycle (more heating).  I powered the 144 LEDs with 5V from both ends, but didn’t make any measurements of the voltage near the middle of the strip.  Power supply voltage might matter.  In other words, your mileage may vary.

But hopefully this helps with understanding what’s really going on, why short APA102 LED strips work so well with the fast clock speeds, but fail when using very long strips, even though the LEDs are supposed to regenerate the clock and data as they pass it down the strip.

Tachometer Using Photosensor

Elliot Carter published a tutorial on making a photoresistor-based tachometer.

The project came about when he needed to test the top speed of a stepper motor.  After putting it together the project became an important diagnostic tool for a larger project – not only does it test the top speed of stepper motors but it also works as a tool to verify code.

The tachometer measures rotational speed using only simple light sensor with an op-amp comparator circuit.  While many mechanical engineers might cringe at the thought of an op-amp, Elliot’s team found a tutorial that explained them well.

Fast pulse counting with interrupts and why nested priority really helps

A question was recently asked on the forum, how fast can attachInterrupt count pulses.  I did some testing to find out, and made this video.

Turns out Teensy 3.2 can run about 1.25 million interrupts per second.  Teensy 3.6 can do about 2.55 million per second.  But these depend on assigning a top priority to the interrupt, as explained in the video.

Of course, both boards can use a timer to count pulses at very high rates, at least 30 MHz.