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.23k stars 19.22k forks source link

[BUG] Heater A / 0 won't work on Mightyboard RevE #18517

Closed SaschaKP closed 4 years ago

SaschaKP commented 4 years ago

Bug Description

on Mightyboard RevE, with 2.0 bugfix (pulled at 12:30 UTC time, on 02/07/2020) the first heater stopped working, I searched in the code why this could happen, but didn't found anything that could give me that hint, just to avoid misunderstandings, the previous firmware (2.0.0.5, stable one) do work, but in that particular firmware there is a problem with homing axes using a probe, that in the recent one is fixed.

My Configurations

MarlinConfig.zip

Steps to Reproduce

pick up a Replicator1, as you can see in the config, apart from the sensor and different pulley, everything is as the machine requires to be usable, compile and upload, heater 0/A will stop working (the one in the right side) With the previous firmware instead, it will work as normal.

System

Arduino 1.8.13 as avr compiler, if this could be the problem, please advice me, since I've been used to compile using a cross toolchain under linux in an ARM system (but again, this bug don't show if I recompile the old version and upload it as I do with the most recent one).

All the libs are just freshly updated, where possible.

ellensp commented 4 years ago

enable PINS_DEBUGGING in Configuration_adv.h and send a M43, check for pin conflicts on heater pins.

SaschaKP commented 4 years ago

recompiled with that define uncommented and the bug is gone (with a pull, latest commit inside, at 12 UTC time, today), this is the output of the command, and I can't really find any conflicts, will do some more tests later.

