Marlin from http://marlinfw.org/is one printer SW that uses the arduino platform. Marlin.ino
is the file to open in Arduino IDE.
Marlin is full of option to suit many 3D printers. Download a tagged version from http://marlinfw.org/meta/download/ or https://github.com/MarlinFirmware/Marlin/tags . 3D printer vendors provide already configured printer firmware for their models. A drawback is that those might create a fork of the original Marlin SW and therefore SW version control might be getting messy.
To test Marlin a printer server program as octoprint can be used. octoprint contains a featured terminal tab and can filter the interesting information.
Also terminal program as minicom or putty can be used. Open the port with the correct baudrate (Note: 250000 might not be supported by Linux, in worst case the Marlin SW must be recompiled using the 115200 baudrate).
When pressing reset Marlin prints out a lot of useful information how it got compiled and configured.
Marlin is a mature software and includes some features to prevent the printer from damaging itself or doing stupid things. Such a check are:
Preventing the extruder to turn when it is cold
Check if temperature is suitable in absolute range (short between two wires or broken wired of sensor) but also dynamically if the temperature regulation sees something not as expected.
If everything is set up correctly, open the Marlin.ino file in the Arduino IDE. Check that the correct hardware is selected (Board, Processor, Port) via the Tools menu:
Then Sketch -> Verify/Complie and when done do Upload
Unfortunately setting up Arduino IDE, Marlin on Linux might end up in some troubles.
If the Avr compiler binary is downloaded and added somewhere it can not be found. A workaround is opening a console and PATH=$PATH:/<path to avr>
/avr8-gnu-toolchain-linux_x86/bin
export PATH
$PATH
arduino
This will set the PATH environmental variable and then start arduino
Alternatively check what you find in /usr/share/arduino/hardware/tools/avr
and if it does not exist add the link
ln -s /<path to avr>
/avr8-gnu-toolchain-linux_x86/bin /usr/share/arduino/hardware/tools/avr
The marlin firmware might have dependencies with the arduino IDE version. Either work with older arduino versions or an older marlin software.
Self built avr compilers might have issues, use the ones from the arduino IDE or a binary compiler from Microchip/Atmel.
Usually all custom settings are done in the Configuration.h
file.
Load Marlin.ino
in the Arduino IDE, edit Configuration.h
then Sketch compile/Verify, Tools Port to check the port and then Sketch upload.
Most settings are self explanatory.
Certain settings can be modified and stored to none volatile to EEPROM.
#define EEPROM_SETTINGS
If this EEPROM feature is enabled then it needs to be erased when a new marlin version is programmed. This can be done by selecting avrdude using the programmer)
from the user interface (or viaMore debug information can be created with DEBUG_LEVELING_FEATURE. Once built in, it needs to be enabled with M111 S32
Marlin can interact with the printer server as Octoprint
#define HOST_ACTION_COMMANDS
In Configuration_adv.h
to have interaction with printer servers as OctoPrint
The Z-axis is critical to set the first layer. Reading the end stop is therefore vital.
Marlin does this very sophisticated however it might happen that noise cause false triggering. Setting ENDSTOP_NOISE_FEATURE might help. This software filter produces delay and is therefore less accurate and more computing intensive. Better is placing a 100nF capacitor and having a 4k7 pull up resistor on the electronic input feed by the end stop switch.
Z=0 means the ideal bed where it is printed. When adjusting the bed it is recommended to have a small gap of about 0.1mm between nozzle and bed, this results in a Z-offset of -0.1mm. Minus since it is below the ideal bed level. Instructions tell using a paper or a feeler gauge and adjust the hight so it can just slide between the nozzle and the bed. Therefore adjust all leveling screws and check the gap above them.
The X and Y end stops are much less critical since they just define where the object is on the bed.
A bit tricky is the extruder direction that might to be inverted. On the user interface positive values mean extruding and negative retracting.
Tricky is also to get the steps/mm values for the stepper motors since this depends an the mechanics, motors and stepper drivers micro-stepping setting. There are calculators on the web to determine this https://www.prusaprinters.org/calculator/.
A 1.8° (200 steps per revolution) motor driving a Z axis with 1.5mm thread pitch has therefore a resolution of 1.5mm/200=7.5um.
Not all layer heights are possible. If the steps do not match with the layer heights then an aliasing effect might (or might not) be visible on the vertical surfaces.
Layer heights that are a multiple of 7.5mm as 0.15mm and 0.3mm are possible. Layer heights as 0.1mm, 0.2mm or 0.4mm should be avoided.
To set a odd looking layer height as 0.105mm, 0.21mm or 0.405mm give then complete steps.
This is without micro stepping. Micro stepping requires to have power in the z motor, if power is turned off the motor moves to a complete step.
The 3rd number in DEFAULT_AXIS_STEPS_PER_UNIT is the number of steps (including micro steps) required to lift 1mm. (200 * 16) steps / 1.5 mm = 2133.33 steps/mm
A 1.8° (200 steps per revolution) motor driving X/Y with a 20 tooth pulley and a GT2 pitch 2mm belt will have 200 * 16 / (20 * 2) mm = 80 steps/mm
Printing a cube will confirm that the dimensions are correct.
DEFAULT_MAX_FEEDRATE in mm/s, DEFAULT_MAX_ACCELERATION in mm/s2 and DEFAULT_<n>
JERK in mm/s3 are a crucial parameter to not having the stepper motors loose some steps.
There are other acceleration parameters as DEFAULT_ACCELERATION that is used internally be the marlins planner but are then constrained further if needed.
Regulating the temperature requires some parameters. Those parameters can be automatically determined by running the command M303 E<n>
S<temp>
C<m>
in a terminal as found the printer server Software OctoPrint. OctoPrint allows to filter for just the desired messages. A standalone terminal program as putty can also be used. This command heats up Extruder <n>
to <temp>
°C and stays at the temperature for <m e.g. 12>
cycles. Finally Marlin returns PID autotune finished!
containing Kp Ki Kd parameters of the PID temperature control.
As temperature use the highest material temperature to be printed as: M303 E0 S240 C12
Consider turning the fan on (M106) before determining the regulator parameters with M303. If the fan cools too much so the target temperature can not be reached, then M303 will fail with a timeout error. Reduce speed and restart and do not forget to tell the slicer that it is not allowed to run the fans at full speed.
It might happen that
#define WATCH_TEMP_PERIOD 40 // Seconds #define WATCH_TEMP_INCREASE 4 // Degrees Celsius
must be adjusted in Configuration_adv.h
to remove E0 heat errors
The same PID control could also be made for the heated bed where E-1 could be inserted in the M303 command. However this has mostly no sense since the bed is operated in Bang-Bang mode (on/off instead of PWM). Therefore no PID parameters are used for the bed. Bang-Bang obviously can not controll the temperature so well as PWM.
M303 E-1 will not work when marlin is configured having a Bang-Bang mode heated bed.
The AUTOTEMP feature increases the hot-end temperature depending on the amount of material flowing through the nozzle. It can be configured with M109 and M104
The bed will never be completely horizontal or flat.
Marlin can correct this. Before doing this, adjust a 0.1mm gap between nozzle and bed above the leveling screws as good as possible. Use a feeler gauge to know the Z-Distance between nozzle and bed, or as other instructing say use a paper. Papers have different thicknesses and are around 0.1mm.
Usually bed probes are used, but manual mesh bed leveling can also be done manually using the LCD menu.
When selecting in the LCD bed leveling then new terms appear:
The fade height this is the height in mm where the correction of not having a flat bed will stop.
Bed Z is the Z-offset, if there is a gap of 0.1mm then the value is -0.1. However assume it is 0, and then correct the Z-offset distance in the slicer.
Heat up the bed to the temperature used during printing
The nozzle will typically be moved to 9 points in a mesh where the same Z-offset can be adjusted in the LDC using the feeler gauge or the previously used paper.
G29 S0 will show if there is a mesh, if so M420 S1 will use it. G28 auto home will by default turn bed leveling off. There are options to change this behavior.
M500 stores the mesh into EEPROM
Storing the mesh in EEPROM is a must for manual board leveling.
During printing of a layer the Z axis is altered when mesh bed leveling is active.