-
Notifications
You must be signed in to change notification settings - Fork 31
Interfacing the Duet3D boards (WiFi, Ethernet, Maestro)
The Duet3D mainboards are powerful and versatile controller boards for 3D printers. They feature a lot of functions out-of-the-box. One unique feature is, that you can program these boards using GCode macro files located on the SD-Card.
Though, one important thing is missing: Connectivity!
As of now, the Duet3D controllers do not enable you to establish a bidirectional connection to other devices via a standard serial interface. Even though there are serial ports available (i.e. if you're not using a LC display) these cannot be controlled via the GCode macros mentioned above.
The only way to send/read data from within a GCode macro is to utilize the I2C a.k.a TWI (Two Wire Interface), using the M260 GCode (as explained here: M260 Gcode). So, instead of forking the publicly available firmware code and adding such features, I've decided to take the other route and to communicate over the I2C.
Therefore we'd need an simple I2C to UART converter, which is available on the market in various packages. Though I've decided to make it a bit more versatile by using an ESP microcontroller as the converter. That's because the microcontroller is easier to modify in case one needs some special features and mostly cheaper than a proprietary converter PCB solution.
In the world of interfaces, microcontrollers as well as the mind of developers can change quickly. Hence, the interface has now got it's own Git repository for quite some reasons. Please head over to the SMuFF-Ifc repositiory for further details.
My Duet3D is configured in that way, that the E1 stepper motor is the main extruder. To combine both devices in the best possible way, I've connected the extruder stepper driver (E1 terminal) to the Feeder stepper motor of the SMuFF. The E1 endstop of the Duet3D connects directly with the SMuFF-Ifc board. The SMuFF is responsible for the filament selection, whereas the Duet still handles the loading/unloading and feeding of the filament during the print.
At the time of writing this instruction, the Duet3D firmware version is 2.02 with the 2.03 in the making. The developers announced that version 2.04 will have the option of conditionals, loops etc. which will ease the handling and programming of macros a ton (so we all hope :o). In this sense ... stay tuned for things to come.
In order to use the scripts described in the following section, you have to modify your config.g beforehand.
Firstly, you have to define an additional axis (U), which gets the same stepper motor assigned as your extruder (E). Also, for each GCode that modifies a setting for the extruder (E), add the same assignment for the U-axis (i.e. M350 ... E128 U128).
Please note: The parameter P3 in M584 will hide the (fake) axis from the Duet3D and the UI. This is by intention.
M575 P1 B57600 ; Set Baudrate for PanelDue/SMuFF-Ifc
...
M584 X0 Y1 Z4:2 E3 U3 P3 ; Apply custom drive mapping
M350 X128 Y128 Z16:16 E128 U128 I0 ; Configure microstepping
M92 X640 Y640 Z266.66:266.66 E3247 U3247 ; Set steps per mm
M566 X1200 Y1200 Z250:250 E1200 U1200 ; Set maximum instantaneous speed changes (mm/min)
M203 X30000 Y30000 Z8000:8000 E12000 U12000 ; Set maximum speeds (mm/min)
M201 X750 Y750 Z250:250 E2000 U2000 ; Set accelerations (mm/s^2)
M906 X1200 Y1400 Z1400:1400 E1200 U1200 I50 ; Set motor currents (mA) and motor idle factor in per cent
Just in case you're wondering: Adding a fake axis is (yet) the only way to make an extruder "extrude until endstop is hit". Hence you have to assign the same stepper motor number. Also, the baud rate setting of P1 (M575) has to match the settings in the SMuFF-Ifc firmware.
Secondly, add the endstop configuration for the fake axis:
M574 U1 S1 C3 ; SMuFF endstop for feeder
Lastly, define the tools according to the number of tools your SMuFF supports:
M563 P0 D0 H1 S"SMuFF-0" ; Define tool 0
G10 P0 X0 Y0 Z0.0 ; Set tool 0 axis offsets
G10 P0 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
M563 P1 D0 H1 S"SMuFF-1" ; Define tool 1
G10 P1 X0 Y0 Z0.0 ; Set tool 0 axis offsets
G10 P1 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
M563 P2 D0 H1 S"SMuFF-2" ; Define tool 2
G10 P2 X0 Y0 Z0.0 ; Set tool 0 axis offsets
G10 P2 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
M563 P3 D0 H1 S"SMuFF-3" ; Define tool 3
G10 P3 X0 Y0 Z0.0 ; Set tool 0 axis offsets
G10 P3 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
M563 P4 D0 H1 S"SMuFF-4" ; Define tool 4
G10 P4 X0 Y0 Z0.0 ; Set tool 0 axis offsets
G10 P4 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
In the example above, tools are named "SMuFF-x" but you can name them whatever you like.
Here you will find a ZIP file containing a set of macros used for tool changing. For a better understanding which script does what, I've added this graph of the script workflow.
Please don't forget setting up the right extraction distances in toolload.g / toolunload.g in order to meet your machine configuration (length of bowden-tube etc.).