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.17k stars 19.21k forks source link

How to Re-Purpose XYZ (min/max) Endstops #8519

Closed kcheeeung closed 5 years ago

kcheeeung commented 6 years ago

Hello everyone. I would like to create a "4th axis" using the extruder stepper motor. In the current 3D printer setup, we have the XYZ positions using either XYZ min/max pins. I would like to use one of those extra pins such that I can achieve this.

Current setup is that each XYZ min/max pins, when activated (configured to stop only the XYZ axes respectively), is to stop the stepper motor from moving, which is what I am looking for. I would like a way such that the "4th axis" knows when to stop without crashing or damaging the system.

What's the best way of doing so? I have attached an image to demonstrate what I am trying to do.

Thanks for reading. untitled

olhodneland commented 5 years ago

How can i find the modified marlin code for an extra axis with endstop? The link to rev.C did not work. @Bob-the-Kuhn

DerAndere1 commented 5 years ago

Hi, a feature to enable homing the 4th axis after homing XYZ would indeed be great.
@olhodneland, @mousey225 and others: I found the "e-stop" branch of @kcheeung 's Marlin fork at www.github.com: https://github.com/kcheeeung/Marlin/tree/e-endstop. It should be working as a good starting point according to the corresponding comment above by kcheeung from 27th Nov. 2017.

Keep everyone updated if you made progress, thx. For my liquid handling robot I will also need to repurpose the E axis and home it (use E-axis stepper motor for moving a syringe pump).

DerAndere

mousey225 commented 5 years ago

@DerAndere1 Oh cool you are also making a Pipetbot! I ended up finishing mine in summer I would be happy to help you out with yours - I planned to put up the source files and marlin code on a website for public use but haven't got round to it yet due to being at university. I can send you it though if you like

DerAndere1 commented 5 years ago

@mousey225 I would appreciate if I could have a look at your code. If it is acceptable that your code will be public, you may simply add a comment in the issue tracker of my repository "contact_DerAndere1" and attach your code using drag and drop. If you don't have much experience with github and did not use version control software to adapt your Marlin firmware, you can still simply put your Marlin folder in a public repository at github.com (think of it as a dropbox on drugs):

  1. left-click the + symbol in the menu at the top-right of the github.com homepage
  2. left-click "New repository". Call it "Marlin1.1.y" or similar, and make sure "initialize with README" is selected. For any fork of Marlin, the license GNU General Public License v.3.0 has to be chosen.
  3. After creation of the repository, left-click "Upload files".
  4. Use drag & drop! to upload the contents (subfolders, original Marlin README, etc.) of your modified Marlin folder.
DerAndere1 commented 5 years ago

The branch Marlin2ForPipetBot of my Marlin fork now allows a homing move for the XYZ and E axis using MIN-Endstops for each axis by issuing G-code G28 for cartesian setups. However during development I boke the ability to do normal movement of the E-stepper when issuing "G1 E10" (even with cold extrusion). XYZ axes work as expected. Does someone see what code change prohibits G1 movement of the E-stepper? (Where is the difference between movement during homing and movement using G1?) The diff to original bugfix-Marlin2.0 is here. The Log file using DEBUG_LEVELING_FEATURE is: LOG.txt

;Test-Gccode Script: 
G91 ;relative
M302 S0 ;cold extrusion
M111 S32 ;debug
G28 ; home XYZE
G90 ;absolute
G1 X5 F300
G1 E10 F100
; end of g-code script

@Bob-the-Kuhn , @kcheeeung : Could you reopen this issue? The solutions publicly available seem to be incomplete or for old versions of Marlin.

kcheeeung commented 5 years ago

Hello friends. I will attempt to bring out my bare bones setup again to see what's going on. Admittedly, I couldn't fully get a complete solution previously, as there were some functionalities that were either "broken" or didn't work as anticipated. With more people interested, I think we can attempt to find a solution. @DerAndere1 and others who may still be interested.

Might be better to look at what @DerAndere1 has so far, as this has been a while back. I haven't kept up with the latest developments. I am also reviewing what I have in 1.1.x to see if there's some solutions.

thinkyhead commented 5 years ago

I can find no instance in Marlin (2.0) where it fetches or uses the E_AXIS element of homing_feedrate_mm_s or in a call to homing_feedrate. So that array can just contain X, Y, and Z.

kcheeeung commented 5 years ago
// #define EXTRUDE_MINTEMP 160
// #define PREVENT_LENGTHY_EXTRUDE
// #define EXTRUDE_MAXLENGTH 200

@DerAndere1 https://github.com/MarlinFirmware/Marlin/issues/8519#issuecomment-456045063 Maybe try this. I'm assuming that you might not need the hot-end and therefore need to disable it in configuration.h Your G28 command is able to move the XYZE to the "home" positions? But when you try to move it forward through something like G1 E10, it doesn't work?

DerAndere1 commented 5 years ago

Yey, My problem is fixed. I have a working proof of principle: For cartesian robots with four axes (one min endstop per axis, no z probe so far), the branch Marlin2forPipetBot of my Marlin 2.0 fork can home XYZ and also home the E axis with a simple G28. ENDSTOP_INTERRUPTS_FEATURE and SOFTWARE_ENDSTOPS for all those axes work, too. Thanks to @thinkyhead whose comment motivated me to go through the code some more times. And thanks to @kcheeeung who suggested to disable "Prevent lengthy extrude". During the next weeks I will try to put all changes inside #ifdefs so the functionality could be added to the original Marlin and only activated with some #define in configuration.h. For now I guess it makes sense to keep it as a seperate fork. DerAndere

DerAndere1 commented 5 years ago

I now have an e_homing branch which is ready for auto-merge with original bugfix-2.0.x, so I could create a pull request if desired. However I do not know how to deal with all the configuration.h files. Should I add the new options to all of them (but comment them out)?

Most changes are embedded in #if ENABLED(E_AXIS_HOMING) ... #else ... #endif blocks, so they are put into effect only when #define E_AXIS_HOMING is added to the file Configuration.h. A few sanity checks are added. Someone shoult test it with a normal 3d-printer while keeping E_AXIS_HOMING undefined.

DerAndere1 commented 5 years ago

The approach discussed above is working well for me. More features can be made compatible with E_AXIS_HOMING in the future. However @thinkyhead pointed out that for introducing the functionality in original Marlin2.0, the concept of the "hangprinter" feature by @tobbelobb in Marlin 1.1.9 is better: Introducing optional additional axes (i called them AXIS_I, AXIS_J, AXIS_K) is a more flexible design (think 6 axis arms as 3d printer). I want to share my idea of introducing NON_E_AXES (the number of non-extruder axes that may benefit from endstops and homing) next to MOV_AXIS (the number of axes used for positioning / kinematics, <=NON_E_AXES). The remaining NON_E_AXES can be used for driving non-extruder tools such as strong grippers or pumps. Users/local devs would have to #define NON_E_AXES >= 3 and add pin definitions for the additional axes (for AXIS_I: define I_STEP_PIN, I_DIR_PIN, I_ENABLE_PIN and I_STOP_PIN (e.g. in pins/pins_MYBOARDS.h). Trying to implement it is early WIP, see this branch: at the moment, homing 4 axis does not work yet, only NON_E_AXES = 3 (XYZ) plus extruders. Otherwise, Smoothieware already supports > 3 axes + extruders as far as I have read.

n9jcv commented 5 years ago

DerAndere1, I have a question in your comments you say the Emin homing will not work for Delta. Why is that?

I was looking at your changes at ; https://github.com/MarlinFirmware/Marlin/compare/bugfix-2.0.x...DerAndere1:e_homing

I have a delta and I want to be able to home an E axis, not for extruding. So would your changes work or is there something about deltas that would mean it will not work?

Thanks Bruce

DerAndere1 commented 5 years ago

@n9jcv Regarding https://github.com/MarlinFirmware/Marlin/issues/8519#issuecomment-464561867 :
Mainly because I did not (cannot) test on Delta. Possibly it is (almost) working as is. So far I really only looked at sections of code that apply to my setup with only basic features enabled (software endstops, endstop interrupts, babystepping, debug via M43/M111). Please submit an issue (feature request) for my fork over at https://github.com/DerAndere1/Marlin/issues and specify what features you really need (EEPROM? z-probe? what kind of bed leveling? Quick home? Any Display?) together with E homing or attach your configuration.h and configuration_adv.h files, so I can have a closer look if those settings are expected to interfere with the current implementation of E homing. In the same feature request also specify, which M-codes are most important to you, thanks. IF you can code yourself, you may double check if the code does what you expect and then remove the relevant sanity check. Soon I may try to change M114 so it also reports the E-axis position.

boelle commented 5 years ago

@kcheeeung

Please post your question either on discord: https://discord.gg/n5NJ59y or on facebook: https://www.facebook.com/groups/2080308602206119/ The issue list is for bugs and feature requests only Please close this issue once you have posted it on one of the 2 links Thanks :-D

n9jcv commented 5 years ago

Bo, I closed the 2 other issues.  This seems I can not close as I did not create.  There is no close button for me.  Sorry

Bruce

 

Sent: Tuesday, February 19, 2019 at 4:54 PM From: "Bo Herrmannsen" notifications@github.com To: MarlinFirmware/Marlin Marlin@noreply.github.com Cc: n9jcv n9jcv@mail.com, Mention mention@noreply.github.com Subject: Re: [MarlinFirmware/Marlin] How to Re-Purpose XYZ (min/max) Endstops (#8519)

@kcheeeung

Please post your question either on discord: https://discord.gg/n5NJ59y or on facebook: https://www.facebook.com/groups/2080308602206119/ The issue list is for bugs and feature requests only Please close this issue once you have posted it on one of the 2 links Thanks :-D

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

boelle commented 5 years ago

@n9jcv correct, only creator and @thinkyhead can close

ersahozbahadir commented 4 years ago

Here's the link to rev C of the 1.1.x E endstop code.

There's several more changed files plus an example Configuration.h file.

I was able to test this code.

Dear friend, I was searching about this issue and found your works here. But I couldn't download the files. Do you still have them?

DerAndere1 commented 4 years ago

@ersahozbahadir you can try https://github.com/DerAndere1/Marlin/tree/2.0.x_E_homing if you like.

ersahozbahadir commented 4 years ago

@DerAndere1 Thank you for your reply, I’ve been trying to compile that and getting some errors like “E_MIN is not declared in this scope” at endstops.cpp . Also I tried your bf2_6axis_dev14 which gives error about “_TERN was not declared”. And I could not figure out what to change, where to start.Both E homing or non_e axis >3 Would really help but I couldn’t :(

I have mega2560 and ramps1.4 with 4 steppers, 4 min endstops.

ersahozbahadir commented 4 years ago

Hi @DerAndere1, just for info what I've done with bf2_6axis. I was very tired yesterday and today started from the beginning. the first error happened when I activated discounted full glcd. Then I found some missing "}" in menu_motion.cpp file. Then it worked for me. Now, when auto homing, X,Y works perfect but when Z starts, the printer halted error occurs. There must be some difference at pins. I'll check. Thanks much.

DerAndere1 commented 4 years ago

@ersahozbahadir and other users: Each comment posted here takes away time from many people. Please do not discuss issues related to my code here. Instead, open new issue reports at https://github.com/DerAndere1/Marlin/issues. Most of the time those problems are related to existing issues listed at https://github.com/DerAndere1/Marlin/issues. My code can serve as a starting point for developers but is not production-ready as you have already noticed.

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