RUG/Pennsylvania/State College/Electronics/Flashing tutorial

From RepRap
Revision as of 20:54, 23 December 2013 by Aem28 (talk | contribs) (Edit the configuration.h file)
Jump to: navigation, search

Welcome

The 'firmware' is a program loaded on the board fixed on the printer (Arduino or RAMBo). This program interprets the g-code commands send by the computer (using a g-code sender such as Pronterface) and turns them into electric signals to command the motors.

Flashing it consists in compiling this firmware on a computer and copying it on the board. Before compiling it, you will need to edit the source code to adapt the firmware to your printer.

Requirements

In order to compile the firmware and send it to the board, you need to download the Arduino IDE software.

You also need to download the Marlin firmware source code. You can either clone the repository if you're familiar with Github, or download the code as a .zip file (download ZIP button on the right).

Prepare the code

The Marlin firmware is written in C and C++. If you don't know those languages, be sure to respect the syntax when you change the code. Anyway, in order to flash a printer, you'll only need to edit a few files that were designed to ease this process.

Once you've downloaded the Marlin source code, un-zip it and open the Marlin-Marlin_v1/Marlin/Marlin.ino file. This file opens the Arduino editor, which allows you to change the source code. Note that you can actually use any text editor to change the code. However, if you do so you'll need to restart the Arduino IDE after you saved your changes, or else they won't be taken into account. All the files you may want to change are located in the same folder as the Marlin.ino file.

All the changes are referenced by line number. Those numbers are likely to change over versions.

Edit the configuration.h file

This file allows you to edit all the basic settings of the firmware. You need to edit it whenever you want to flash a printer. This file uses pre-processing commands (# in the beginning of the line). Pre-processing commands define constants when the code is compiled, saving both space and memory usage for the board. Basic logic can be used on those commands (essentially if/else conditions).

Line 28: Change the Baudrate to 115200:

#define BAUDRATE 115200

Line 73: Select a motherboard. The options are described above this line. For an Arduino with a single extruder:

#define MOTHERBOARD 33

Line 84: Choose the number of extruders. For a single extruder:

#define EXTRUDERS 1

Line 124: Define the temperature sensor used for each extruder and the bed. The options are described above this line. If you set the number of extruders to 1, the sensors defined for the other extruders won't be used (you don't need to set them to 0). For a thermocouple:

#define TEMP_SENSOR_0 -1

Line 149: Define the heater max temperature. It depends on the working temperature of your printer. A good value is around 20 degrees higher than the working temperature (high enough so that the temperature can be increased a little without throwing an error, and low enough to prevent any damage to the extruder if someone sets a temperature way too high). If you don't know the working temperature of the printer yet, you can use the default value of 275°C:

#define HEATER_0_MAXTEMP 275
Line 234: Define the extrusion min temperature. A goo value is around 20 degrees less than the working temperature. If you don't know the working temperature of the printer yet, you can use the default value of 170°C:
#define EXTRUDE_MINTEMP 170

Line 290: Disable the Z axis when it's not in use. This option should be set to true (the Z-axis uses an irreversible mechanism, therefore there is no need to hold the motor to it's position). This allows you to adjust the Z-height in the beginning of the print, and it prevents the Z-motors from overheating. Note that for the other axis, the 'disable' option should be left to true.

#define DISABLE_Z true

Line 293: In order to have the same default direction on each printer, define the 'invert direction' options as follows:

#define INVERT_X_DIR false
#define INVERT_Y_DIR true
#define INVERT_Z_DIR false
#define INVERT_E0_DIR false
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false 

Feed rates depend on your printer design, the motors and the board. You can determine them with the following tables:

Board Motherboard factor
Arduino M = 1
RAMBo (v < 1.2) M = 0.5
RAMBo (v ≥ 1.2) M = 1
Z-Axis design Z design factor Z feed rate factor
Two motors Zd = 1 Zf = 2.4
One motor + belt Zd = 2.625 Zf = 1
Extruder type Extruder factor
Open Hybrid Mendel E = 1
Extruder 1040222 E = 1.07
Extruder 1040220 E = 1.78

Then apply the following formulas:

Homing feed rate: { 1800, 1800, Zf * 60, 0 }
Steps per unit: { 80.376 * M, 80.376 * M, 2560 * M * Zd, 645 * M * E }
Max feed rate: { 30, 30, Zf, 30 }

Example for an Arduino board, with two Z-motors and an Open Hybrid Mendel extruder:

Line 395: Change the homing feed rates. They are defined in mm/min:

#define HOMING_FEEDRATE { 1800, 1800, 144, 0 }

Line 399: Change the axis steps per unit. They depend on the reduction ratio of the gears you use:

#define DEFAULT_AXIS_STEPS_PER_UNIT { 80.376, 80.376, 2560, 645 }

Line 400: Change the max feed rates. They are defined in mm/s:

#define DEFAULT_MAX_FEEDRATE { 30, 30, 2.4, 30 }

Edit the pins.h file

Edit the configuration_adv.h file

Flash the code

Troubleshooting