Setting up Marlin 1.1.8 on a Prusa i3 Clone, and upgrading the Z-Axis Lead screw (Part 2)

In part one of this blog post, we dealt with download of the marlin firmware, along with the configuration of the Arduino IDE to be able to compile it. In this second part we will deal with configuration of the marlin firmware for our printer, along with another of necessary configuration changes to the IDE which will enable us to upload the firmware to our GT2560 board.

The next part assumes that your GT2560 board has got bootloader installed, and we can therefore upload the compiled firmware directly to it without any issues. There are various posts / tutorials out there about how to upload a bootloader to a GT2560. The only one that actually worked for me, was to use the Arduino IDE 1.0.1, along with a USBASP programmer connected to the GT2560 via the sd card / lcd pins. But more on that in another blog post soon.

Configuring Marlin for your printer

Now that we can communicate to our board using our IDE, it is time to configure the firmware for our printer. Most of the settings keywords are self explanatory, the only issue is that there are a lot of parameters you can fiddle with, so we will start with the  bare essentials  :-

  • Motherboard Type
  • Extruder Parameters
  • Stepper motor directions
  • Axis steps per unit
  • Printer limits
  • LCD Type

You might also want to take a look at the official Marlin documentation which is an extremely good source of information, as is the example_configurations folder within the firmware itself

In the Arduino IDE click on the tab labelled configuration.h

Scroll down to line 122, and change the motherboard to BOARD_GT2560_REV_A. Like everything else in this page these settings are for a Prusa i3 clone, with a GT2560 Rev A board. You can find a complete list of supported boards in the boards.h file in the firmware directory.

// The following define selects which electronics board you have.
// Please choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
   #define MOTHERBOARD BOARD_GT2560_REV_A
#endif

Scroll to line 358, comment out the 3 lines defining the extruder parameters, and update with your extruder parameters. You can get these parameters from your current settings by navigating to Control ->and scrolling down to the PID Settings

 // My Printer
#define DEFAULT_Kp 19.86
#define DEFAULT_Ki 1.00
#define DEFAULT_Kd 98.93

Scroll down to line 750 and update the motor directions

// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
#define INVERT_X_DIR false
#define INVERT_Y_DIR true
#define INVERT_Z_DIR false

Scroll up to line 533 to set the steps / mm for all the axis. The below two examples are for the standard M8 lead screw (M8x1.25) which is commented out, and the new M8x2.00) Lead screw which is the one currently in use.

Note that since the new lead screws travel 8mm per rotation, as opposed to 2mm per rotation of the original lead screw, the 3rd figure (2560) is reduced to 400 steps per mm

//#define DEFAULT_AXIS_STEPS_PER_UNIT { 78.81, 78.81, 2560, 114.13 } // MXL, Z M8=1.25, MK8
#define DEFAULT_AXIS_STEPS_PER_UNIT { 78.81, 78.81, 400, 114.13 } // MXL, Z M8=2.00, MK8

Scroll down to line 780 to set the printer hard limits

// @section machine

// The size of the print bed
#define X_BED_SIZE 190
#define Y_BED_SIZE 200

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 170

Finally, let’s setup the LCD Display. Once at it, I have upgraded mine to a full graphic lcd

Head to line 1312

/**
* LCD TYPE
*
* Enable ULTRA_LCD for a 16x2, 16x4, 20x2, or 20x4 character-based LCD.
* Enable DOGLCD for a 128x64 (ST7565R) Full Graphical Display.
* (These options will be enabled automatically for most displays.)
*
* IMPORTANT: The U8glib library is required for Full Graphic Display!
* https://github.com/olikraus/U8glib_Arduino
*/
//#define ULTRA_LCD // Character based
#define DOGLCD // Full graphics display

And to Line 1480

//
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER

Make sure that only one controller is defined, all the others must be commented out.

At this point, we need to compile our code and upload to our board.

If there are errors during the compilation, double check the changes we have done above. If you absolutely cannot figure our what went wrong, you can always use CTRL-Z or Edit -> Undo until the code compiles successfully. Once it does, you proceed with the other changes one by one, and try compiling after each change to make sure no errors are encountered.

Once the code compiles succesfully,  you may proceed to upload the firmware to the board by hitting the upload (→) button to the right of the compile (✓) button.

 

If all goes well, you should once again see the compiler output, followed by the linker and finally

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM2 -b115200 -D -Uflash:w:C:\Users\Johann\AppData\Local\Temp\arduino_build_922646/Marlin.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM2
Using Programmer : wiring
Overriding Baud Rate : 115200
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Wiring
Description : Wiring
Programmer Model: AVRISP
Hardware Version: 15
Firmware Version Master : 2.10
Vtarget : 0.0 V
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "C:\Users\Johann\AppData\Local\Temp\arduino_build_922646/Marlin.ino.hex"
avrdude: writing flash (116150 bytes):

Writing | ################################################## | 100% 29.01s

avrdude: 116150 bytes of flash written
avrdude: verifying flash memory against C:\Users\Johann\AppData\Local\Temp\arduino_build_922646/Marlin.ino.hex:
avrdude: load data flash data from input file C:\Users\Johann\AppData\Local\Temp\arduino_build_922646/Marlin.ino.hex:
avrdude: input file C:\Users\Johann\AppData\Local\Temp\arduino_build_922646/Marlin.ino.hex contains 116150 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 24.93s

avrdude: verifying ...
avrdude: 116150 bytes of flash verified

avrdude done. Thank you.

And That’s it. Once you get everything working the way it should, make a copy of the folder containing the “good” firmware source code, and keep it safe. You can then keep tinkering with the software, safe in the knowledge that if you break something, you can always revert to the known good version.

Let me know how it goes and happy 3d printing 🙂

2 comments On Setting up Marlin 1.1.8 on a Prusa i3 Clone, and upgrading the Z-Axis Lead screw (Part 2)

Leave a reply:

Your email address will not be published.

Site Footer