Skip to content

Instantly share code, notes, and snippets.

@rmeissn
Last active December 11, 2023 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmeissn/f24294a20b57c870abf1c9e760e54954 to your computer and use it in GitHub Desktop.
Save rmeissn/f24294a20b57c870abf1c9e760e54954 to your computer and use it in GitHub Desktop.
Flashforge Adventurer 3 Cura

The firmware of the Flashforge Adventurer 3 seems to understand only a subset of typical marlin gcode:

  • no G0 support (use G1 instead)
  • if XYZ coordinates are combined within G1, the bed leveling mesh seems to be ignored (use two G1 (one for Z and one for XY) instead)
  • M140 does not support decimal point numbers (only e.g. S50 instead of S50.0)
  • M104 does not support decimal point numbers (only e.g. S50 instead of S50.0)
  • no relative E value support (cura produces absolute E values either way)
  • a Z-Offset needs to be included in each Z coordinate if required (use cura Z-Offset plugin and tick "extensive z-offset processing")

-> I've created a bash script to convert cura gcode to flashforge gcode. I'm not sure I've covered all edge cases, but it seems to work.

X: 150mm
Y: 150mm
Z: 150mm
Build_Plate: Rectangular
Origin at Center: Tick
Heated Bed: Tick
Heated Build Volume: false
G-Code Flavor: Marlin
xmin: -20
ymin: -10
xmax: 10
ymax: 10
gantry hight: 150
no of extruders: 1
Apply Extruder Offset: Tick
M104 S0 T0 ; Hotend to 0°C
M140 S0 T0 ; Bed to 0°C
G162 Z F1800 ; Move Z Axes to Maximum
G28 X Y ; Home XY
M132 X Y A B ; Recall home offsets
M652 ; ???
G91 ; Relative Positioning
M18 ; Disable Steppers
M107 ;Turn-off fan
M140 S{material_bed_temperature} T0
M104 S{material_print_temperature} T0
M104 S0 T1 ; Tool 1 to 0°C
M107 ; Fan off
M900 K0.000 T0 ; K-Factor to 0
G90 ; Absolute Positioning
G28 ; Home XYZ
M132 X Y Z A B ; Recall home offsets
G1 Z50.250 F420 ; Move Z to 50mm
G161 X Y F3300 ; Move Axes to Minimum
M7 T0 ; Stabilize bed temperature
M6 T0 ; Stabilize extruder temperature
M651 S255 ; Set case fan on
M108 T0 ; Break and Continue
#!/bin/bash
# use as: transform_cura_to_flashforge.sh xxx.gcode
ConvertedGCode=$(cat $1)
# replace temperature of kind xx.0 to just xx
M140=$(echo "$ConvertedGCode" | grep M140)
while IFS= read -r line; do
convertedLine=$(echo "$line" | sed -E 's/S([0-9]+)\.0/S\1/g')
ConvertedGCode="${ConvertedGCode//$line/$convertedLine}"
done <<< "$M140"
M104=$(echo "$ConvertedGCode" | grep M104)
while IFS= read -r line; do
convertedLine=$(echo "$line" | sed -E 's/S([0-9]+)\.0/S\1/g')
ConvertedGCode="${ConvertedGCode//$line/$convertedLine}"
done <<< "$M104"
# seperate each G0 with Z coordinate into two G1 commands
linesWithZ=$(echo "$ConvertedGCode" | grep G0 | grep ' Z.*\.')
while IFS= read -r line; do
# Extracting relevant parts
speed=$(echo "$line" | awk -F '[ ;]' '{print $2}')
x=$(echo "$line" | awk -F '[ ;]' '{print $3}')
y=$(echo "$line" | awk -F '[ ;]' '{print $4}')
z=$(echo "$line" | awk -F '[ ;]' '{print $5}')
# Creating the new lines
z_line="G1 F420 ${z}0"
xy_line="G1 $speed $x $y"
# Printing the new lines
replacement=$(printf "%s\n%s\n" "$z_line" "$xy_line")
#echo "$line"
#echo $replacement
# Replacing within the original text
ConvertedGCode="${ConvertedGCode//$line/$replacement}"
# the following lines are currently not working
#ConvertedGCode=$(echo "$ConvertedGCode" | sed -e "s/\$line/\$replacement/g")
#ConvertedGCode=$(echo "$ConvertedGCode" | sed -e "s/$line/$replacement/g")
done <<< "$linesWithZ"
# Convert each remaining G0 to G1
ConvertedGCode=$(echo "$ConvertedGCode" | sed -e 's/G0/G1/g')
ending='.gcode'
convertedFile=${1%$ending}\-converted.g
echo "$ConvertedGCode" > $convertedFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment