MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.21k stars 19.22k forks source link

[BUG] SKR 1.3, neopixel and Marlin 2.0 #13636

Closed DimchikUA closed 5 years ago

DimchikUA commented 5 years ago

Description

For some time I use MKS gen1.3 (atmega 2560) board and marlin 1.1.9 firmware in my 3D printer. In this configuration, the bltouch and neopixel strip are configured and work well. Recently, I decided to switch to the 32 bit platform. I chose the BIGTREETECH-SKR-V1.3 board. This board has only one servo plug and there is no special place where you can connect additional servo or neopixel strip. Nevertheless, I have a lot of empty connectors and assumed that I could add some pin for a neopixel. While I do not really understand what to do. I assume that I can add the necessary pins to the file pins_BIGTREE_SKR_V1.3.h in the servo section, it looks like in the file pins_MKS_SBASE.h and it should work.

// Servo pin
//
#define SERVO0_PIN         P1_23   // J8-3 (low jitter)
#define SERVO1_PIN         P2_12   // J8-4
#define SERVO2_PIN         P2_11   // J8-5
#define SERVO3_PIN         P4_28   // J8-6

But all this is not a bug. Bug further.

Steps to Reproduce

my configuration

platformio.ini env_default = LPC1768

Marlin\Configuration.h ... #define MOTHERBOARD BOARD_BIGTREE_SKR_V1_3 ... #define BLTOUCH

#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)
  #define NEOPIXEL_PIN    4        // LED driving pin on motherboard 4 => D4 (EXP2-5 on Printrboard) / 30 => PC7 (EXP3-13 on Rumba)
  #define NEOPIXEL_PIXELS 38       // Number of LEDs in the strip
  //#define NEOPIXEL_IS_SEQUENTIAL   // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
  #define NEOPIXEL_BRIGHTNESS 200  // Initial brightness (0-255)
  #define NEOPIXEL_STARTUP_TEST  // Cycle through colors at startup
#endif

Expected behavior: I expect that with this configuration there should be a compilation error, because the SKR-1.3 board does not have a special pin for neopixel

Actual behavior: In fact, the firmware is compiled without any errors, it is not clear which pin is assigned to the neopixel strip. I guess this is a bug.

Additional Information

If you comment out #define NEOPIXEL_LED, the firmware still compiles normally.

Configuration.zip

p3p commented 5 years ago

While pin 4 is not a correct pin number for LPC based boards that need to use PX_XX style pin identifiers, the integer value of 4 is still a valid pin index, the PX_XX style just hides the real value. 4 is probably the same as P0_04 as long as it has no extra features available. We can't catch all configuration errors, sometimes we just have to trust the user to change the pin id to one that makes sense on the board they are using.

As a side note although you may have lots of free pins, makes sure they do not have any other things connected to them on the board (pullup resistors, filter circuits, etc) if you want to use the pin with a neopixel.

SISLANGER commented 5 years ago

@DimchikUA did you get this sorted, I need to find a way for neopixel also

DimchikUA commented 5 years ago

I used pin P1_27, he is not busy with me. But neopixel does not work from 3.3v. need a solution, such as https://images.app.goo.gl/RqvVrfQXfY9x1Q176 or https://images.app.goo.gl/kg6uTDYtzqn5PR1a8

SISLANGER commented 5 years ago

Good to know

On 1 May 2019, at 10:17, DimchikUA notifications@github.com wrote:

I used pin P1_27, he is not busy with me. But neopixel does not work from 3.3v. need a solution, such as https://images.app.goo.gl/RqvVrfQXfY9x1Q176 or https://images.app.goo.gl/kg6uTDYtzqn5PR1a8

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 5 years ago

P1_27 is normally the Y- (Y limit switch) on the SKR 1.3 board, so don't forget to not use Y- limit switch connector for your Y limit switch. It also has a filter network on it before the pin, an RC filter (0.1uF and I can't remember the resistor value)..

SISLANGER commented 5 years ago

Thank you

On 1 May 2019, at 13:25, doggyfan notifications@github.com wrote:

P1_27 is normally the Y- (Y limit switch) on the SKR 1.3 board, so don't forget to not use Y- limit switch connector for your Y limit switch. It also has a file network on it before the pin, an RC filter (0.1uF and I can't remember the resistor value)..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

DimchikUA commented 5 years ago

I use y+ limit switch and y- is free. That's what I used.

jmdearras commented 5 years ago

Looking at the neopixel library, it does not appear it supports the LPC1768.

jmdearras commented 5 years ago

I used pin P1_27, he is not busy with me. But neopixel does not work from 3.3v. need a solution, such as https://images.app.goo.gl/RqvVrfQXfY9x1Q176 or https://images.app.goo.gl/kg6uTDYtzqn5PR1a8

does it work with a level shifter?

p3p commented 5 years ago

@DimchikUA

But neopixel does not work from 3.3v. need a solution

3.3v is above the state transition for 5.0 logic so it should work in most conditions, I know I run my neopixels on 3.3v logic level pins.

@jmdearras

it does not appear it supports the LPC1768.

my fork that is used in LPC176x builds does

jmdearras commented 5 years ago

@DimchikUA

But neopixel does not work from 3.3v. need a solution

3.3v is above the state transition for 5.0 logic so it should work in most conditions, I know I run my neopixels on 3.3v logic level pins.

@jmdearras

it does not appear it supports the LPC1768.

my fork that is used in LPC176x builds does

you have it working on the LPC176x? Is your fork different from the main one? I have tried on my SKRV1.3 with no luck. Compiles OK.

p3p commented 5 years ago

yes it works for LPC176x, my fork is used by the Marlin LPC176x build, as long as the pin doesn't have any other filters, pullups etc on the board it should just work, I don't have a SKR 1.3 to test on, but on Re-ARM and SBase it works on quite a few pins.

jmdearras commented 5 years ago

Thanks!

ghost commented 5 years ago

yes it works for LPC176x, my fork is used by the Marlin LPC176x build, as long as the pin doesn't have any other filters, pullups etc on the board it should just work, I don't have a SKR 1.3 to test on, but on Re-ARM and SBase it works on quite a few pins.

oooo, I wonder what other other interesting differences/changes you've made p3p ? anything nice ?

DimchikUA commented 5 years ago

Безымянный Datasheet ws2812 The datasheet for ws2812 says that the signal input should be 0.7 of the supply voltage. Based on this 0.7 * 5V = 3.5V. It can be seen that 3.3v is not enough for the circuit to work. For everything to work, you can use the level converter, but you can cheat and lower the ribbon supply voltage a little bit, but then the brightness will be lower. Using a diode in the tape will provide a small drop in the supply voltage of the first LED and the circuit will work. The first LED will issue a control signal to the next diode with a voltage equal to its power supply. So everything will work.

I have not connected my strip yet. And I can not say that it works on pin P1_27. I looked at the scheme of SKR-1.3 and I think that P1_27 is not the best idea, since it has a RC filter. Безымянный1 SKR-V1.3-SCH.pdf This will distort the outgoing signal. You need to either remove the capacitor and resistor (10K), or look for another pin. I will most likely use unoccupied pins with E1 plugs like EN/STP/Dir, or UART plugs from Z, E0 or E1. They are not yet occupied and do not have filters.

p3p commented 5 years ago

Afraid I just add LPC176x support using my Arduino framework that Marlin runs on, I haven't pushed it upstream as my Arduino framework api hasnt stableised enough yet. (I probably could really but I control what libraries Marlin uses for LPC build so it doesn't matter)

@DimchikUA Practically speaking my Neopixel strips all work with an LPC176x 3.3v logic level with a clean 5.0v supply, Theoretically speaky as you said the spec says they shouldn't.

jmdearras commented 5 years ago

Afraid I just add LPC176x support using my Arduino framework that Marlin runs on, I haven't pushed it upstream as my Arduino framework api hasnt stableised enough yet. (I probably could really but I control what libraries Marlin uses for LPC build so it doesn't matter)

Does this mean the main branch does not yet support the LPC176x?

p3p commented 5 years ago

Does this mean the main branch does not yet support the LPC176x?

Of the Neopixel library? yes it doesn't have LPC176x support I didn't push it upstream, but that isn't used by Marlin for LPC176x builds so it doesn't matter. Marlin bugfix-2.0.x has LPC176x support for neopixel without any modification .. other than enabling the feature and setting a appropriate pin for your board in the main config.

jmdearras commented 5 years ago

Does this mean the main branch does not yet support the LPC176x?