SENT: M43
READ: PIN:   0   Port: E0        RXD0                                   protected 
READ: PIN:   1   Port: E1        TXD0                                   protected 
READ: PIN:   2   Port: E4        MAX6675_SS2_PIN                        Output = 1    TIMER3B   PWM:     0    WGM: 1    COM3B: 1    CS: 3    TCCR3A: 1    TCCR3B: 3    TIMSK3: 0  
READ: .                          THERMO_CS2_PIN                         Output = 1    TIMER3B   PWM:     0    WGM: 1    COM3B: 1    CS: 3    TCCR3A: 1    TCCR3B: 3    TIMSK3: 0  
READ: PIN:   3   Port: E5        MAX6675_DO_PIN                         Input  = 0    TIMER3C   PWM:     0    WGM: 1    COM3C: 0    CS: 3    TCCR3A: 1    TCCR3B: 3    TIMSK3: 0  
READ: .                          THERMO_DO_PIN                          Input  = 0    TIMER3C   PWM:     0    WGM: 1    COM3C: 0    CS: 3    TCCR3A: 1    TCCR3B: 3    TIMSK3: 0  
READ: PIN:   4   Port: G5        BEEPER_PIN                             Output = 0    TIMER0B   PWM:   128    WGM: 3    COM0B: 3    CS: 3    TCCR0A: 3    TCCR0B: 3    TIMSK0: 5   compare interrupt enabled   overflow interrupt enabled  
READ: PIN:   5   Port: E3        MAX6675_SS_PIN                         Output = 1    TIMER3A   PWM:     0    WGM: 1    COM3A: 1    CS: 3    TCCR3A: 1    TCCR3B: 3    TIMSK3: 0  
READ: .                          THERMO_CS1_PIN                         Output = 1    TIMER3A   PWM:     0    WGM: 1    COM3A: 1    CS: 3    TCCR3A: 1    TCCR3B: 3    TIMSK3: 0  
READ: PIN:   6   Port: H3        HEATER_0_PIN                           protected 
READ: PIN:   7   Port: H4        E0_AUTO_FAN_PIN                        protected 
READ: PIN:   8   Port: H5        <unused/unknown>                       Input  = 0                           TIMER4C   PWM:     0    WGM: 1    COM4C: 0    CS: 3    TCCR4A: 1    TCCR4B: 3    TIMSK4: 0  
READ: PIN:   9   Port: H6        SD_DETECT_PIN                          Input  = 0    TIMER2B   PWM:     0    WGM: 1    COM2B: 1    CS: 4    TCCR2A: 1    TCCR2B: 4    TIMSK2: 0  
READ: PIN:  10   Port: B4        <unused/unknown>                       Input  = 1                           TIMER2A   PWM:     0    WGM: 1    COM2A: 1    CS: 4    TCCR2A: 1    TCCR2B: 4    TIMSK2: 0  
READ: PIN:  11   Port: B5        HEATER_1_PIN                           protected 
READ: PIN:  12   Port: B6        E1_AUTO_FAN_PIN                        protected 
READ: PIN:  13   Port: B7        LED_PIN                                Input  = 0    TIMER0A   PWM:     0    WGM: 3    COM0A: 3    CS: 3    TCCR0A: 3    TCCR0B: 3    TIMSK0: 5   overflow interrupt enabled  
SENT: M105
READ:  .                  TIMER1C is also tied to this pin                  TIMER1C   PWM:     0    WGM: 4    COM1C: 0    CS: 2    TCCR1A: 0    TCCR1B: 10    TIMSK1: 2   non-standard PWM mode
READ: PIN:  14   Port: J1        BTN_RT                                 Input  = 1  
READ: PIN:  15   Port: J0        BTN_CENTER                             Input  = 1  
READ: .                          BTN_ENC                                Input  = 1  
READ: PIN:  16   Port: H1        CUTOFF_RESET_PIN                       Input  = 0  
READ: PIN:  17   Port: H0        CUTOFF_TEST_PIN                        Input  = 1  
READ: PIN:  18   Port: D3        <unused/unknown>                       Input  = 0                         
READ: PIN:  19   Port: D2        <unused/unknown>                       Input  = 0                         
READ: PIN:  20   Port: D1        <unused/unknown>                       Input  = 1                         
READ: PIN:  21   Port: D0        <unused/unknown>                       Input  = 1                         
READ: PIN:  22   Port: A0        <unused/unknown>                       Input  = 0                         
READ: PIN:  23   Port: A1        <unused/unknown>                       Input  = 0                         
READ: PIN:  24   Port: A2        E0_DIR_PIN                             protected 
READ: PIN:  25   Port: A3        E0_STEP_PIN                            protected 
READ: PIN:  26   Port: A4        E0_ENABLE_PIN                          protected 
READ: PIN:  27   Port: A5        DIGIPOTS_I2C_SDA_E0                    Output = 1  
READ: PIN:  28   Port: A6        E1_DIR_PIN                             protected 
READ: PIN:  29   Port: A7        E1_STEP_PIN                            protected 
READ: PIN:  30   Port: C7        <unused/unknown>                       Input  = 1                         
READ: PIN:  31   Port: C6        STAT_LED_BLUE_PIN                      Output = 0  
READ: PIN:  32   Port: C5        STAT_LED_RED_PIN                       Output = 0  
READ: PIN:  33   Port: C4        SR_STROBE_PIN                          Output = 0  
READ: PIN:  34   Port: C3        SR_DATA_PIN                            Output = 0  
READ: PIN:  35   Port: C2        SR_CLK_PIN                             Output = 1  
READ: PIN:  36   Port: C1        SERVO0_PIN                             Input  = 0  
READ: PIN:  37   Port: C0        SERVO1_PIN                             Input  = 0  
READ: PIN:  38   Port: D7        <unused/unknown>                       Input  = 0                         
READ: PIN:  39   Port: G2        E1_ENABLE_PIN                          protected 
READ: PIN:  40   Port: G1        SERVO2_PIN                             Input  = 0  
READ: PIN:  41   Port: G0        SERVO3_PIN                             Input  = 0  
READ: PIN:  42   Port: L7        Z_MAX_PIN                              protected 
READ: PIN:  43   Port: L6        Z_MIN_PIN                              protected 
READ: .                          Z_STOP_PIN                             protected 
READ: PIN:  44   Port: L5        FAN_PIN                                protected 
READ: PIN:  45   Port: L4        HEATER_BED_PIN                         protected 
READ: PIN:  46   Port: L3        Y_MAX_PIN                              protected 
READ: .                          Y_STOP_PIN                             protected 
READ: PIN:  47   Port: L2        FIL_RUNOUT2_PIN                        protected 
READ: .                          Y_MIN_PIN                              protected 
READ: PIN:  48   Port: L1        X_MAX_PIN                              protected 
READ: .                          X_STOP_PIN                             protected 
READ: PIN:  49   Port: L0        X_MIN_PIN                              protected 
READ: PIN:  50   Port: B3        AVR_MISO_PIN                           Input  = 1  
READ: .                          MISO_PIN                               Input  = 1  
READ: PIN:  51   Port: B2        AVR_MOSI_PIN                           Output = 1  
READ: .                          MOSI_PIN                               Output = 1  
READ: PIN:  52   Port: B1        AVR_SCK_PIN                            Output = 0  
READ: .                          SCK_PIN                                Output = 0  
READ: PIN:  53   Port: B0        AVR_SS_PIN                             protected 
READ: .                          SDSS                                   protected 
READ: .                          SS_PIN                                 protected 
READ: PIN:  54   Port: F0 (A 0)  X_DIR_PIN                              protected 
READ: PIN:  55   Port: F1 (A 1)  X_STEP_PIN                             protected 
READ: PIN:  56   Port: F2 (A 2)  X_ENABLE_PIN                           protected 
READ: PIN:  57   Port: F3 (A 3)  DIGIPOTS_I2C_SDA_X                     Output = 1  
READ: PIN:  58   Port: F4 (A 4)  Y_DIR_PIN                              protected 
READ: PIN:  59   Port: F5 (A 5)  Y_STEP_PIN                             protected 
READ: PIN:  60   Port: F6 (A 6)  Y_ENABLE_PIN                           protected 
READ: PIN:  61   Port: F7 (A 7)  DIGIPOTS_I2C_SDA_Y                     Output = 1  
READ: PIN:  62   Port: K0 (A 8)  Z_DIR_PIN                              protected 
READ: PIN:  63   Port: K1 (A 9)  Z_STEP_PIN                             protected 
READ: PIN:  64   Port: K2 (A10)  Z_ENABLE_PIN                           protected 
READ: PIN:  65   Port: K3 (A11)  DIGIPOTS_I2C_SDA_Z                     Output = 1  
READ: PIN:  66   Port: K4 (A12)  <unused/unknown>   Analog in =   668   Input  = 1                         
READ: PIN:  67   Port: K5 (A13)  <unused/unknown>   Analog in =   676   Input  = 1                         
READ: PIN:  68   Port: K6 (A14)  <unused/unknown>   Analog in =   708   Input  = 1                         
READ: PIN:  69   Port: K7 (A15)  TEMP_BED_PIN                           protected 
READ: PIN:  70   Port: G4 (A16)  <unused/unknown>                       Input  = 0                         
READ: PIN:  71   Port: G3 (A17)  <unused/unknown>                       Input  = 0                         
READ: PIN:  72   Port: J2 (A18)  BTN_LFT                                Input  = 1  
READ: PIN:  73   Port: J3 (A19)  BTN_DWN                                Input  = 1  
READ: PIN:  74   Port: J7 (A20)  <unused/unknown>                       Input  = 0                         
READ: PIN:  75   Port: J4 (A21)  BTN_UP                                 Input  = 1  
READ: PIN:  76   Port: J5 (A22)  DIGIPOTS_I2C_SCL                       Output = 1  
READ: PIN:  77   Port: J6 (A23)  DIGIPOTS_I2C_SDA_E1                    Output = 1  
READ: PIN:  78   Port: E2 (A24)  MAX6675_SCK_PIN                        Output = 0  
READ: .                          THERMO_SCK_PIN                         Output = 0  
READ: PIN:  79   Port: E6 (A25)  <unused/unknown>                       Input  = 0                         
READ: ok
sjasonsmith commented 4 years ago

