Hey all, relatively new here... I've been tinkering with the FastLED library a bit.

(Peter Brydon) #1

Hey all, relatively new here… I’ve been tinkering with the FastLED library a bit. It works fine with my old Arduino UNO with a strip of WS2812B LED’s I bought.

Though now I recently got one of the Bluefruit feather M0’s with the 48 Mhz Cortex M0 processor. Primarily because the bluetooth sounded like it would be awesome to work in with those LED’s.

Sadly, everything I’ve been trying to do for the past week has failed. I got logic level converters and messed around with them… They seem to be working, but I was only able to (for whatever reason) get them to properly blink a standard RGB LED on the high side with an analogWrite(PIN,255) call. Once I try to setup the fastLED (the same way that works for the arduino) I can’t even get a single WS2812B LED to light up even with the level converter.

I have the 5V power for the LED’s connected to the USB on my board. The boards ground is shared with the 5V ground. I put the 3V output from the bluefruit to the LV pin of the leveler and the ground goes to the common ground. Same is done for the high side. LV1 gets a signal pin and HV1 carries it to the LED signal wire. (with less than 500 Ohms worth of resistors). It’s a pretty simple circuit so I doubt I’m doing anything wrong there. Except that tidbit about the analogWrite call did worry me a bit. (Setting it to “HIGH” using either analog or digitalWrite functions ended up with a very weakly lit analog LED.)

I’m kind-of at a loss here. Though I suppose this particular product (regardless of the M0 support for Arduino since this is Adafruit) may not be supported by FastLED. Would anyone have any constructive advice for this? Should I try to find a way to bit-bang things myself? It would have been great of the NeoPixel DMA library I found worked but I don’t know if that’s even properly signalling them through the level converter…

(Yves BAZIN) #2

My guess is the following as ws2812b requires precise Timing I think the Fastled lib needs an update for your processor speed. But it’s only a guess

(Daniel Garcia) #3

You don’t mention what level converter you are trying to use.

