BLACKFYRE
MG—01
LANG
←
ALL POSTS
05 · Writing / 2021
28 MAY 2021 · 6 MIN READ

Adventures with Klipper and a Duet 2 Wifi on an FLSUN QQ-S Pro

Flashing Klipper onto a Duet 2 Wifi with bossac, and building a working printer.cfg for the FLSUN QQ-S Pro from three different configs.

CONTENTS
03 +

While Duet Web Control is nice and RepRapFirmware is a solid workhorse with a proven track record, I’ve really wanted to get on the Klipper bandwagon!

I wanted to see what the Klipper hype is all about and what it can do for me in print quality and ease-of-life aspects.

First of all: Klipper is an alternative firmware for your 3D printer which offloads the heavy lifting (calculations) to an external provider (Raspberry Pi, laptop, desktop, …). This allows for a whole lot, actually! Imagine that your printer is still rocking that old and faithful 8-bit microcontroller, you’re still stuck with early versions of Marlin because of space constraints, and you’re missing out on all the fun and new features. No more! Klipper to the rescue!

Since I’ve got a solid board and the wiring already done, I didn’t really want to tinker with the hardware setup, so I went on to flash Klipper onto the Duet, and this is how it went. (This isn’t for the faint of heart!)

Building the firmware

The first real hurdle to cross was flashing Klipper onto the Duet board. While documentation is available, it’s all over the place… So, to make things easy for next time, here’s how the make menuconfig command should be set up:

Enlarge imageKlipper’s menuconfig screen: SAM3/SAM4 (Due and Duet) architecture, SAM4e8e (Duet Wifi/Eth) processor, USB communication
FIG. 1make menuconfig for a Duet 2 Wifi.

This was the easy part; now you can build the firmware.

Flashing the Duet

The next, harder part (if you’re not a regular Duet 2 flasher) was to figure out how to flash the Duet 2 board with the new firmware. This is where the Duet wiki article about flashing comes in handy!

You can follow the preparation steps to enter “flash mode” (and totally erase the previous firmware on entering said state).

At this point, you’ll have to deviate from all the documentation present and go for another one, which will tell you to use bossac to flash the printer instead of the nifty little flashing tool provided by Klipper (it also uses bossac, but with the wrong flags for our case).

Take note of the unique port name provided by this command, as you’ll need to replace the /dev/ttyACM0 part with its result below:

SHELL
$ls /dev/serial/by-id/*

So, command line it is:

~/klipper
SHELL
$./lib/bossac/bin/bossac --port=/dev/ttyACM0 -b -U -e -w -v -R out/klipper.bin
output
TEXT
1Erase flash
2Done in 4.079 seconds
3Write 21864 bytes to flash (43 pages)
4[==============================] 100% (43/43 pages)
5Done in 0.335 seconds
6Verify 21864 bytes of flash
7[==============================] 100% (43/43 pages)
8Verify successful
9Done in 0.327 seconds
10Set boot flash true

If you see something like this, you’re golden! At this point, we have open communications between the printer and the Raspberry Pi (in my case at least, YMMV).

Configuring the printer

This preparation part was arguably the easier one; the next one can be a bit… Google-heavy 😃 We need to configure our printer! Here are a few resources to do just that:

As you’ve probably guessed, we’re going to mix and match parts of config files! Here are my results. The first one is where I started:

printer.cfg (first version)
INI
1[mcu]
2serial: /dev/serial/by-id/usb-Klipper_sam4e8e_00313953325753543039303330303630-if00
3
4[printer]
5kinematics: delta
6max_velocity: 500
7max_accel: 2000
8max_z_velocity: 200
9minimum_z_position: 0
10delta_radius: 130
11
12[stepper_a]
13step_pin: PD6
14dir_pin: !PD11
15enable_pin: !PC6
16microsteps: 16
17rotation_distance: 32
18endstop_pin: ^PC14
19position_endstop: 316
20arm_length: 288.14
21homing_speed: 60
22second_homing_speed: 5
23
24[tmc2660 stepper_a]
25cs_pin: PD14
26spi_bus: usart1
27run_current: 1.000
28sense_resistor: 0.051
29
30[stepper_b]
31step_pin: PD7
32dir_pin: !PD12
33enable_pin: !PC6
34microsteps: 16
35rotation_distance: 32
36endstop_pin: ^PA2
37
38[tmc2660 stepper_b]
39cs_pin: PC9
40spi_bus: usart1
41run_current: 1.000
42sense_resistor: 0.051
43
44[stepper_c]
45step_pin: PD8
46dir_pin: !PD13
47enable_pin: !PC6
48microsteps: 16
49rotation_distance: 32
50endstop_pin: ^PD29
51
52[tmc2660 stepper_c]
53cs_pin: PC10
54spi_bus: usart1
55run_current: 1.000
56sense_resistor: 0.051
57
58[extruder]
59step_pin: PD5
60dir_pin: PA1
61enable_pin: !PC6
62microsteps: 16
63rotation_distance: 9
64nozzle_diameter: 0.400
65filament_diameter: 1.750
66heater_pin: !PA20
67sensor_type: EPCOS 100K B57560G104F
68sensor_pin: PC15
69control: pid
70pid_Kp: 14.529
71pid_Ki: 0.557
72pid_Kd: 94.802
73min_extrude_temp: 180
74min_temp: 0
75max_temp: 260
76
77[tmc2660 extruder]
78cs_pin: PC17
79spi_bus: usart1
80run_current: 1.000
81sense_resistor: 0.051
82
83[heater_bed]
84heater_pin: !PA19
85sensor_type: EPCOS 100K B57560G104F
86sensor_pin: PC13
87control: pid
88pid_Kp: 325.10
89pid_Ki: 63.35
90pid_Kd: 417.10
91min_temp: 0
92max_temp: 150
93
94[fan]
95pin: PC23
96
97[probe]
98pin: PC1
99z_offset: -0.1
100speed: 20
101samples: 2
102
103[delta_calibrate]
104radius: 120
105
106[gcode_arcs]
107resolution: 1.0
108
109[filament_switch_sensor Filament]
110pause_on_runout: True
111switch_pin: !PD10
112
113[virtual_sdcard]
114path: ~/gcode_files
115
116[display_status]
117
118[pause_resume]
119
120[bed_mesh]
121mesh_radius: 120

And this is the one I’m running now:

printer.cfg
INI
1# This file contains common pin mappings for Duet2 Eth/Wifi boards. To
2# use this config, the firmware should be compiled for the SAM4E8E.
3
4# See docs/Config_Reference.md for a description of parameters.
5
6[mcu rpi]
7serial: /tmp/klipper_host_mcu
8
9[adxl345]
10cs_pin: rpi:None
11
12[resonance_tester]
13accel_chip: adxl345
14probe_points:
15 0,0,20 # an example
16
17[mcu]
18serial: /dev/serial/by-id/usb-Klipper_sam4e8e_00313953325753543039303330303630-if00
19
20[printer]
21kinematics: delta
22max_velocity: 500
23max_accel: 2000
24max_z_velocity: 200
25minimum_z_position: -5
26#delta_radius: 130
27
28[stepper_a]
29step_pin: PD6
30dir_pin: !PD11
31enable_pin: !PC6
32microsteps: 16
33rotation_distance: 32
34endstop_pin: ^PC14
35#position_endstop: 316
36#arm_length: 288.14
37homing_speed: 60
38second_homing_speed: 5
39
40[tmc2660 stepper_a]
41cs_pin: PD14
42spi_bus: usart1
43run_current: 1.000
44sense_resistor: 0.051
45
46[stepper_b]
47step_pin: PD7
48dir_pin: !PD12
49enable_pin: !PC6
50microsteps: 16
51rotation_distance: 32
52endstop_pin: ^PA2
53
54[tmc2660 stepper_b]
55cs_pin: PC9
56spi_bus: usart1
57run_current: 1.000
58sense_resistor: 0.051
59
60[stepper_c]
61step_pin: PD8
62dir_pin: !PD13
63enable_pin: !PC6
64microsteps: 16
65rotation_distance: 32
66endstop_pin: ^PD29
67
68[tmc2660 stepper_c]
69cs_pin: PC10
70spi_bus: usart1
71run_current: 1.000
72sense_resistor: 0.051
73
74[extruder]
75step_pin: PD5
76dir_pin: PA1
77enable_pin: !PC6
78microsteps: 16
79rotation_distance: 7.618
80nozzle_diameter: 0.400
81filament_diameter: 1.750
82heater_pin: !PA20
83sensor_type: EPCOS 100K B57560G104F
84sensor_pin: PC15
85#control: pid
86#pid_Kp: 14.529
87#pid_Ki: 0.557
88#pid_Kd: 94.802
89min_extrude_temp: 180
90min_temp: 0
91max_temp: 260
92max_extrude_cross_section: 50
93pressure_advance: 0.082
94
95[tmc2660 extruder]
96cs_pin: PC17
97spi_bus: usart1
98run_current: 1.000
99sense_resistor: 0.051
100
101
102#[extruder1]
103#step_pin: PD4
104#dir_pin: PD9
105#enable_pin: !PC6
106#heater_pin: !PA16
107#sensor_pin: PC12
108#...
109#[tmc2660 extruder1]
110#cs_pin: PC25
111#spi_bus: usart1
112#sense_resistor: 0.051
113#...
114
115[heater_bed]
116heater_pin: !PA19
117sensor_type: EPCOS 100K B57560G104F
118sensor_pin: PC13
119#control: pid
120#pid_Kp: 325.10
121#pid_Ki: 63.35
122#pid_Kd: 417.10
123min_temp: 0
124max_temp: 150
125
126[fan]
127pin: PC23 # FAN0
128
129#[heater_fan nozzle_cooling_fan]
130#pin: PC26 # FAN1
131
132#[heater_fan board_cooling_fan]
133#pin: PA0 # FAN2
134
135[probe]
136pin: PC1
137z_offset: -0.340
138speed: 20
139samples: 2
140samples_tolerance_retries: 2
141
142[delta_calibrate]
143radius: 120
144
145[gcode_arcs]
146resolution: 1.0
147
148[filament_switch_sensor Filament]
149pause_on_runout: false #pause handled by macro
150runout_gcode:
151 M600 #calls a macro with the name M600 (so it can be called by slicers too)
152switch_pin: !PD10
153
154[virtual_sdcard]
155path: ~/gcode_files
156
157[display_status]
158
159[pause_resume]
160
161[bed_mesh]
162mesh_radius: 120
163
164# This macro should be called at the 'start g-code' part
165# of your slicer and you would put all the start g-code here
166# instead so that you don't have to re-slice everytime you
167# have to edit the commands
168[gcode_macro START_PRINT]
169gcode:
170 SET_GCODE_OFFSET Z=0.0
171 SET_GCODE_OFFSET Z_ADJUST=-0.1 MOVE=1 # PETG for 260mm plate
172 #SET_GCODE_OFFSET Z_ADJUST=-0.340 MOVE=1 # PLA for 260mm plate
173 #SET_GCODE_OFFSET Z_ADJUST=-0.560 MOVE=1 # PLA for 265mm plate
174
175# This macro should be called at the 'end g-code' part
176# of your slicer and like the macro above, you would
177# also put all of your end g-code here for the same reason as above
178[gcode_macro END_PRINT]
179gcode:
180 G91
181 G1 E-7 F2100
182 SET_GCODE_OFFSET Z_ADJUST=0 # resets the z-offset (otherwise, )
183
184# Pause print macro
185[gcode_macro PAUSE]
186rename_existing: BASE_PAUSE
187default_parameter_X: 0 #edit to your park position
188default_parameter_Y: 100 #edit to your park position
189default_parameter_Z: 30 #edit to your park position
190default_parameter_E: 5 #edit to your retract length
191gcode:
192 SAVE_GCODE_STATE NAME=PAUSE_state
193 BASE_PAUSE
194 G91
195 G1 E-{E} F2100
196 G1 Z{Z}
197 G90
198 G1 X{X} Y{Y} F6000
199
200# Resume print macro
201[gcode_macro RESUME]
202rename_existing: BASE_RESUME
203default_parameter_E: 5 #edit to your retract length
204gcode:
205 G91
206 G1 E{E} F2100
207 G90
208 RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
209 BASE_RESUME
210
211# Cancel print macro
212[gcode_macro CANCEL_PRINT]
213rename_existing: BASE_CANCEL_PRINT
214gcode:
215 TURN_OFF_HEATERS
216 CLEAR_PAUSE
217 SDCARD_RESET_FILE
218 BASE_CANCEL_PRINT
219 G28
220 END_PRINT
221
222[gcode_macro SET_Z]
223gcode:
224 G28
225 G1 X0 Y0 Z10 F5000
226 PROBE
227 G1 X0 Y0 Z10
228 G1 X0 Y0 Z0
229
230[gcode_macro UNLOAD]
231gcode:
232 M83
233 G0 E-50 F1800
234 G0 E-50 F1800
235 G0 E-50 F1800
236 G0 E-50 F1800
237 G0 E-50 F1800
238 G0 E-50 F1800
239 G0 E-50 F1800
240 G0 E-50 F1800
241 G0 E-50 F1800
242 G0 E-50 F1800
243 G0 E-50 F1800
244 G0 E-50 F1800
245 G0 E-50 F1800
246
247[gcode_macro LOAD]
248gcode:
249 M83
250 G0 E50 F1800
251 G0 E50 F1800
252 G0 E50 F1800
253 G0 E50 F1800
254 G0 E50 F1800
255 G0 E50 F1800
256 G0 E50 F1800
257 G0 E50 F1800
258 G0 E50 F1800
259 G0 E50 F1800
260 G0 E50 F1800
261 G0 E50 F1800
262
263[gcode_macro PARK_MACRO]
264default_parameter_X: 0
265default_parameter_Y: 100
266default_parameter_Z: 30
267gcode:
268 M117 PARKING..
269 G91
270 G1 E-3.14 F1500
271 G1 Z{Z}
272 G90
273 G1 X{X} Y{Y} F3000
274
275[gcode_macro M600]
276gcode:
277 PAUSE_MACRO
278 UNLOAD
279
280[gcode_macro PAUSE_MACRO]
281gcode:
282 PAUSE
283 PARK_MACRO
284
285[gcode_macro PURGE]
286gcode:
287 M117 PURGING..
288 G91
289 G1 E45.0 F250
290 G1 E45.0 F250
291 G1 E-5 F1800
292 G90

Compared to the first version, a few things moved or got added:

  • delta_radius, position_endstop, arm_length and the PID values are commented out, because DELTA_CALIBRATE, PID_CALIBRATE and SAVE_CONFIG store the calibrated values in the auto-generated block at the end of printer.cfg.
  • The Raspberry Pi is a second MCU ([mcu rpi]), so an ADXL345 accelerometer on it can drive [resonance_tester].
  • The extruder’s rotation_distance is calibrated, and pressure_advance is set.
  • The macros: START_PRINT and END_PRINT keep the start and end G-code out of the slicer, and filament runout goes through an M600 macro that pauses, parks and unloads.
TAGS
3D Printing
Klipper
Duet 2 Wifi
FLSUN QQ-S
06 · CONTACT

Have a system that needs building?

GET IN TOUCH → PROJECTS →
PRODUCT DATA SHEET
MG—01
BLACKFYRE
S/N MG-1985-1027
Miklós Galicz — Golang Advocate · Solution Architect
MODEL
MG—01 "Miklós Galicz"
SERIES
1985
ORIGIN
Nagykovácsi, Hungary
FUNCTION
Senior Full Stack Engineer · Solution Architect
CORE LANGUAGES
Go · PHP · JavaScript
SPOKEN
Hungarian · English · German
SERVICE LIFE
~20 years in software, ongoing
POWER SUPPLY
Coffee, 2–4 cups / day
DIMENSIONS
1 × human, standard size
OPERATING TEMP.
Calm under production incidents
CONNECTIVITY
[email protected] · github.com/blackfyre · linkedin.com/in/galiczmiklos
Less, but better. Specifications subject to continuous improvement.
● ● ●
MG—01 · SERIES 1985
№ MG-1985-1027
CERTIFICATE OF OPERATION
Certified Operator
Has located every documented feature of the MG—01 without reading the manual. Probably.
TIME
—
FEATURES
—
DATE
—
SIGNED
Miklós Galicz