Marlin Firmware Setup
Marlin Setup
The required changes to Marlin firmware to run the Flex3Drive are outlined here. These can be done directly in the source code with Arduino IDE, or if your EEPROM is enabled the changes can be made at command line level using m-codes using a command line tool such as PrintRun or the same in PrusaSlicer / S3D. Thus avoiding the need to recompile and re-upload your firmware.
If you dont know PrintRun, it is a very useful tool written by Kliment and can be downloaded from here (opens in new tab)
The changes required are dependent on the version of Marlin being used.
Marlin 1.x runs on 8bit boards (Arduino ATmega1280 / 2560 proc’)
Marlin 2.0 runs on 32bit SKRv1.3 (LPC1768 ARM CoreTex M3)+others
Motor Direction
Depending how the motor is wired to the main board you may need to reverse the motor direction. This can be done in the firmware, or by reversing the connector (or pins) to the board.
Firmware method – flip the parameter below true/false as required.
#define INVERT_E0_DIR false
Set E axis Motor current
For Flex3Drive the motor current needs to be lowered. This can be set via command line if your board supports digital trim pots otherwise it will be set by measuring and adjusting the reference voltage from the trim pot on the board.
For board mounted trim pot, measure the voltage between the centre of the trim pot for the E axis and ground with a multi-meter. Adjust the trim pot to achieve a target measurement of 0.4v for pancake motors and 0.45 for mid-can motors.
In firmware use the parameter listed below to set current. Set the relevant parameter for your board.
//#define PWM_MOTOR_CURRENT { 1300, 1300, 450 } // Values in milliamps |
//#define DIGIPOT_MOTOR_CURRENT { 135,135,135,85,85 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) |
//#define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 50 } // Default drive percent – X, Y, Z, E axis
The m-codes in use for Marlin based boards if they support digital trimpots are M907 and M908.
M907 E400
M908 <pin><400> (check with your board manufacturers documentation for pins used, and format of current parameter)
Microstepping
Best to run at x8 microstepping for the Flex3Drive where possible. This can often be set by removing jumper MS3 from the E axis port if your board has jumpers under the driver.
Microstepping can also be adjusted by use of m-code M350 if the board supports it.
M350 E8
On Mini-Rambo (eg Prusa MK2/2.5/S use x4. See Prusa install for more info.
M350 E4 (driver does not support x8 microstepping
On 32bit Marlin boards microstepping is dependent on the drivers being used. Recommended to run the E axis aswell at x8 without interpolation. This reduces the load on the circuitry given the high pulse frequency (within the driver).
TMC21xx drivers should be set to run at x4 microstepping.
They also have a Stealthchop/Spreadcycle mode. Set to Spreadcycle since stealthchop effectively reduces the energy going through the motor at low speeds by modifying the waveform of signal sent to motors, but we need high speeds for retraction performance, with a low current. So Spreadcycle it is.
Decay Mode
In some instances it is possible to adjust the decay mode of the driver. This is a more advanced optimsation and usually done at the hardware level.
4988 decay mode can be set by shorting the resistor on the decay mode pin to ground to select fast decay.
Motion Parameters
These are the summary changes to be made within the Marlin v1.x code running on 8bit boards and can be found in the configuration.h file.
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 4000, 1900}
#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 40 }
#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 75 }
#define DEFAULT_RETRACT_ACCELERATION 75
#define DEFAULT_EJERK 0.1
These parameters can also be set via m-codes as follows
M92 E1900 – sets esteps
M201 E75 – E axis acceleration
M203 E40 – E axis max feedrate
M204 R75 – Retract acceleration (set to same as M201)
M205 E0.1 – E axis jerk.
M500 – Store settings
If you dont have eeprom enabled and are without access to source code, you can include the m-codes into your slicers startup code.