@SaschaKP, do you actually re-install the old firmware to verify it still works after the new firmware failed? I just want to rule out hardware damage, such as a burned-out mosfet.

grauerfuchs commented 4 years ago

You said you're using the Arduino IDE as a compiler? Did you modify the pin definitions in the core libraries?

By default, Arduino doesn't properly address all of the pins used by the MightyBoard. I had the same issue early on when trying to compile Marlin builds for the MightyBoard, and that affected both PIO and Arduino at the time.

Since then, the code has been updated (for PIO) to make it to use a board variant that supports the needed pins. If the original firmware still works, try switching your compile environment to Platform IO instead of the Arduino compiler. If you need to run this entirely from command line, you'll need to update the pins definition.

Edited: Removed the erroneous references to the "MightyCore" library; The correct pin definitions come from the "MegaCore" library.

SaschaKP commented 4 years ago

that is what solved my issue, probably, since also older firmware worked, newer worked too, what probably solved the issue for the recompile for the new firmware is that the older one requested me with an error on compile time to modify that arduino pin definition file. so after that everything worked out.

I suppose that by giving the error in compile time, about number of pins, should fix future issues too, since older firmware do that and new one don't.

this can be shortly described this way:

I downloaded bugfix firmware, that compiled cleanly without any error, I ran the machine with the new firmware (I had a version of sailfish that I did maintain myself on my repos), and the heater didn't work.

I downloaded regular firmware, that didn't compile by giving me that pin numbers error, I fixed the local files and recompiled it, temperature did work out cleanly.

After that I uninstalled and reinstalled arduino IDE, and that's the point were I couldn't never imagine the error.

After some trial and error I've come to the conclusion that the missing pins are necessary and that arduino ide don't have them.

Maybe, instead of making some native ide modifications, it would be ideal to make some local config file with that mods to load on compile time.

This can be closed anyway, but those things should be kept in mind for the future.

sjasonsmith commented 4 years ago

I suggest leaving it open so that a compiler error can be added to the Mightyboard pins file. If there is an easy way to check the hardware it might help somebody else down the line.

SaschaKP commented 4 years ago

You said you're using the Arduino IDE as a compiler? Did you modify the pin definitions in the core libraries or switch to the MightyCore library for premade support?

By default, Arduino doesn't properly address all of the pins used by the MightyBoard. I had the same issue early on when trying to compile Marlin builds for the MightyBoard, and that affected both PIO and Arduino at the time.

Since then, the code has been updated (for PIO) to make it to use a board variant (MightyCore) that supports the needed pins. If the original firmware still works, try switching your compile environment to Platform IO instead of the Arduino compiler. If you need to run this entirely from command line, you'll need to update the pins definition.

I have to check that MightyCore, because Replicator 1 clones and Replicator 2 clones use different pins, maybe it's because of that, and by reassigning pins manually in arduino IDE that won't be called.

grauerfuchs commented 4 years ago

So far, at least in my experience, the configuration now provided for use with PlatformIO works on the Mightyboard rev D that uses the ATMega2560. I have personally tested this and it works with a stock FlashForge Creator Pro and on the clone board removed from a CTC Replicator Dual. I have not tested it on the ATMega1280-based Mightyboard.

My apologies. The name of the library providing the board (and pins) variant is "MegaCore", not "MightyCore". I have edited my original post to remove the incorrect references.

SaschaKP commented 4 years ago

Mightyboard with ATMEGA1280 or 2560 only vary on the programmable memory size (double size on 2560), all the rest is exactly the same on both controllers, like SRAM and other things.

grauerfuchs commented 4 years ago

That's what I had understood of the configuration, but I haven't reviewed the MakerBot or Sailfish code to verify that there have not been any pin changes.

SaschaKP commented 4 years ago

anyway, the fact is that arduino IDE only maps the first 70 pins of the arduino board, while mightyboard do use 80 pins in the map, the latest 10 are unrecognized by the compiler itself.

The non-bugfix version will give an error on compile time, requesting a modification on those core files, while the latter will not request, making those pins non functional, since they are not configured and used in the correct way in the various defines. that's probably what is happening here.

boelle commented 4 years ago

i would recommend to go the vscode+platform.io route, once you have tried you will not go back to arduino ide

ellensp commented 4 years ago

when you compiled, what did you select in arduino ide as the board type? (or command line)

According to https://cdn.thingiverse.com/assets/6d/94/65/9b/90/MakerBot_MightyBoard_REVE_Schematic.pdf the hotend pins are H3 and B5 The provided m43 output lists READ: PIN: 6 Port: H3 HEATER_0_PIN protected READ: PIN: 11 Port: B5 HEATER_1_PIN protected Shows these to be correct.

These are standard arduino pins. nothing special about them.

SaschaKP commented 4 years ago

the first page you see is exactly what I had for pins config, and never changed the mightyboardreve.h, the arduino type is a atmega2560, as selected in the arduino IDE, before and after.

It can't be that the problem has gone itself as if nothing did happen, that's not truly possible.

I will try to recreate the situation, and if successfull I'll post it here, negative or positive case.

grauerfuchs commented 4 years ago

@ellensp - It's been a long time since I've gone over the details for where and how the underlying issue occurs, but if I recall correctly, it's due to the unpredictable nature of reading data past the end of the pins array (out-of-bounds). In my case and with the code I had at the time, it resulted in the outward appearance of E1 (L) not heating up. The issue also isn't universal; It only occurs in functions that use certain calls in Arduino-based libraries. I'd need to go back through and find where the issue was initially documented to give details beyond this, but it's a long-standing, known issue with the Arduino framework/compiler/IDE with respect to the MightyBoard. Thankfully, the issue has been resolved when compiling the bugfix branch using VSCode and PIO due to its support for the MegaCore library and the extended pins definitions in the board config.

SaschaKP commented 4 years ago

It currently works, and I'm currently using the machine, tested with marlin 2.0.x-bugfix, recently updated.

What I've found out is that arduino IDE don't declare all the pins used by a mightyboard REV-E (so this requires a pin readdressing), so at this point the current bugfix-2.0.x works correctly with that board on an avr-atmega2560, this can be considered solved at the moment.

this is what I found on an old version of marlin source, and applied all the changes, and it currently works, it could be as @grauerfuchs stated, it only happens when certain functions are called, declaring those missing pins in the arduino IDE will make it work everything, but currently, marlin 2.0.x-bugfix don't have that disclaimer/error: `

// Check if all pins are defined in mega/pins_arduino.h
#include <Arduino.h>
static_assert(NUM_DIGITAL_PINS > MAX_PIN, "add missing pins to [arduino dir]/hardware/arduino/avr/variants/mega/pins_arduino.h based on fastio.h"
                                          "to digital_pin_to_port_PGM, digital_pin_to_bit_mask_PGM, digital_pin_to_timer_PGM, NUM_DIGITAL_PINS, see below");

/* in [arduino dir]/hardware/arduino/avr/variants/mega/pins_arduino.h
change:
#define NUM_DIGITAL_PINS            70
to:
#define NUM_DIGITAL_PINS            80

to digital_pin_to_port_PGM add at the end:
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
....
        PG      , // PG 4 ** 70 **
        PG      , // PG 3 ** 71 **
        PJ      , // PJ 2 ** 72 **
        PJ      , // PJ 3 ** 73 **
        PJ      , // PJ 7 ** 74 **
        PJ      , // PJ 4 ** 75 **
        PJ      , // PJ 5 ** 76 **
        PJ      , // PJ 6 ** 77 **
        PE      , // PE 2 ** 78 **
        PE      , // PE 6 ** 79 **
};

to digital_pin_to_bit_mask_PGM  add at the end:
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
....
        _BV( 4 )        , // PG 4 ** 70 **
        _BV( 3 )        , // PG 3 ** 71 **
        _BV( 2 )        , // PJ 2 ** 72 **
        _BV( 3 )        , // PJ 3 ** 73 **
        _BV( 7 )        , // PJ 7 ** 74 **
        _BV( 4 )        , // PJ 4 ** 75 **
        _BV( 5 )        , // PJ 5 ** 76 **
        _BV( 6 )        , // PJ 6 ** 77 **
        _BV( 2 )        , // PE 2 ** 78 **
        _BV( 6 )        , // PE 6 ** 79 **
};

to digital_pin_to_timer_PGM add at the end:
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
....
        NOT_ON_TIMER    , // PG 4 ** 70 **
        NOT_ON_TIMER    , // PG 3 ** 71 **
        NOT_ON_TIMER    , // PJ 2 ** 72 **
        NOT_ON_TIMER    , // PJ 3 ** 73 **
        NOT_ON_TIMER    , // PJ 7 ** 74 **
        NOT_ON_TIMER    , // PJ 4 ** 75 **
        NOT_ON_TIMER    , // PJ 5 ** 76 **
        NOT_ON_TIMER    , // PJ 6 ** 77 **
        NOT_ON_TIMER    , // PE 2 ** 78 **
        NOT_ON_TIMER    , // PE 6 ** 79 **
};
*/
el0x00bre commented 4 years ago

Thought I should chime in on this as my issue is identical minus compiling with the Arduino IDE. I have the ATMega1280 on the Mightyboard Rev A with the same heater pin out H3 and B5 all wired up correctly and no hardware issues (previously ran @SaschaKP 's modified Sailfish version with everything working). Currently running the latest bugfix and compiling with VSCode instead of IDE.

My T0 (right side extruder) is also not heating up. What's even more odd (this may be a separate bug) is that when I use the filament loading settings regardless of choosing E1 or E2, the left extruder (T1) always heats up and the right... nothing.

SaschaKP commented 4 years ago

@gilesdavison use anything before this commit: b0c6cfb0511b8d71fec26ab91cd945f3d623b3c0 after this we have a problem on multiple toolhead

el0x00bre commented 4 years ago

@SaschaKP Which specific commit are you using? I've tried the previous commit to b0c6cfb and I'm still having problems.. I then tried the 2.0.5 release and it's working but as you mentioned there are probe issues with that release.

boelle commented 4 years ago

@SaschaKP did you try vscode?

SaschaKP commented 4 years ago

@boelle No, I still use arduino IDE with modified pins_arduino.h, but in arduino IDE the progmem won't be sufficient for an ATMEGA1280, 128KB of progmem are mostly used by the auto-leveling and all the strings, I'll try later with the gcc cross toolchain

@gilesdavison I use this one: https://github.com/MarlinFirmware/Marlin/commit/ca78a57b1dd5bdec1aac9a2ee7bfd72fa3d7bfc5

boelle commented 4 years ago

thinking of it this question came up in my head: why not vscode+platform.io?

ellensp commented 4 years ago

default env:mega2560 in vscode+platformio has same missing pins issue, it uses the board megaatmega2560. This is based on Arduino mega pin definitions and they do not use pin > 69 For platformio you can also edit the file in .platformio/packages/framework-arduino-avr/variants/mega/pins_arduino.h

But, you are meant to use env: MightyBoard1280 or env: MightyBoard2560 env, these use the ATmega2560 megacore framework. And has the extra pins.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.