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.14k stars 19.2k forks source link

end of filament detection #999

Closed rr2s closed 9 years ago

rr2s commented 10 years ago

I would like to implement a function that would put marlin break at the detection end of the filament. I would really contributed to this framework and understand how to do it properly.

Where and how can I create a function that triggers a pause if the pin D1 and high state (normally unused pin on the ramps 1.4).

gerty commented 9 years ago

Has any progress been made on this feature? We're looking to repurpose an unused endstop and a roller/limit switch which would trigger an M226 "Gcode Initiated Pause" when open. D1 is a good thought but we're using an Azteeg X3. I'll have to check the mapping.

rr2s commented 9 years ago

I wanted have advice, but I have not had any. I fend me. I use a optical detector fork. Command M226 is trigger when there no more filament. In ramps 1.4 we can use the AUX (D1 for example). Azteeg X3 also uses a Atmel ATMEGA2560 micro controller, you should find the auxiliary fairly easily. I also use a buzzer to warn me when there lack of filament M300.   It's very simple to set up.

boelle commented 9 years ago

if you have fixed this then please fork the latest marlin, make the changes you made and submit a pull request

JamesT42 commented 9 years ago

If you do, please make it multi-extruder compatible

AbuMaia commented 9 years ago

I see there is now an option to enable a filament runout sensor in configuration.h. Where can I find documentation on this feature? I have such a switch already in use on my printer, set to normally-open, and held closed by the filament, triggering M300 when the filament end opens the switch.

thinkyhead commented 9 years ago

Hi @AbuMaia. All you need to do is to uncomment the define FILAMENT_SENSOR and then make sure your sensor's pin is set correctly. The default values are…

boelle commented 9 years ago

info here: http://www.thingiverse.com/thing:89044

and you can get one here: http://owi.storenvy.com/

AbuMaia commented 9 years ago

That's the wrong sensor, Thinkyhead. I'm not talking about a filament width sensor, but an end-of-filament sensor. Configuration.h says it uses RAMPS servo pin 2, but there are options for pullups and inverting which I do not understand.

boelle commented 9 years ago

you can still use that sensor... if a 3mm filament is below 1mm then you are prob out

Den tirsdag den 24. marts 2015 skrev AbuMaia notifications@github.com:

That's the wrong sensor, Thinkyhead. I'm not talking about a filament width sensor, but an end-of-filament sensor. Configuration.h says it uses RAMPS servo pin 2, but there are options for pullups and inverting which I do not understand.

— Reply to this email directly or view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/999#issuecomment-85455575 .

AnHardt commented 9 years ago

@boelle Yes. But there is a little difference between 60$ and 20€ cent.

AbuMaia commented 9 years ago

As mentioned earlier, I don't have a width sensor, I have a filament runout sensor. I just need some additional info on how to set it up in Configuration.h.

Wurstnase commented 9 years ago

If you have a normal mechanical switch you need a pullup, so the pin can reset. Inverting depends on your switch (normally close/normally open).

AnHardt commented 9 years ago

@AbuMaia Take a switch. Connect to pin and ground. Set FILRUNOUTPIN in your pins???.h. Define ENDSTOPPULLUP_FIL_RUNOUT. Play with FIL_RUNOUT_INVERTING until it works.

AbuMaia commented 9 years ago

I have my switch connected to pin 57. Is there a pullup resistor associated with that pin?

AnHardt commented 9 years ago

@AbuMaia As fa i remember there are pullups for all pins.

AbuMaia commented 9 years ago

Thanks for the help.

thinkyhead commented 9 years ago

Oops, right, well, same general idea. Find the relevant pin, make sure it's set, enable the option. Etc.

Ziggy2013 commented 9 years ago

Most of the functionality required for a filament "end" monitor and alarm are already in Marlin. The existing "filament Change" function (pause/resume) can be used if triggered by a digital pin going low to high. A simple filament end sensor can be made just using a micro switch which normally holds the pin low when filament is present.

http://community.robo3d.com/index.php?threads/filament-monitor.3335/page-2#post-42914

The mods below have been tested and work. The end of filament sense pin is 44. Obviously this pin needs to be a config parameter. The boolean FC_Flag also needs to be defined correctly (not just in line as in this mod)

The code changes required in the file marlin_main.cpp are :

  lcd_init();
  _delay_ms(1000);  // wait 1sec to display the splash screen

  #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
    SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
  #endif

  #ifdef DIGIPOT_I2C
    digipot_i2c_init();
  #endif

  // filament monitor mod - 18/03/2015
  // filament monitor pin set to input
   SET_INPUT(44);
   WRITE(44,HIGH); // enable pull up 
}

// filament monitor mod - 18/03/2015
boolean FC_Flag = false; // initialise flag to enque M600 command once per alarm

void loop()
{
  if(buflen < (BUFSIZE-1))
    get_command();

And in the marlin_main.cpp loop() code

    #else
      process_commands();
    #endif //SDSUPPORT
    buflen = (buflen-1);
    bufindr = (bufindr + 1)%BUFSIZE;

// filament monitor mod - Ziggy 
// 
// note FC_Flag variable must be global
//
 if (digitalRead(44) == HIGH) {         // check filament monitor alarm pin
    if (!FC_Flag) {              // not already triggered ?
     enquecommand_P(PSTR("M600"));       // trigger a filament change
     FC_Flag = true;                     // 
    }
  } else FC_Flag = false;               // reset for next alarm

  }
  //check heater every n milliseconds
Ziggy2013 commented 9 years ago

I see in the latest dev version this function has been implemented along the same lines using pin 4

thinkyhead commented 9 years ago

Sounds like you have it in hand. I can see it will help to make better documentation for this, and for Marlin features generally. Keeping that in mind…

github-actions[bot] commented 2 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.