Also, The asm code used for ws2812 style output on the M0 is clock speed independent (which is to say, at compile time it tunes to the clock speed set by the F_CPU define - there isn’t separate code written for each clock frequency.

(Peter Brydon) #4

@Daniel_Garcia Perhaps the F_CPU isn’t being set by the compiler for my adafruit or it doesn’t recognize my board? The level converters are 3.3v to 5.0v so I thought it’d go without saying. It’s a naive test I know but I used an LED to test it with a simple blink on off sketch. It seemed to work fine. Perhaps I’ll borrow my roommates multimeter to be sure.

Key thing though, this is an adafruit bluefruit feather M0 and not the Arduino. So if FastLED relies on an Arduino define or something specific to that board and/or we don’t have support for the board I’m using then that would explain it. Which is my suspicion anyway. The ZeroDMA library I tried to use may not be working because the signal strength the MOSI pin runs to the output pin might not be high enough is my guess, too. (If I powered the LEDs from a 3.3V supply maybe this would be a non-issue but the strand I’m using for prototyping needs a stronger power supply and I’d rather not cut the LEDs.)

Anyway most of my programming experience is in C and I still haven’t been able to get eclipse to work properly with the Arduino libraries or I’d have an easier time I’m sure. I really want to use it but for whatever reason it’s very obstinate. Plus the cross compilation settings can be a pain to resolve I’m sure. I’ll get it eventually if I just stop trying to go too fast though.

And if it really matters to know exactly… The level converters in particular are below but I’m fairly sure unless all ten of them are bad this shouldn’t be an issue. They’re soldered properly etc.

I’m going to try buying some adafruit stuff next. Texas instruments is top notch I hear and that’s who they get the stuff from so if those don’t work something is seriously wrong. I just have to wait on this stuff a bit longer than I’d like.

It’d just suck a little to keep spending money on stuff that won’t work. I’m sure I’ll figure it out eventually if there’s not something obvious or a #define I need to add or some hack to add the board to the library.

I’d try to write the assembly myself to roll my own bit banging library. I’m just not sure how to translate the pin number on the board to the assembly instructions to power it on or off and so on. It’s easy to find the manual for the cortex MO I’m using in particular and get a list of assembly instructions for it but I don’t want to screw up the board if I don’t know what pins on the CPU are tied into what pin on the board. (Since I haven’t manually compiled Arduino sketches yet I probably won’t get to use a gcc -S anytime soon.)

(Daniel Garcia) #5

That shifter likely can’t keep up with the ws2812 data timings - see https://happyinmotion.com/?p=1247 - and if F_CPU isn’t being set properly all sorts of other things will get thrown off as well, I highly doubt F_CPU isn’t being set properly.

(Peter Brydon) #6

@Yves_BAZIN Judging from the comment Daniel made it’s plausible the CPU speed define may not be a part of my compilation process or something else could be going wrong. Perhaps it doesn’t recognize that I’m using a cortex MO processor or has the pin maps confused with the Arduino M0 so it translates things incorrectly. I could learn the library if I had more time but work keeps me busy 13 hours a day on average and I haven’t used anything but gnu99 standard C and python in ages.

It’s what I get for hoping something would be easy. haha. But for tinkerings sake maybe I can get a serial connection to my Uno and just use the bluefruit I bought as a “Bluetooth shield” so I can still have fun playing with it until I figure out how to do it all on the Bluefruit M0. Save me some frustration and still let me have a little fun in the meantime. Then if I ever want to make something other than a prototype… Well, yeah. Better solve this first. ^^;

(Yves BAZIN) #7

@Peter_Brydon if @Daniel_Garcia says that F_CPU is set correctly I tend to believe him as he wrote that code. To put this hypothesis to rest add Serial.print(F_CPU) in your setup function and we will be fixed. It also seems that the level shifter used may not be the suited for this as they can’t switch fast enough. Maybe try without them first.

(Daniel Garcia) #8

Peter - if F_CPU wasn’t defined, then the code wouldn’t compile at all. If you are building using Arduino, Adafruit has supplied platform definition files which ensure that, among other things, F_CPU is getting set properly - and the feather m0 is supported by FastLED.

(there is, however, a reason why I don’t officially test/support building in non-arduino environments – I don’t want to mess with the myriad of ways people can misconfigure things if, for example, they’re building in eclipse)

The more likely issue is that you are using a level shifter that for all intents and purposes is messing up your data signal to the WS2812. It doesn’t matter if it worked for a “bare” led, a bare led just either has a connection and is on, or it doesn’t and it’s off. The WS2812 signal depends on timings, and if your level shifter is messing with those timings, then the WS2812 is going to likely not react (or react somewhat randomly).

(Peter Brydon) #9

@Daniel_Garcia I understand that much about how it works. That’s part of why I mentioned buying some of the adafruit levelers. If I can assume that with the right leveler FastLED shouldn’t have an issue with my system that’s all fine and dandy for me. I can use the M0 as a “bluetooth shield” in a sense I’m sure until one of the adafruit logic level shifters come in. I just didn’t know the library.

Also as far as non-arduino environments go… I mean, honestly their IDE is terrible compared to what I use at work. I can’t highlight things and push F3 to go to their declarations or check call hierarchies? What is this, Auschwitz? I like a development environment that I can work with that helps accelerate things for me. If I end up having to compile my code with the Arduino IDE because I futzed up something in Eclipse so be it but they’re all just commands in a shell script in the end and some environment variables anyway. I’ll figure it out. It’s just a cross compilation and then feeding the output file to a programmer.

Whether it works or not for actually compiling/uploading programs to the board I’m happy to have gotten eclipse working just now. It will make it far easier for me to learn the libraries I’m using when I can highlight variables/types and chase them around instead of using grep like a scrub.

(I have a BSc in computer science and work as a software developer. I’m just far more practiced in C and Python. I’ll probably never use python for embedded but it’s useful for generic stuff . Haven’t used C++ in years, but the compilation commands I see from the Arduino IDE aren’t alien to me.)

(Daniel Garcia) #10

The feather m0 as sold by Adafruit is supported — as for the IDE, the vast vast vast majority of the folks who use the library are coming in from the Arduino/hobby side of things - it does have the advantage of a certain consistency which takes out a bunch of variables in trying to support folks with “why doesn’t this work/compile” requests. Personally I use a different set of editors and just use the Arduino IDE for compile/upload to the dozen or so different hardware platforms I build for/test with…

(Peter Brydon) #11

Anyway, thanks for clearing that up a bit. I was worried that perhaps the library wasn’t compatible with the feather M0 and hoped someone who knew more about it could tell if that was likely. I over complicate things and was really frustrated after trying to get things to work for… Eight hours or more. And after buying a bunch of logic level shifters that given the vote of confidence in the FastLED library… Likely don’t shift fast enough for the LED"s.

Hopefully whenever snail mail comes with the TI levelers from Adafruit I’ll be victorious with my experimentation. :slight_smile:

(Peter Brydon) #12

Just posting an update, after trying a bunch of different things it seems the unequivocal winner was https://learn.adafruit.com/neopixels-on-raspberry-pi/wiring using the 74AHCT125’s.

The other logic level shifters I kept trying (even the TXB0108) were all insufficient or I was too stupid to get them working.

Thank you for your help.