Hello all, First off, thank you for allowing me into your community.

Hello all,
First off, thank you for allowing me into your community. I was looking for creating a synesthesia project with music tracking LEDs and stumbled upon your library. By the looks of it, this is what I was looking for. I have ordered an Arduino Uno to implement this. However, I had a question and that is related to support on different chips. I have been using an Atmel 89C51RC2 microcontroller for my school project and was planning to implement the glowing leds using this chip. I can see that the libraries have been custom designed for Arduino boards. I was wondering if this can be ported into my Atmel chip? If not, it would be great if you could give me some tips, so that I can try to write my own library. Appreciate any feedback/suggestions. Have a great day ahead!

Thanks
Kaushik Prakash

There are a bunch of things in FastLED that are designed with portability and abstraction in mind - https://github.com/FastLED/FastLED/blob/master/PORTING.md has some beginning notes (the most important thing that needs to be done is pin access needs to be implemented - once you have that, then SPI output can be bitbanged (until you implement hardware SPI support)).

So far, I’ve ported FastLED’s deep internals to the AVR architecture, multiple ARM architectures (from freescale, stm, nordic, nxp), the xtensa architecture (the esp8266, and soon esp32).

Most of FastLED doesn’t rely on anything from the arduino infrastructure (I have some code that falls back to using arduino methods for pin access - and right now FastLED uses the arduino methods millis, micros, delay, and a handful of others - though that’s all easily swapped out over time).

Some tricks/problems with this platform.

Like the PIC, the 80C52 takes multiple clock cycles for 1 machine cycle. 12 in normal mode, 6 in X2 mode. That caps your instruction cycle rate at about 5Mhz compared to the AVR 16Mhz rate - also, far more of the 80C52 instructions take 2-4 cycles than AVR (where most instructions take a single cycle).

You only have 8 registers compared to AVR’s 32, but you’re even more constrained, because all math operations require working with the Accumulator register - which adds extra cycles of moving things in/out of the accumulator.

So, it will take you more instructions to do an equivalent amount of work on the 80C52 as on the AVR, and those individual opcodes may take longer than their AVR counterparts, and you only have 1/3rd the number of instruction cycles per second to play with.

For the most part, this shouldn’t be much of a problem. It just means that most code will run slower than the equivalent code. That’s ok - there’s a version (greatly restricted subset, of course) of FastLED that runs on an Apple II’s 6502 CPU :slight_smile: (Hi, @Mark_Kriegsman !).

If, however, you want to use WS2812 leds (neopixels) - then things start to get ugly. You have exactly 1.25µs to write a single bit out. I had to do some fairly heroic asm gymnastics to make this work on an 8Mhz AVR with no hardware multiply (while keeping the inline dithering/scaling) - there there are only 10 CPU cycles per bit, total. On that atmel chip, however, there’s only 6.25 cycles per bit (let’s call it 7). There are games that I’ve seen people play with abusing UART outputs to sort of drive WS2812 leds, which may be what you’d have to do - but even then, you’d still only have 7 cycles to prepare each byte to be written to the UART (because this hack uses two 8-bit values, one representing a 0 bit and one representing a 1-bit).

Anyway - not saying it’s impossible - it’s quite possible, especially if you stick with 4-wire led chipsets like the APA102 (which use a clock and data line, and can be much freer with their timing) - but know what you’re getting into :slight_smile:

Hmm - actually, there might be a bigger problem for you using the 80C52 - you’ll need to make sure that you can get a C++ compiler, FastLED makes very very very heavy use of C++.

Thanks Daniel for the quick response. Based on your feedback, looks like I had not done enough research about the pitfalls. After going through your suggestions, I guess its going to be tough, and with the timing constraints, I am sure things may not turn out the way I would like to see the end result. Thanks for the suggestions. I guess I will use the Arduino Uno processor to accomplish the glowing leds. I might use 4 leds on a breadboard with the Atmel chip and just perform a basic volume synesthesia where a signal high from a sound sensor can then light up these LEDs. On a related note, can I use Arduino’s FastLED library in a Beagle bone black? I am sure there will be some degree of cross compilation as the pins may not be the same.

Thanks again for all the help.

A typo: Arduino Uno board*

Re: the beaglebone black - not right now. FastLED is designed for running on bare MCU’s in mind (though, some enterprising folks have gotten it working with some RTOS’s out there) - and so the only ARM set of chips that I’m supporting are the cortext-Mx set of chips (M0, M0+, M3, M4, etc…). The beaglebone black is an Axx class arm chip, multi-core, virtual memory, designed for running a full OS like linux. I am interested in playing with the black, at some point, mostly because of it’s PRU - however I haven’t had time to do that yet.

What types of things do you want to do? One nice thing with the increasing range of platforms that FastLED does work on, is that it’s likely there’s a platform out there that’d be a good fit: Want Wifi? Try the ESP8266 or the boards from http://particle.io. Want bluetooth? The NRF51822 (and soon, NRF52) is a nice arm mcu with an embedded bluetooth subsystem. Want performance and ram? The teensy 3.x is a great all around system (though there are other arm based systems becoming available that have even higher clock speeds). Want tiny? FastLED runs on the ATTiny8 (it also runs on the LPC810, which is physically as small as the ATTiny8, but it’s a 32-bit ARM cpu :).

I was thinking of implementing a volume synthesia, where the decibel levels from a music player will make an LED to shine brighter or dim the led. If that’s successful, I would like to implement Chromesthesia, a tonal synthesia, where a particular tone in a music, will light a specific set of leds. That will involve a FFT of the signal. Initially I thought of doing it in my atmel processor, meaning to impress my professor and my girlfriend who always wanted synthesia Christmas lights . SIGH. But then there is always something called as a “Fallback” aka Arduino. And clever minds to prove me wrong. :slight_smile: