bigtreetech / BIGTREETECH-SKR-mini-E3

BIGTREETECH SKR-mini-E3 motherboard is a ultra-quiet, low-power, high-quality 3D printing machine control board. It is launched by the 3D printing team of Shenzhen BIGTREE technology co., LTD. This board is specially tailored for Ender 3 printer, perfectly replacing the original Ender3 printer motherboard.
1.97k stars 1.97k forks source link

v1.2 RGB Neopixel leds working #123

Open raymond-w2 opened 4 years ago

raymond-w2 commented 4 years ago

After some trial and error I got my RGB leds to work. Strip of 59 leds powered by an external wall powersupply . https://imgur.com/a/lEBhNcu

Sharing my solution here as I spent way to much time on this...

On the WS2812B Din the normal resistor should be 300 to 500 Ohm. I changed it up to 12580 Ohm (several resistors in series) and now the signal is coming trough :)

/edit After a bit mote tinkering best value was 14K Ohm

Software settings :

Platformio.ini https://github.com/bigtreetech/Adafruit_NeoPixel

Configuration.h `// Support for Adafruit Neopixel LED driver

define NEOPIXEL_LED

if ENABLED(NEOPIXEL_LED)

//#define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) //edit by RaymondW

define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800)

define NEOPIXEL_PIN PC7 // LED driving pin

//Changed by RaymondW

define NEOPIXEL_PIXELS 59 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used

define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.

define NEOPIXEL_BRIGHTNESS 55 // Initial brightness (0-255)

define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup

// Use a single Neopixel LED for static (background) lighting

define NEOPIXEL_BKGD_LED_INDEX 25 // Index of the LED to use

define NEOPIXEL_BKGD_COLOR { 0, 0, 0, 255 } // R, G, B, W

endif

/**

joewmorrissey commented 4 years ago

I gave up also, mainly because I believe a small percentage of E3's have a defect. Myself and quite a few others have experienced a bizarre issue where the X axis runs hotter / louder than normal, and skips steps, fixed by a power cycle. It's always X, hence the belief in a defect.

I've since switched to the SKR 1.4, which I've been a lot happier with. As a bonus, it has perfectly working Neopixel support because the LPC1768 CPU is natively supported by Adafruit's official library.

Yeah I’m about to just run it from the pi as I have everything else working. Just grates at me seeing people getting it working and not able to get mine after damn near $75 bucks in crap plus hours of time lol.

Scope666 commented 4 years ago

I gave up also, mainly because I believe a small percentage of E3's have a defect. Myself and quite a few others have experienced a bizarre issue where the X axis runs hotter / louder than normal, and skips steps, fixed by a power cycle. It's always X, hence the belief in a defect. I've since switched to the SKR 1.4, which I've been a lot happier with. As a bonus, it has perfectly working Neopixel support because the LPC1768 CPU is natively supported by Adafruit's official library.

Yeah I’m about to just run it from the pi as I have everything else working. Just grates at me seeing people getting it working and not able to get mine after damn near $75 bucks in crap plus hours of time lol.

At one point I had it really close with Demitrix's version, but then just a normal Marlin update somehow screwed it up. It's just not worth the effort, RGB Status is WAY better and every color is spot on.

demitrix commented 4 years ago

Same issue when I was trying. Flash the same firmware twice and get different results. That was the beginning of my giving up. Since then I just went to white LEDs the heat up cycle and everything is so short the RGB just seemed silly.

NameOfTheDragon commented 4 years ago

I gave up also, mainly because I believe a small percentage of E3's have a defect. Myself and quite a few others have experienced a bizarre issue where the X axis runs hotter / louder than normal, and skips steps, fixed by a power cycle.

I've seen that happen if the mains power is turn off but the USB cable not unplugged (e.g. if you are using OctoPi / OctoPrint). The USB power keeps the board alive and when mains comes back it doesn't get a power on reset and that turns the board into a zombie. Check you are not back-powering the board Vcc somehow.

Scope666 commented 4 years ago

I gave up also, mainly because I believe a small percentage of E3's have a defect. Myself and quite a few others have experienced a bizarre issue where the X axis runs hotter / louder than normal, and skips steps, fixed by a power cycle.

I've seen that happen if the mains power is turn off but the USB cable not unplugged (e.g. if you are using OctoPi / OctoPrint). The USB power keeps the board alive and when mains comes back it doesn't get a power on reset and that turns the board into a zombie. Check you are not back-powering the board Vcc somehow.

Good theory but this wasn't it. I learned VERY early that all E3 boards have to have the power pin of the USB cable taped off, since it doesn't have the power selector jumper like the full size SKRs do.

NameOfTheDragon commented 4 years ago

Yeah i have a 3b setup in a dual rear case with the e3, so based upon your config, i would just move the signal to pin 24 on the GPIO on the PI and toss on the plugin? I got it, it connects to pin 19 by default which is GPIO 10, and i didn't modify marlin.

Correct, the GPIO 10, the one that doesn't need Octoprint running as root, per his docs. It's a really awesome plugin, it does print status across the top showing percentage, and you can even pick the color that goes against the white.

Also the Rainbow Cycle effect is really cool, something you can't do with Marlin.

Sorry for the confusion, the Marlin config was if you were going to still try and go that route.

Confusingly, GPIO10 is labelled SPI0/MOSI and pin 19 on the connector, according to some pinout diagrams.

Scope666 commented 4 years ago

Yeah, pretty sure it's this one:

image

NameOfTheDragon commented 4 years ago

I actually gave up for now, at least until I see someone improve the modified NeoPixel library. All I had to do was move the data line over to my Pi, I've been using this which is flawless:

https://plugins.octoprint.org/plugins/rgb_status/

This is actually an excellent workaround. Highly recommended.

In my view, Octoprint/Octopi is far more worthwhile putting effort into if you don't have it and you solve the LED problem "en passant". The LEDs "just work" running from the Pi. I'm using a strip of 7 pixels and the Pi can power those directly, so you can just plug the strip completely into the Pi as long as you don't try to power a silly amount of pixels. Adafruit says to allow 20mA per pixel as a good rule of thumb, so my 7 pixels should only be drawing like 150mA and the official Raspberry Pi PSU has loads of headroom. You can see this working here (the Pi is just off to the left of the printer on a stand with some breadboards, a very temporary configuration).

So I'm not putting any time into fixing my SKR Mini E3. I've given it up as a bad job.

joewmorrissey commented 4 years ago

Yeah it is a joke. Connected up to the Pi today in 5 mins and done. Doesn't give the hot end indication and some of the features, but i mainly just wanted light for telegram to snap pics in the middle of the night.

jwebber23 commented 4 years ago

@joewmorrissey I am using a generic strip of LEDs

The key appears to be to change the NEOPIXEL_TYPE to #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) and add a 15k resistor. I am using the Bigtreetech NEOPIXEL library as per their setup info.

Please comment if you have tried this and not have it work.

Marlin 2.04.4 has the LED indication sorted now when printing from an SD card so my system is all go.....

I am also looking to try it from Octoprint but my Pi 1 is not happy with having plugins installed so that is another challenge..

Scope666 commented 4 years ago

@joewmorrissey I am using a generic strip of LEDs

The key appears to be to change the NEOPIXEL_TYPE to #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) and add a 15k resistor. I am using the Bigtreetech NEOPIXEL library as per their setup info.

Please comment if you have tried this and not have it work.

Marlin 2.04.4 has the LED indication sorted now when printing from an SD card so my system is all go.....

I am also looking to try it from Octoprint but my Pi 1 is not happy with having plugins installed so that is another challenge..

It will sort of work, but the colors will be off, especially if you enable the Marlin feature where the LED's change one by one during heating. BTT's library is WAY off...

jwebber23 commented 4 years ago

I have found the following. The LED's change from Blue to Red as it heats and that works. Changes to White when printing and that works. Changes to Green when finished and that works.

I wanted the Green LED's when finished so i can see it from inside the house as my printer is is my shed. Since the Marlin fix this works so i am happy.

The LED menu when you select the colours also works fine. I am not sure what colours you are finding that are off.

Scope666 commented 4 years ago

I don't use the E3 anymore so keep that in mind, but as demitrix mentioned it was all over the place. There were times where the colors were really close with his modified library, but then I would flash a Marlin update and the colors would break again. I also at times had to set the number of LEDs higher than what I actually had.

jwebber23 commented 4 years ago

I was having the same issues when i first started down this path. Googling brought me to 1/2 way through this thread and i tried the different library and got the colours to sometimes work and not others then i went to the top of the thread and found the 15k resistor suggestion and the #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) and i haven't had an issue since.

I think the resistor plays a bigger part than the timing. There may be other things happening with the pin and its circuit that requires the resistor.

Scope666 commented 4 years ago

Just my 2 cents, but if a 15K resistor is required, it should have been integrated into the board. My SKR 1.4 just works perfectly, no resistor required. The design of the E3 has lots of issues for sure, including weird grounding, lack of USB power jumper, and something is definitely wrong with the X driver circuit.

jwebber23 commented 4 years ago

I certainly agree, using the pin they have setup for it to not work ins't correct. So far that is the only issue i have come across with the board. I am in the process of tying to use a couple of input pins as outputs to control my hotend fan and case fan. It would be nice if they exposed a few more of the pins available to add other functions.

Scope666 commented 4 years ago

You're lucky you haven't run into the X driver issue. Best guess is they had a bad batch...

joewmorrissey commented 4 years ago

@joewmorrissey I am using a generic strip of LEDs

The key appears to be to change the NEOPIXEL_TYPE to #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) and add a 15k resistor. I am using the Bigtreetech NEOPIXEL library as per their setup info.

Please comment if you have tried this and not have it work.

Marlin 2.04.4 has the LED indication sorted now when printing from an SD card so my system is all go.....

I am also looking to try it from Octoprint but my Pi 1 is not happy with having plugins installed so that is another challenge..

Yes i have bought 14k resistors specifically due to the comments near the top of this thread after i couldn't get a signal without. I have the LEDs powered by a buck converter and the signal to the PC7 with a 14k resistor in line and nada, my guess is my board is screwed as i don't get a light at all. Remove the resistor pop it on the PI and voila done. Which is job done in my book. I'm tired of screwing with it much like everyone else it seems. I've got to clean up some of the wiring and then its going back together for the final time, and I'm moving on to other projects.

jwebber23 commented 4 years ago

Yes that is really frustrating having so many issues with a feature they advertise (it is one of the reasons I got the board). With the buck converter there could have been a ground issue.

Which plug in are you using on the pi and is it through octoprint?

joewmorrissey commented 4 years ago

Pin 19 and yes using the RGB status addon linked above by @Scope666 . he helped me get it setup a while ago, but i was stubborn and trying everything to get the stupid SKR board and connectors working but i'm done, its a shit implementation and not worth any more of my time. I get lights while printing and it has some color changes to indicate fails, success.

CommandoreBombardiero commented 4 years ago

Hi, after trying to get my neopixels to work by adjusting number of nops and then learnend that nop on ARM is not necessarily a time-consuming instruction, I started to browse Marlin files in order to find timers implementations and try to implement neopixels using them. Instead I came across file named Delay.h: https://github.com/MarlinFirmware/Marlin/blob/bugfix-2.0.x/Marlin/src/HAL/shared/Delay.h This file contains pretty clever implementation of nanosecond delay based on DWT unit so I decided to give it a try. I modified neopixel library by including Delay.h and replacing nops with DELAY_NS() function as follows:

  if(p & bitMask) {
    // data ONE
    // min: 650 typ: 800 max: 950
    GPIO_SET(pin);
    DELAY_NS(700);  //high
    // min: 300 typ: 450 max: 600
    GPIO_CLEAR(pin);
    DELAY_NS(150);  //low
  } else {
    // data ZERO
    // min: 250  typ: 400 max: 550
    GPIO_SET(pin);
    DELAY_NS(100);  //high
    // data low
    // min: 700 typ: 850 max: 1000
    GPIO_CLEAR(pin);
    DELAY_NS(750);  //low
  }

I needed to adjust short times to be even shorter, but now my LEDs works flawlessly. I'm using WS2812B pixels without any additional resistor on data line.

demitrix commented 4 years ago

@CommandoreBombardiero this is by far the best workaround so far. Excellent work.

Scope666 commented 4 years ago

You should publish your modified fork on GitHub, I'm sure there's plenty of E3 users who would love to finally have accurate control. :) (I've since moved on to the SKR 1.4 or I'd be ALL over this)

CommandoreBombardiero commented 4 years ago

@Scope666 I would like to, but I'm entirely new to github, I've just created account to share my solution and I don't know how to properly include library from Marlin into neopixel file in order for this to work for everyone because neopixel library is usualy downloaded separetly.

Stff0r commented 4 years ago

Thanks @CommandoreBombardiero. I had the problem that all LEDs were just white, but with your modification everything is working fine!

WS2812B strip, no additional resistor in data line.

personthingman2 commented 4 years ago

My neopixels are working beautifully now thanks to the fix from @CommandoreBombardiero, Thanks!

jwebber23 commented 4 years ago

How did you guys get the mod into your marlin build?

CommandoreBombardiero commented 4 years ago

@jwebber23 You can use my fork of BTT neopixel library: https://github.com/CommandoreBombardiero/Adafruit_NeoPixel then all you have to do is to locate Delay.h file in your local copy of Marlin (Marlin 2.0\Marlin\Marlin\src\HAL\shared\Delay.h) and provide full path to this file in line 51 of Adafruit_NeoPixel.cpp

joewmorrissey commented 4 years ago

Love it! Finally full functionality like BTT should have had from the start. Thanks @CommandoreBombardiero I had just given up the other day and plugged them into the PI, so simply had to swap the pin back to the e3 and voila.

JWolfJr commented 4 years ago

I'm sorry, a little on the slow side here! Where does this fork go in Marlin2.0 The main Marlin folder? Also does anything need to be changed in platformio.ini file?

joewmorrissey commented 4 years ago

I'm sorry, a little on the slow side here! Where does this fork go in Marlin2.0 The main Marlin folder? Also does anything need to be changed in platformio.ini file?

I was there with you. Take the link above and add to platformio under libs just like with Demetrix above. And then use the search function to find the adafruit_neopixel.cpp file and then enter the location on your delay.h file

JWolfJr commented 4 years ago

Thanks for getting back, is this right? Add the link above to lib_deps in platformio.ini, then find the .cpp file and add my path to my delay.h file? Sorry to be pain, I'm usually a little more with it. Thank you for holding my hand!!

joewmorrissey commented 4 years ago

Yup exactly you can pull up the delay.h in studio and then right click and copy path. Then go to the .cpp file and paste the path on line 51 just remember to put the path in quotes

JWolfJr commented 4 years ago

I'm using vscode, and after adding the link to lib_deps and try a file search in my workspace. Nothing is found for adafruit_neopixel.cpp. I'm doing something wrong.

joewmorrissey commented 4 years ago

I'm using vscode, and after adding the link to lib_deps and try a file search in my workspace. Nothing is found for adafruit_neopixel.cpp. I'm doing something wrong.

Here is the section from my platformio.ini

[common] default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py build_flags = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants lib_deps = LiquidCrystal TMCStepper@>=0.6.2,<1.0.0 https://github.com/CommandoreBombardiero/Adafruit_NeoPixel U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip Adafruit_MAX31865=https://github.com/adafruit/Adafruit_MAX31865/archive/master.zip LiquidTWI2=https://github.com/lincomatic/LiquidTWI2/archive/master.zip Arduino-L6470=https://github.com/ameyer/Arduino-L6470/archive/0.8.0.zip SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip SailfishRGB_LED=https://github.com/mikeshub/SailfishRGB_LED/archive/master.zip SlowSoftI2CMaster=https://github.com/mikeshub/SlowSoftI2CMaster/archive/master.zip

Then in the left section of vscode studio, click the magnifying glass to search and type adafruit_neopixel.cpp or you can find it in .pio/libdeps/STM32F103RC_bigtree_512K (or whatever env you're using)/adafruit neopixel/ adafruit_neopixel.cpp

change line 51 to look like this:

include "/Users/gameroom/Downloads/Marlin-2.0.x/Marlin/src/HAL/shared/Delay.h"

But make sure your path in in the quotes

JWolfJr commented 4 years ago

Thank you, it's compiling now! When I was trying to search for that file, vscode just kept giving me a no results found. Now I just need to take all the resistors off the data line!!! Are you just using the basic 200 - 500 ohm "ish" range?

joewmorrissey commented 4 years ago

Thank you, it's compiling now! When I was trying to search for that file, vscode just kept giving me a no results found. Now I just need to take all the resistors off the data line!!! Are you just using the basic 200 - 500 ohm "ish" range?

Yeah standard on board level. Once you add the new firmware it’s plug n play.

JWolfJr commented 4 years ago

Cool, thank you again for the help. The search gave me no results, thanks for including the path to the cpp file.

Releece commented 4 years ago

@jwebber23 You can use my fork of BTT neopixel library: https://github.com/CommandoreBombardiero/Adafruit_NeoPixel then all you have to do is to locate Delay.h file in your local copy of Marlin (Marlin 2.0\Marlin\Marlin\src\HAL\shared\Delay.h) and provide full path to this file in line 51 of Adafruit_NeoPixel.cpp

I have done exactly as described by you and @joewmorrissey. Added your fork to lipdeps by putting link to zip in platformio.ini, deleted old neopixel library from lipdebs and let it compile once so your fork would be downloaded. This worked as expected, because when I searched the .cpp and opened it again, I saw the content was changed to that of your fork. So I have added the full link (starting with my drive letter) to delay.h in AdafruitNeopixel.cpp line 51: `#include "C:\Users\SmartPlant\Desktop\3D\Firmware\Marlin-bugfix-2.0.x#17071\Marlin\src\HAL\shared\Delay.h"` saved everything.

I'm given three different errors (5 total) on compilation:

.pio\libdeps\LPC1768\Adafruit NeoPixel\Adafruit_NeoPixel.cpp: In member function 'void Adafruit_NeoPixel::show()': .pio\libdeps\LPC1768\Adafruit NeoPixel\Adafruit_NeoPixel.cpp:1873:9: error: 'gpio_set' was not declared in this scope; did you mean 'LPC176x::gpio_set'? .pio\libdeps\LPC1768\Adafruit NeoPixel\Adafruit_NeoPixel.cpp:1874:9: error: 'time' has not been declared .pio\libdeps\LPC1768\Adafruit NeoPixel\Adafruit_NeoPixel.cpp:1876:9: error: 'gpio_clear' was not declared in this scope; did you mean 'LPC176x::gpio_clear'?

Then another 'time', and another 'gpio_set' error.

When I go to the part of the code giving errors, mouse-over on 'time', shows pop-up with: "name followed by '::' must be a class or namespace name".

Would you have any idea about what could be wrong? Been scratching my head on this for a while...

CommandoreBombardiero commented 4 years ago

@Releece In your compilation errors I can see LPC1768 microcontroller. If you have SKR mini E3 V1.2 board you should have STM32F103RC in your libdeps. Check if you're building your firmware for correct board.

Releece commented 4 years ago

@Releece In your compilation errors I can see LPC1768 microcontroller. If you have SKR mini E3 V1.2 board you should have STM32F103RC in your libdeps. Check if you're building your firmware for correct board.

Oh sorry I completely missed the fact that this issue was only for SKR mini's. I have an SKR1.4 myself, maybe that means my LEDs would have worked from the start? I got here through a Google search on SKR & neopixel, found dimitrex's post on Reddit which led me here. I thought it was a general issue on the BTT boards, long thread hehe.

Strange thing is that after restoring the original Neopixel library in platformio.ini I still can't compile because of the same errors. Just before all this I did actually do a successful build with a tiny LED strip which printer is now running, but didn't test much. Now on to figuring out this black magic, because now I can't build and I have changes to make :/

axg20202 commented 4 years ago

I'd just like to say thanks to all contributors to this thread and particularly to @CommandoreBombardiero, who's fix above worked perfectly for me. Just FYI to others who are trying to get this to work, I am using the DCDC5v add-on board. I am currently only using a strip of 3 LEDs on my hotend. No added resistor, no added capacitor - just plugged straight into the board. Seems to be fine so far. I commented out the line for indexing a single background LED. I also entered the correct number of LEDs in the firmware - I did not need to increase this higher than what is installed. I will now try to add another longer run of LEDs to the top gantry and see if that works.

Taomyn commented 4 years ago

Has anyone got this compiling with Marlin v2.0.5.1 and VSCode (with the Auto Marlin Builder extension)? I have made the same changes as mentioned above (changed the library in platformio,ini and it downloads fine, then changed the .cpp to point at delay.h), also with v2.0.5.0, but I always get this error:

In file included from Marlin\src\feature/leds/leds.h:33:0, from Marlin\src\MarlinCore.cpp:85: Marlin\src\feature/leds/neopixel.h:34:10: fatal error: Adafruit_NeoPixel.h: No such file or directory

JWolfJr commented 4 years ago

It's working great for me, had to use a 280 ohm resistor I believe. I am running Marlin 2.0.5 also. I believe there are multiple adafruit .cpp files. Make sure you included your absolute path in this one, .pio/libdeps/STM32F103RC_bigtree_512K. Hope this helps.

Taomyn commented 4 years ago

@JWolfJr multiple .cpp files? The directions only mentions to change one, the one under .pio\libdeps\STM32F103RC_btt_512K\Adafruit NeoPixel which is downloaded with the URL

Taomyn commented 4 years ago

I missed these errors just after the one I showed before:

***************************************************************************
* Looking for Adafruit_NeoPixel.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_NeoPixel.h"
* Web  > https://platformio.org/lib/search?query=header:Adafruit_NeoPixel.h
*
***************************************************************************

 #include <Adafruit_NeoPixel.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\STM32F103RC_btt_512K\src\src\feature\bedlevel\bedlevel.cpp.o
*** [.pio\build\STM32F103RC_btt_512K\src\src\MarlinCore.cpp.o] Error 1
Taomyn commented 4 years ago

I think I fixed it.

I moved the downloaded fixed "Adafruit NeoPixel" folder from source folder to the .platformio\lib under my profile - I'm using Windows. I then edited the platformio.ini file and removed the URL, put back the "Adafruit NeoPixel" that it replaced, also the ignore of "Adafruit NeoPixel" for the board build I am using, then it compiled cleanly with just one warning.

I won't know for a while whether it will actually work on my Ender 3, but at least this hopefully sorts out the firmware build.

Taomyn commented 4 years ago

Success

image

It's just a 7-led neopixel strip, directly connected to the mini E3's port using its power (jumper changed) - it cycles the colours at start up. I can set them to any colour, varying brightness using M150 codes. No idea about individual led control. I have also enabled them as the "case light", which needed me to dummy the pin variable (used 0).

I've yet to start a print to test the temperature status changes, which I will do when I start re-calibrating everything seeing as I also added an x-axis tensioner, replaced the hotend/mainboard fans.

axg20202 commented 4 years ago

Nice one. I’ve since added an overhead strip like yours, so I now have 3 under my hot end and 14 overhead, linked together as though they were one strip. Took a while to thread the long wiring up to the hot end leds, back from the hot end down to the z motor and back up the left hand upright to the top strip. works perfectly with no resistor or capacitor, but I am using the DCDC5v add on board. A no brainier seeing as it costs peanuts. Temperature related colour change works fine.

Taomyn commented 4 years ago

Temperature related colour change works fine.

Confirmed as well