Skip to content

Commit

Permalink
Merge pull request #10 from gitaroktato/retract-fractions
Browse files Browse the repository at this point in the history
Added option to define retraction distance with decimals
  • Loading branch information
gitaroktato authored Jun 19, 2023
2 parents 6003c2b + d7317e9 commit 24f92f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,36 @@ https://www.youtube.com/watch?v=xzQjtWhg9VE

https://www.youtube.com/watch?v=3yIebnVjADM

# Running the code
# Running the code - Samples

Changing retraction distance, starting with 0 with and defaulting to an increase of 1.0mm in every 25 layers
Changing retraction distance, starting with 0 with and defaulting to an increase of 1.0mm in every 25 layers (bowden tube)

```shell script
```shell
python ./main.py -f GCODE_FILE_NAME -m distance -l 25 -d 0
```

Changing retraction distance with a defined step distance, starting with 0 and increasing by 0.5mm in every 25 layers
Changing retraction distance with a defined step distance, starting with 0 and increasing by 0.5mm in every 25 layers (direct drive)

```shell script
```shell
python ./main.py -f GCODE_FILE_NAME -m distance -l 25 -d 0 -ds 0.5
```

Changing retraction speed from 25mm/s by 5mm/s in every 25 layer. **Note:** the given values are in mm/min [in Gcode](https://marlinfw.org/docs/gcode/G000-G001.html), so have to be multiplied by 60.
Changing retraction distance with a defined step distance, starting with 0.2 and increasing by 0.1mm in every 25 layers (direct drive)
```shell
python ./main.py -f ./CE3_stringing_0.4_3_all.gcode -m distance -l 25 -d 0.2 -ds 0.1
```

Changing retraction speed from 25mm/s by 5mm/s in every 25 layer (bowden tube).
**Note:** the given values are in mm/min [in Gcode](https://marlinfw.org/docs/gcode/G000-G001.html), so have to be multiplied by 60.

```shell
python ./main.py -f GCODE_FILE_NAME -m speed -l 25 -s 120 -t 60
```

Changing retraction speed from 2mm/s by 1mm/s in every 25 layer (direct drive).

```shell script
python ./main.py -f GCODE_FILE_NAME -m speed -l 25 -s 1500 -t 300
```shell
python ./main.py -f GCODE_FILE_NAME -m speed -l 25 -s 120 -t 60
```

Specify the layer height you would like to use for changing the retraction distance in the second parameter.
Expand All @@ -58,14 +70,14 @@ I TAKE ABSOLUTELY NO WARRANTY FOR RUINING YOUR PRINTER!
Let's say I want to do a test with the initial retraction distance of 0 and change it on every 5mm.
My layer height is 0.2, so I run the following command:

```shell script
```shell
python main.py -f tests/CE3_stringing.gcode -m distance -l 25 -d 0
```

The script will log out every retraction modification, where it was identifiable in the `.gcode` file.
In my case this was the following:

```shell script
```shell
...
LAYER: 33
RETRACT: 132.03252 changed to 136.03252 with retraction distance 1mm in G1 F2700 E132.03252
Expand Down Expand Up @@ -102,7 +114,7 @@ After running the `.gcode` file in my Ender 3 I realized that the ideal setting
After figuring out the ideal retraction distance you can even change the retraction speed for a given `.gcode`.
I've configured the initial retraction speed of 25mm/s and added 5mm/s increase in every 25 layer.

```shell script
```shell
python ./main.py -m speed -f tests/CE3_stringing_2mm_at_45mms_original.gcode -l 25 -s 1500 -t 300
```

Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def init_argparse():
parser.add_argument('-l', '--layer_step', required=True, type=int,
help="defines the layer step")

parser.add_argument('-d', '--initial_retraction_distance', type=int,
parser.add_argument('-d', '--initial_retraction_distance', type=float,
help="defines the initial retraction distance")

parser.add_argument('-ds', '--retraction_distance_step', type=float, default=1.0,
Expand Down Expand Up @@ -108,7 +108,7 @@ def change_retraction_distance(gcode_source=None,
log_layer_line(current_layer_at)
# We increment retraction distance if required
if not_initial_layer(current_layer_at) and have_to_change_variable_at_layer(current_layer_at, layer_distance):
current_retraction_distance_at += retraction_distance_step
current_retraction_distance_at = round(current_retraction_distance_at + retraction_distance_step, 1)

if current_layer_at is not None and currently_extruder_at is not None:
# Changing the retraction setting derived from the original
Expand All @@ -133,7 +133,7 @@ def change_retraction_distance(gcode_source=None,


def log_retraction_speed_change(current_retraction_speed_at=None, feed_rate=None, line=None):
print(f'RETRACT: Changing speed from {feed_rate} => {current_retraction_speed_at} in line {line}')
print(f'RETRACT: Changing speed from {feed_rate} => {current_retraction_speed_at} {current_retraction_speed_at / 60}mm/s in line {line}')


def log_retraction_distance_change(new_extruder_at=None,
Expand Down

0 comments on commit 24f92f2

Please sign in to comment.