Of the Neopixel library? yes it doesn't have LPC176x support I didn't push it upstream, but that isn't used by Marlin for LPC176x builds so it doesn't matter. Marlin bugfix-2.0.x has LPC176x support for neopixel without any modification .. other than enabling the feature and setting a appropriate pin for your board in the main config.

OK, this stream has been a little confusing to me. You are saying the Marlin 2.0.x main branch supports neopixels on the LPC1768 now? Thanks.

everything-tech-related commented 5 years ago

I'm new to coding etc. But I'm getting Adafruit_Neopixel.h directory or file cant be found.

I have neopixel installed plus platformio...had everything working on1.1.9 arduino. Help

SISLANGER commented 5 years ago

@codycato in PlatformIO click on the alien in the first column somewhere I’d update library’s give that a go.

everything-tech-related commented 5 years ago

Everything is up to date. I tried Pin p1_27 etc still no luck

SISLANGER commented 5 years ago

@codycato Your in luck give me 5 minutes

SISLANGER commented 5 years ago

@codycato Adafruit_Neopixel.h directory or file cant be found. this is down to platformio

Screenshot 2019-05-26 at 04 47 19
SISLANGER commented 5 years ago

under project task in the left column at the very bottom will be update project libraries click on that then once that's done click on rebuild intelligence index

SISLANGER commented 5 years ago

Once that's all ok This is how I just got mine to work https://www.makenvape.uk/3d-printing/3d-printing-guides/skr-v1-3-neopixel-bltouch/

everything-tech-related commented 5 years ago

Found the problem...Adafruit_NeoPixel has to be under lib_deps inside platformio.ini

saranloyolite commented 5 years ago

@SISLANGER I tried your guide but it's not working. I even tried removing the BLTouch and disabled it in Marlin. Still no luck! Any advice? Thanks in advance!

SISLANGER commented 5 years ago

@saranloyolite what exactly is not working

saranloyolite commented 5 years ago

@saranloyolite what exactly is not working

Both the Neopixels and the Bl touch are not working.

I followed the instructions on your guide, wired up the Neopixel(ws2812b - 20 LEDs) to an external 5V PSU with common ground to the SKR and connected them to the servo pins. (double checked if 5V, ground, and signal are wired right and checked if the strip works with a nodeMCU).

Following are the code changes:

  1. Configuration.h

    define NEOPIXEL_LED

    if ENABLED(NEOPIXEL_LED)

    define NEOPIXEL_TYPE NEO_GRB + NEO_KHZ800

    define NEOPIXEL_PIN P2_00

    //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE //#define NEOPIXEL2_PIN 5

    define NEOPIXEL_PIXELS 20

    define NEOPIXEL_IS_SEQUENTIAL

    define NEOPIXEL_BRIGHTNESS 200

    define NEOPIXEL_STARTUP_TEST

    //#define NEOPIXEL_BKGD_LED_INDEX 0 //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 }

    endif

  2. Configuration_adv.h

    define LED_CONTROL_MENU

    if ENABLED(LED_CONTROL_MENU)

    define LED_COLOR_PRESETS

    if ENABLED(LED_COLOR_PRESETS)

    define LED_USER_PRESET_RED 255

    define LED_USER_PRESET_GREEN 255

    define LED_USER_PRESET_BLUE 255

    define LED_USER_PRESET_WHITE 255

    define LED_USER_PRESET_BRIGHTNESS 255

    define LED_USER_PRESET_STARTUP

    endif

    endif

Connected the BL Touch to Zmax pins.

Following are the code changes:

  1. pins_BIGTREE_SKR_V1.3h to:

    define SERVO0_PIN P1_24

  2. Congifuration.h

    define BLTOUCH

  3. Configuration_adv.h

    if ENABLED(BLTOUCH)

    //#define BLTOUCH_FORCE_SW_MODE

    define BLTOUCH_DELAY 200

    define BLTOUCH_SET_5V_MODE

    //#define BLTOUCH_FORCE_MODE_SET //#define BLTOUCH_HS_MODE //#define BLTOUCH_LCD_VOLTAGE_MENU

    endif // BLTOUCH

Compiled and uploaded the firmware, and the BL touch is going on an erratic stow and deploy cycle and the neopixels don't light up even after I turned it on from the LCD menu.

PS: I am on the latest Marlin bugfix 2.0 (downloaded it on 2019 09 01)

And idea what might be going wrong?

SISLANGER commented 5 years ago

@saranloyolite

replace #define NEOPIXEL_TYPE NEO_GRB + NEO_KHZ800 with #define NEOPIXEL_TYPE NEO_GRB

If no luck with P1_24 some have had issues try

define SERVO0_PIN P1_26 and move cables to the Y Max

Disable below for the moment I found I didn't need it, and caused some issues. //#define BLTOUCH_SET_5V_MODE

saranloyolite commented 5 years ago

@SISLANGER

I tried with #define NEOPIXEL_TYPE NEO_GRB at first but didn't work and after reading through the adafruit neopixel library I added the NEO_KHZ800. Doesn't seem to make any difference.

Shall try BL Touch with Y max pin with 5V mode undefined and get back to you. Hopefully, that would work. Even then I can't seem to understand why the neopixels are not working from PIN2_00.

SISLANGER commented 5 years ago

neopixel library part is already done by Marlin so just the NEO_GRB is required.

Try disabling #define NEOPIXEL_IS_SEQUENTIAL I know It made me keep thinking it was not working when it was at least while testing.

Also here is my configuration.h part (striped down) see if you can spot things, ensure servo is on at bottom may help as well.

//#define RGB_LED //#define RGBW_LED

if EITHER(RGB_LED, RGBW_LED)

//#define RGB_LED_R_PIN 34 //#define RGB_LED_G_PIN 43 //#define RGB_LED_B_PIN 35 //#define RGB_LED_W_PIN -1

endif

// 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)

define NEOPIXEL_PIN P2_00 // LED driving pin

define NEOPIXEL_PIXELS 77 // Number of LEDs in the strip

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

define NEOPIXEL_BRIGHTNESS 255 // 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 0 // Index of the LED to use //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W

endif

if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)

define PRINTER_EVENT_LEDS

endif

define NUM_SERVOS 1 // Servo index starts with 0 for M280 command

define SERVO_DELAY { 300 }

saranloyolite commented 5 years ago

@SISLANGER

OMG! #define NUM_SERVOS 1 did the trick! Yaay! The neopixels are working now! Thanks a ton!

But the BL Touch is still randomly deploying and stowing!! Homing and bed leveling works, but it keeps randomly stowing and deploying! I am scared it will destroy the Bl Tocuh!! Any thoughts on this?

SISLANGER commented 5 years ago

Double check the wiring, also pull out the switch cable from Y is it still doing it?

SISLANGER commented 5 years ago

check the orientation of the GND SIGNAL IN THE Y MAX

saranloyolite commented 5 years ago

The wiring is correct 5V, GND and SIGNAL. I tried with the X MAX and Z max pins as well and the same problem. I was scared that mt BL Touch was damaged in some way so switched it back to the servo pin and the problem went away! This looks like some interference on the Endstop MAX pins!! :((

SISLANGER commented 5 years ago

I had that at the very beginning, with one of the machines, trying to remember what it was.

saranloyolite commented 5 years ago

Oh, okay that's a relief! Do let me know when you remember. Really appreciate all the support, man!

In the meanwhile I shall tinker around with it a bit more and see if I can sort this out! Shall post if it works. :)

SISLANGER commented 5 years ago

I have you checked the Z-min cable orientation and set correctly in Marlin

SISLANGER commented 5 years ago

define ENDSTOPPULLUPS

if DISABLED(ENDSTOPPULLUPS)

// Disable ENDSTOPPULLUPS to set pullups individually //#define ENDSTOPPULLUP_XMAX //#define ENDSTOPPULLUP_YMAX //#define ENDSTOPPULLUP_ZMAX //#define ENDSTOPPULLUP_XMIN //#define ENDSTOPPULLUP_YMIN //#define ENDSTOPPULLUP_ZMIN //#define ENDSTOPPULLUP_ZMIN_PROBE

endif

// Enable pulldown for all endstops to prevent a floating state //#define ENDSTOPPULLDOWNS

if DISABLED(ENDSTOPPULLDOWNS)

// Disable ENDSTOPPULLDOWNS to set pulldowns individually //#define ENDSTOPPULLDOWN_XMAX //#define ENDSTOPPULLDOWN_YMAX //#define ENDSTOPPULLDOWN_ZMAX //#define ENDSTOPPULLDOWN_XMIN //#define ENDSTOPPULLDOWN_YMIN //#define ENDSTOPPULLDOWN_ZMIN //#define ENDSTOPPULLDOWN_ZMIN_PROBE

endif

define Z_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.

define Z_MIN_PROBE_ENDSTOP_INVERTING true // set to true to invert the logic of the probe.

define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

define Z_MIN_PROBE_PIN P1_25 // Z_MIN_PIN

define BLTOUCH

MAKE SURE

define Z_SAFE_HOMING is enabled

SISLANGER commented 5 years ago

Sorry meant double check Y-Max orientation

saranloyolite commented 5 years ago

define ENDSTOPPULLUPS

if DISABLED(ENDSTOPPULLUPS)

// Disable ENDSTOPPULLUPS to set pullups individually //#define ENDSTOPPULLUP_XMAX //#define ENDSTOPPULLUP_YMAX //#define ENDSTOPPULLUP_ZMAX //#define ENDSTOPPULLUP_XMIN //#define ENDSTOPPULLUP_YMIN //#define ENDSTOPPULLUP_ZMIN //#define ENDSTOPPULLUP_ZMIN_PROBE

endif

// Enable pulldown for all endstops to prevent a floating state //#define ENDSTOPPULLDOWNS

if DISABLED(ENDSTOPPULLDOWNS)

// Disable ENDSTOPPULLDOWNS to set pulldowns individually //#define ENDSTOPPULLDOWN_XMAX //#define ENDSTOPPULLDOWN_YMAX //#define ENDSTOPPULLDOWN_ZMAX //#define ENDSTOPPULLDOWN_XMIN //#define ENDSTOPPULLDOWN_YMIN //#define ENDSTOPPULLDOWN_ZMIN //#define ENDSTOPPULLDOWN_ZMIN_PROBE

endif

define Z_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.

define Z_MIN_PROBE_ENDSTOP_INVERTING true // set to true to invert the logic of the probe.

define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

define Z_MIN_PROBE_PIN P1_25 // Z_MIN_PIN

define BLTOUCH

MAKE SURE

define Z_SAFE_HOMING is enabled

Yes, all of the Marlin configurations seems perfect!

I hadnt defined the #define Z_MIN_PROBE_PIN P1_25 // Z_MIN_PIN. Defined it now and still the problem persists! :(

saranloyolite commented 5 years ago

Sorry meant double check Y-Max orientation

Y MAX orientation is also fine. I have cross-checked with the pinout diagram as well!

saranloyolite commented 5 years ago

Also, this might be a stupid question, but I was going through this post where the ZMAX pins are proposed to be used to drive the Neopixels! Link: https://reprap.org/forum/read.php?1,855543 Will this work?

SISLANGER commented 5 years ago

Make sure with everything connected that you use the M502, followed by M500, followed by M501, then in menu reset BLTOUCH

SISLANGER commented 5 years ago

Z_MAX was unreliable for me, colours wouldn't always match, never quite right for me.

saranloyolite commented 5 years ago

Make sure with everything connected that you use the M502, followed by M500, followed by M501, then in menu reset BLTOUCH

Did this, no luck still :( Dont think this is going to work for me!

Z_MAX was unreliable for me, colours wouldn't always match, never quite right for me.

The neopixels dont even light up for me when I connect to Z_MAX!!

jmdearras commented 5 years ago

maybe I missed it, but the endstop pins on the SKR1.3 have a cap on the PCB that must be removed for neopixels to work

On Mon, Sep 2, 2019 at 12:54 PM saranloyolite notifications@github.com wrote:

Make sure with everything connected that you use the M502, followed by M500, followed by M501, then in menu reset BLTOUCH

Did this, no luck still :( Dont think this is going to work for me!

Z_MAX was unreliable for me, colours wouldn't always match, never quite right for me.

The neopixels dont even light up for me when I connect to Z_MAX!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/13636?email_source=notifications&email_token=AAESZCJCWG3GMJBZIIQBF2LQHVANJA5CNFSM4HEVC6Z2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5WIBHQ#issuecomment-527204510, or mute the thread https://github.com/notifications/unsubscribe-auth/AAESZCNGNQGLUFU7CPGLI3LQHVANJANCNFSM4HEVC6ZQ .

SISLANGER commented 5 years ago

@saranloyolite do you have #define SOFT_PWM_DITHER enabled if so disable that