I recently made a custom printhead for my snapmaker (see Dragon Burner adapter for Snapmaker 2.0 QC by theDude | Download free STL model | Printables.com ) which require some modification of the firmware and I didn’t find a lot of information on how to do this so I decided to share my experiences here.
Disclaimer: Using custom firmware on your printer will most certainly void your warranty and in the worst case destroy your machine, try responsibly and at your own risk.
The changes that I have made work well for me but I can’t guarantee that it will for everybody.
Also I would recommend you mark your changes in the source code to be able to find them later one, I commented OGSM after every line for this purpose.
The Snapmaker 2.0 firmware is based on Marlin but adds quite some things on top which makes adjustments to the firmware a bit less straight forward.
Here is an overview of how everything is structured:
I’m no programming expert so alot of what will be written here is just my understanding based on some limited C skills and trial and error.
The Snapmaker controller has its own firmware which is not open source as far as I know.
Then the controller and the individual modules (print head, CNC, Laser etc.) have their own seperate firmwares but they somethimes have dependencies between them.
I have made the following adjustments:
- Changed the thermistor froma an NTC3950 to an 104NT
- Changed the max. temp from 275°C to 300°C
- Change the direction of the extruder motor
So here is how I did it:
1.) Normaly in Marlin you could just select the correct thermistor in the Configuration.h file.
But since in the Snapmakers the temperature measurement and conversion is done directly on the tool head and not in the main controller you will need to edit the toolhead firmware found here: GitHub - Snapmaker/Snapmaker2-Modules · GitHub
Unfortunately I had to do it in a quick and dirty way from a programming point of view since I never got it to work trying to do it in the proper way. Instead of adding a new table and adjusting all the cases I just edited the table which is used by default.
In the file Marlin>src>core>thermistor_table.cpp you can find the conversion table from the ADC (analog to digital converter) to the reported temperature. This temperature converts the 12 bit (4096 steps) ADC voltage reading over the thermistor circuit into the actual temperature.
This is how the adjusted code looks like:
const int32_t temptable_ntc3950[][2] = {
/* OGSM2.0 original values:
{ OV( 4), 938 },
{ OV( 91), 300 },
{ OV( 118), 290 },
{ OV( 136), 272 },
{ OV( 169), 258 },
{ OV( 201), 247 },
{ OV( 236), 237 },
{ OV( 270), 229 },
{ OV( 309), 221 },
{ OV( 343), 215 },
{ OV( 380), 209 },
{ OV( 415), 204 },
{ OV( 454), 199 },
{ OV( 487), 195 },
{ OV( 533), 190 },
{ OV( 563), 187 },
{ OV( 605), 183 },
{ OV( 651), 179 },
{ OV( 687), 176 },
{ OV( 766), 170 },
{ OV( 839), 165 },
{ OV( 918), 160 },
{ OV(1005), 155 },
{ OV(1098), 150 },
{ OV(1220), 144 },
{ OV(1330), 139 },
{ OV(1472), 133 },
{ OV(1811), 128 },
{ OV(1729), 123 },
{ OV(1895), 117 },
{ OV(2068), 111 },
{ OV(2245), 105 },
{ OV(2394), 100 },
{ OV(2542), 95 },
{ OV(2689), 90 },
{ OV(2832), 85 },
{ OV(2996), 79 },
{ OV(3175), 72 },
{ OV(3246), 69 },
{ OV(3337), 65 },
{ OV(3500), 57 },
{ OV(3537), 55 },
{ OV(3605), 51 },
{ OV(3697), 45 },
{ OV(3775), 39 },
{ OV(3888), 28 },
{ OV(3927), 23 },
{ OV(3966), 17 },
{ OV(4005), 9 },
{ OV(4038), 0 },
{ OV(4062), -10 },
{ OV(4083), -27 },
{ OV(4085), -30 }
*/
{ OV( 45), 350 },
{ OV( 52), 325 },
{ OV( 71), 300 },
{ OV( 81), 290 },
{ OV( 106), 272 },
{ OV( 131), 258 },
{ OV( 156), 247 },
{ OV( 184), 237 },
{ OV( 211), 229 },
{ OV( 243), 221 },
{ OV( 270), 215 },
{ OV( 300), 209 },
{ OV( 329), 204 },
{ OV( 361), 199 },
{ OV( 389), 195 },
{ OV( 427), 190 },
{ OV( 452), 187 },
{ OV( 488), 183 },
{ OV( 527), 179 },
{ OV( 558), 176 },
{ OV( 627), 170 },
{ OV( 691), 165 },
{ OV( 762), 160 },
{ OV( 840), 155 },
{ OV( 925), 150 },
{ OV(1038), 144 },
{ OV(1142), 139 },
{ OV(1278), 133 },
{ OV(1401), 128 },
{ OV(1532), 123 },
{ OV(1699), 117 },
{ OV(1877), 111 },
{ OV(2062), 105 },
{ OV(2221), 100 },
{ OV(2381), 95 },
{ OV(2542), 90 },
{ OV(2700), 85 },
{ OV(2883), 79 },
{ OV(3084), 72 },
{ OV(3166), 69 },
{ OV(3268), 65 },
{ OV(3453), 57 },
{ OV(3494), 55 },
{ OV(3572), 51 },
{ OV(3675), 45 },
{ OV(3762), 39 },
{ OV(3885), 28 },
{ OV(3927), 23 },
{ OV(3968), 17 },
{ OV(4009), 9 },
{ OV(4041), 0 },
{ OV(4064), -10 },
{ OV(4084), -27 },
{ OV(4086), -30 }
};
If you use a diffrerent thermistor than either a NTC 3950 or 104NT you can create your own table with the resistance table of the thermistor and the following formula:
ADC = (R_thermistor / ( R_thermistor + R_pull_down)) * 4096 (R_pull_down being 4.7kOhm)
Make sure you have enough datapoints in the temperature range you intend to print.
2.) Changing the max. temperature is a little more complicated since you will have to adjust several things in different places for it to properly work. Don’t exceed the temperature that your hotend can handle safely. (e.g. the original Snapmaker hotend is PTFE lined which will start to emit all sorts of nasty stuff at higher temperatures)
In the controller (https://github.com/Snapmaker/Snapmaker2-Controller) you will have to adjust the following:
This section in snapmaker>src>module>toolhead_3dp.cpp will define the max. temperature that the Snapmaker controller can input to marlin e.g. over Luban.
// update max temp firstly, CAN callback will use it to judge max_temp error
UpdateHotendMaxTemp(310); //OGSM was 275
This section in Marlin>Configuration.h defines the max. hotend temperature that marlin will allow the hardware to go to.
// Above this temperature the heater will be switched off.
// This can protect components from overheating, but NOT from shorts and failures.
// (Use MINTEMP for thermistor short/failure protection.)
#define HEATER_0_MAXTEMP 310 //OGSM 290
#define HEATER_1_MAXTEMP 310 // OGSM 275 for all following
#define HEATER_2_MAXTEMP 310
#define HEATER_3_MAXTEMP 310
#define HEATER_4_MAXTEMP 310
#define HEATER_5_MAXTEMP 310
#define BED_MAXTEMP 150
#define CHAMBER_MAXTEMP 100
In the toolhead firmware Marlin>src>core>pid.h you will have to adjust the following:
#define DUAL_EXTRUDER_MAX_TARGET_TEMPERATURE 310
#define DUAL_EXTRUDER_MIN_TARGET_TEMPERATURE 0
#define DUAL_EXTRUDER_MAX_TEMPERATURE 310
#define DUAL_EXTRUDER_MIN_TEMPERATURE 0
#define SINGLE_EXTRUDER_MAX_TARGET_TEMPERATURE 310 // OGSM2.0 original value: 275
#define SINGLE_EXTRUDER_MIN_TARGET_TEMPERATURE 0
#define SINGLE_EXTRUDER_MAX_TEMPERATURE 310 // OGSM2.0 original value: 300
#define SINGLE_EXTRUDER_MIN_TEMPERATURE 0
3.) This change is fairly simple and works like it would in any other Marlin machine:
In Marlin>Configuration.h you can also find most of the other generall firmware settings.
// For direct drive extruder v9 set to true, for geared extruder set to false.
#define INVERT_E0_DIR false //OGSM2.0 original value true
I hope this helps to get some overview and some guidance for everyone who wants to make their own custom firmware.
If you have any inputs, corrections or additions please post them here so we can collect all the information in one place.
Thanks and happy printing