Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsphpl/58a917fd050f1104eb6766878cc5fec9 to your computer and use it in GitHub Desktop.
Save jsphpl/58a917fd050f1104eb6766878cc5fec9 to your computer and use it in GitHub Desktop.

Upgrading the RepRapPro Huxley to Marlin 1.1.0-RC8

1. Download Marlin

…from https://github.com/MarlinFirmware/Marlin/releases/tag/1.1.0-RC8

2. Backup current EEPROM settings

…in case they get overwritten through the firmware update. To do so, issue a M501 (set all parameters from EEPROM) followed by a M503 (dump current settings) and save the output of that command.

A dump from my Huxley with the original Marlin 1.0.1 RRP and 18-teeth T2.5 pulleys on the x- and y-axis:

Steps per unit:
M92 X71.110 Y71.110 Z4000.000 E980.000
Maximum feedrates (mm/s):
M203 X500.000 Y500.000 Z5.000 E45.000
Maximum Acceleration (mm/s2):
M201 X1000 Y1000 Z50 E1000
Acceleration: S=acceleration, T=retract acceleration
M204 S1000.000 T1000.000
Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s),  Z=maximum Z jerk (mm/s), K=advance_k
M205 S0.000 T0.000 B20000 X15.000 Z0.400 E15.000
M206 X0.000 Y0.000 Z0.000
M208 X155.000 Y150.000 Z90.000
PID settings:
M301 P12.000 I2.200 D80.000 W120
Thermistor settings: M304 Hh Bb Rr Tt, H0=Bed, H1..n=nozzle, b=thermistor beta value, r=series resistor, t=thermistor resistance as 25C
M304 H0
 B4100 R4700 T100000 M304 H1
 B3960 R4700 T100000
 FPU Enabled no

3. Adjust Configuration.h

These are the necessary adjustments to be made in Configuration.h before flashing the new Marlin.

Enable EEPROM

In order to make Marlin use the EEPROM to save and restore its settings uncomment the corresponding line at roughly line number 900:

#define EEPROM_SETTINGS

Set baud rate

#define BAUDRATE 115200

Choose the correct motherboard

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_MELZI
#endif

Temperature Sensors

Extruder thermistor is an RS 198-961, the heatbed thermistor is a VISHAY NTCS0603E3104FXT.

#define TEMP_SENSOR_0 10
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_BED 8

PID Parameters

The Kp, Ki and Kd values are obtained from the following lines of the previously taken EEPROM dump and could be used as our constants:

PID settings:
M301 P12.000 I2.200 D80.000 W120

As a starting point, you can use the settings below, which i determined using the auto-tune feature:

  #define  DEFAULT_Kp 81.88
  #define  DEFAULT_Ki 15.42
  #define  DEFAULT_Kd 108.66
  
  …
  
  #define  DEFAULT_bedKp 328.62
  #define  DEFAULT_bedKi 63.07
  #define  DEFAULT_bedKd 428.02

After flashing the new firmware, you should run an auto-tune on both the extruder and bed, in order to adapt for your specific hardware. The procedure is described below.

Axis directions

In my case i had to change the settings for stepper motor directions to the following:

#define INVERT_X_DIR false
#define INVERT_Y_DIR false
#define INVERT_Z_DIR false

Steps per unit

The steps per unit values can also be taken from the EEPROM dump and yield the following configuration in this example:

#define DEFAULT_AXIS_STEPS_PER_UNIT   { 71.110, 71.110, 4000, 980 }

Note that these settings don't apply for the stock RepRapPro Huxley. Obtain the actual values from your EEPROM dump instead, if you don't use 18-teeth T2.5 pulleys!

Printer Dimensions

The firmware has to know the length of each axis, in order to avoid crashes. The exact values depend on your specific hardware properties (including wiring paths, fans, etc.). These are the values i determined by manually driving the individual axes to their maxima where all other axes could still move freely:

#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS 145
#define Y_MAX_POS 145
#define Z_MAX_POS 80

Fix Heated Bed Thermistor Type

Set the correct temperature sensor type for the heated bed:

  #define TEMP_SENSOR_BED 12

Fix Heated Bed Pin

The heated bed MOSFET is connected to pin 12 on an Sanguinololu, but the Huxley uses an external MOSFET (right at the heated bed) which is connected to pin 10. To adapt for this, you could edit pins_SANGUINOLOLU_11.h and replace line 79 with

  #define HEATER_BED_PIN   10 // originally 12

4. Compile and Upload

Sanguino support for Arduino

In order to upload a new firmware to the Melzi v2 board, you need to add the Sanguino board definitions to your Arduino IDE. Append https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json with a leading comma to the Additional Board Manager URLs in Arduino preferences, then open the Boards Manager, search for Sanguino and install the offered package.

Modifications to boards.txt

The newly downloaded board definitions need some changes to work with the melzi. Alternatively to changing the following lines, you could add an entirely new device to maintain the ability to flash regular 1284Ps.

sanguino.menu.cpu.atmega1284p.upload.protocol=stk500v1
sanguino.menu.cpu.atmega1284p.upload.maximum_size=129024
sanguino.menu.cpu.atmega1284p.upload.maximum_data_size=16384
sanguino.menu.cpu.atmega1284p.upload.speed=57600

Board Selection

Select Sanguino from Tools>Board, then ATMega 1284P (16MHz) from Tools>Processor. Choose the serial port to which the Melzi is connected.

Make sure the JP1 jumper is closed. It is located at the very right of the PCB.

Upload

Check that everything compiles by clicking the Verify button in the Arduino IDE. If everything compiles without errors, Upload the new firmware to the board.

5. Test axes and home

The first thing we need to do after flashing is to check whether all axes are going to the right direction.

  1. With the printer powered off, move all axes to their approximate centers by hand.
  2. Switch on the printer.
  3. Move each axis 10mm into positive direction (G1 X10, G1 Y10 or G1 Z10).
  4. Watch if the axis moves away from the endstop.
  5. If it does, home it (G28 X, G28 Y or G28 Z). Keep one hand at the power plug so you can quickly unplug it in case the endstop doesn't trigger or the direction is wrong!
  6. If it moves towards the endstop (negative direction), invert it either by swapping the wires or by setting the corresponding constant in Configuration.h and re-flashing (see section 3 -> Axis Directions).

6. Auto-Tune PID values for extruder and bed

After the first startup, you should check if the temperatures reported reflect your current ambient temperature. If not, the thermistor settings might be off.

With the extruder at ambient temperature, auto-tune it using M303 E0 C8 S210 (Auto-tune extruder 0 in 8 cycles around 210°C). This procedure will take a couple of minutes and then show you the Kp, Ki and Kd values it determined. You can now re-flash your Melzi after inserting the values into Configuration.h, or you can write them to the EEPROM using M301 P<Kp> I<Ki> D<Kd>, followed by a M500 (save current settings to EEPROM).

Repeat the same procedure for the heated bed using the command M303 E-1 C8 S60. Use M304 instead of M301 to update the values for the bed. And don't forget to M500! The PID parameters for the bed can also be directly edited in the firmware, of course.

Note: In case you update the settings through Configuration.h, remember to update the EEPROM values as well. You can use M502, then M500 to reset all EEPROM parameters to their firmware defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment