MarlinFirmware / MarlinFirmware/Marlin

[FR] Order of operations for planner when using solenoids

Open
#23,391 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T: Feature Request
Dominant language
C++
Stars
17.6k
Forks
19.7k
Avg merge
3d 5h
Merged PRs (30d)
21

Description

### Is your feature request related to a problem? Please describe.

I have made a printhead that uses a solenoid. I added a command to turn on the solenoid in G10, and turn off the solenoid in G11, and I want the solenoid to turn on at the beginning of the retraction and turn off after. Instead, the solenoid is turned on as soon as it hits Planner :: block_buffer, with all other parts of the retract being executed on time. If both commands G10 and G11 fall into the buffer, the solenoid turns on and off immediately, after which printing continues. I found this peculiarity by changing the buffer size, when it = 2, the solenoids work almost correctly.
I also tried adding these commands to fwretract.cpp, the result does not change

### Are you looking for hardware support?

printer flying bear ghost 5, with significant changes
mks_robin_nano35
marlin 2.0.9.1

### Describe the feature you want

Is it possible to change the priority in the Planner so that the solenoids opens and closes on time?

### Additional context

these are my changes in G10 and G11
```
void GcodeSuite::G10() {
#if HAS_MULTI_EXTRUDER
const bool rs = parser.boolval('S');
#endif
fwretract.retract(true
#if HAS_MULTI_EXTRUDER
, rs
#endif
);
#ifdef epoxy
enable_solenoid(1);
disable_solenoid(0);
#endif
}

/**
* G11 - Recover filament according to settings of M208
*/
void GcodeSuite::G11() {
fwretract.retract(false);
#ifdef epoxy
enable_solenoid(0);
disable_solenoid(1);
#endif
}
```
FWRETRACT settings:
```
#define FWRETRACT
#if ENABLED(FWRETRACT)
//#define FWRETRACT_AUTORETRACT // Override slicer retractions
#if ENABLED(FWRETRACT_AUTORETRACT)
#define MIN_AUTORETRACT 0 // (mm) Don't convert E moves under this length
#define MAX_AUTORETRACT 0 // (mm) Don't convert E moves over this length
#endif
#define RETRACT_LENGTH 0 // (mm) Default retract length (positive value)
#define RETRACT_LENGTH_SWAP 0 // (mm) Default swap retract length (positive value)
#define RETRACT_FEEDRATE 0 // (mm/s) Default feedrate for retracting
#define RETRACT_ZRAISE 1 // (mm) Default retract Z-raise
#define RETRACT_RECOVER_LENGTH 0 // (mm) Default additional recover length (added to retract length on recover)
#define RETRACT_RECOVER_LENGTH_SWAP 0 // (mm) Default additional swap recover length (added to retract length on recover from toolchange)
#define RETRACT_RECOVER_FEEDRATE 0 // (mm/s) Default feedrate for recovering from retraction
#define RETRACT_RECOVER_FEEDRATE_SWAP 0 // (mm/s) Default feedrate for recovering from swap retraction
#if ENABLED(MIXING_EXTRUDER)
//#define RETRACT_SYNC_MIXING // Retract and restore all mixing steppers simultaneously
#endif
#endif
```
part of g-code, as a sample, if BLOCK_BUFFER_SIZE = 16

> G1 X19.953 Y144.455 E40.28643
> G1 X19.845 Y143.727 E40.33900
> solenoid open
> solenoid close
> G1 X19.794 Y143.203 E40.37654
> G1 X19.643 Y140.000 E40.60557
> G1 X19.643 Y37.000 E47.96141
> G1 X19.669 Y36.475 E47.99895
> G1 X19.803 Y35.109 E48.09695
> G1 X20.008 Y34.079 E48.17195
> G1 X20.406 Y32.766 E48.26996
> G1 X20.808 Y31.796 E48.34495
> G1 X21.455 Y30.586 E48.44295
> G1 X22.039 Y29.712 E48.51795
> G1 X22.909 Y28.652 E48.61595
> G1 X23.588 Y27.973 E48.68452
> G10 (z-hope on time)
> G92 E0
> G1 X25.200 Y37.010 F12000.000
> G11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the planner's block_buffer behavior and the G10/G11 handling, including the changes shown in fwretract.cpp. Reproduce the sample G-code with different BLOCK_BUFFER_SIZE values and trace when the solenoid commands execute relative to retraction. Done means the solenoid opens and closes at the intended retraction boundaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.