I've spent the past week implementing this feature I call push/pull toolchange.
It started when @heinz posted his findings with the Cetus2 nozzle and its strategy for fast toolchanges:
The shownotes of implementation went something like this:
- Day 1
- Write initial pseudocode
- Day 2
- Look inside tool_change(...)
- Write config modifications, looking at SWITCHING_TOOLHEAD for naming conventions
- Write more detailed pseudocode
- Try and understand what COLOR_A_MASK means
- Day 3
- Look at how the extruder directions are applied (and ask if there's any specific thing I'm supposed to do so that I don't break everything, since this is outside the mixing-related code.
- Look up what do { } while(0) does, and it seems to make sure if-blocks don't break things.
- Day 4
- Find out there's something called MIXER_AUTORETRACT_TOOL
- Understand a few other functions in mixing.h
- Create a pushpull type
- Day 5
- Turn off VSCode Cpp formatting so that it doesn't mess with the formatting that's already present
- discover "mix" and related functions, and enable them for push/pull
- Write initial implementation for pushpull in the mixing.h side of things, such as creating MIXER_PUSHPULL_TOOL instead of a colour in the pushpull type.
- Day 6 (today)
- Find out that there are bit-mask macros and use them to tidy up my code.
- Try, fail, try some more to create the new E_APPLY_DIR macro.
- Change get_extruder_bits(...) to e_dir(...), where the former gave the thing that asked for it the entire 8 bits wheras the latter is a boolean on if that specific extruder is inverted or not. This made the MIXER_STEPPER_LOOP easier.
- Allow pushpull to use the too_cold(...) function already in toolchange.cpp
- Get more errors that stem from how I implemented the E_APPLY_DIR macro, as well as Mixer::pushpull
- Finally get the E_APPLY_DIR macro to work by needing essentially a do { do { ... }while(0) }while(0)
- Add a definition of pushpull_t Mixer::pushpull into mixing.c
- Marlin compiles finally
- Fix errors when optionals in config.h are disabled
- Improve too-cold error message by adding an additional context message
- Everything seems to work except I'm not getting any directions
- Test to see that my bits are being set correctly
- Find out that I need to apply the stepper directions, and I can't do that from mixing.h
- Split the code so that the logic responsible for extruding was in toolchange.cpp.
- Extruders work but there are a few quickly-squashed bugs.
- Pull Request created.
Implementation estimate: 12 hours Implementation time... 15 hours?
- Day 7 [Mar 31]
- Code cleanup to make it look minty fresh.
- Thought of a potential bug, confirmed and fixed it.
- When going from a A5 B5 C0 D0 to an A0 B0 C5 D5 mix, the push/pull length was wrong as I assumed it would just be 2x all the time
- Found out that G3 causes Marlin to crash and probably has something to do with the I and J values,
- Changing the HIJK mix characters to LMNO seems to fix it.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.