-
Notifications
You must be signed in to change notification settings - Fork 185
Customization & Compiling
Without any changes, the firmware source code and the provided hex-files work with an Anycubic i3 Mega with 2 Z-axis endstops and TMC2208 with connectors in original orientation (corresponding to the TMC2208.hex
file).
The bare minimum you have to configure is motor direction and stepper driver type, which I am going to describe below.
- Download and install Arduino IDE
- Clone or download this repo
- Browse into the Marlin folder and run
Marlin.ino
- Arduino IDE should now open and show all the files corresponding to this firmware.
- In the IDE, under
Tools -> Board
selectGenuino Mega or Mega 2560
and underProcessor
, selectATmega2560
- Start off by looking at line
559
to566
and line857
to865
inConfiguration.h
, edit the file according to your stepper driver type and direction (see the comments) - That's it for the basic setup. You can either make further adjustments or jump straight to compilation.
- Generally, you can enable options by uncommenting them (remove
//
) or disable by commenting them out (add//
)
- After saving your changes, open Marlin.ino in the Marlin directory of this repo
- Under
Sketch
, selectExport compiled binary
- Look for the .hex file in the Marlin directory (only use the
Marlin.ino.hex
, not theMarlin.ino.with_bootloader.hex
!)
- In
Configuration.h
, line617
, adjust the E0 steps to 384 by editing the line as follows:
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 384 }
There is an old version of the i3 Mega that only has one Z endstop. To make this work:
- Disable
Z_DUAL_ENDSTOPS
by commenting it out in line327
ofConfiguration_adv.h
/*
*
* Proceed at your own risk.
*
*/
- You can change the PWM settings for heaters and fans at line
1816
to1828
inConfiguration.h
. - Those settings affect heaters as well as fans. Some custom fans (e.g. Sunon 5015) might need some adjustment to make sure they can be controlled correctly.
- You might have to try different options until you get good results.
- By default, this firmware does not use software PWM for fans. You can enable
FAN_SOFT_PWM
and adjust the PWM frequency by changing the value of#define SOFT_PWM_SCALE
. This will also affect heaters.
Base frequency is 7.6294 Hz. Incrementing the value by one doubles the frequency, although it also halves control resolution (to mitigate that loss, you can enable SOFT_PWM_DITHER
).
SOFT_PWM_SCALE | Fan & Heater PWM Frequency |
---|---|
0 | 7.6294 Hz |
1 | 15.2588 Hz |
2 | 30.5176 Hz |
3 | 61.0352 Hz |
4 | 122.0703 Hz |
5 | 244.1406 Hz |
... | ... |
For reference, Sunon MF50151VX-A99 fans run well on 7.6294 Hz (SOFT_PWM_SCALE 0
). The stock fan runs well on 30.5176 Hz (SOFT_PWM_SCALE 2
). I would only recommend going higher by SOFT_PWM_SCALE
if you know what you are doing. Keep the specifications of the electronics (e.g. transistors/MOSFETs) involved in mind when changing PWM frequencies. To use fast PWM frequencies without affecting heaters, you have to use FAST_PWM_FAN
instead.
- Uncomment
#define FAST_PWM_FAN
. To change the fast PWM frequency, change the value ofsetPwmFrequency(FAN_PIN, 1);
intemperature.cpp
, line 1132. Incrementing by one halves the frequency.
setPwmFrequency | Fan PWM Frequency |
---|---|
1 | 7812.48 Hz |
2 | 3906.25 Hz |
3 | 1953.12 Hz |
4 | 976.56 Hz |
5 | 488.28 Hz |
6 | 244.14 Hz |
... | ... |