# Specific 3D Printers, Scanners, & Hardware > RepRap Format Printer Forum >  Max temp limit in marlin

## CSMonkey

Hi Guys,

I'm running a Mendlemax 2 /RAMBo  with E3Dv6 /thermocouple successfully at 380°C to print PEEK and PEEK composites as part of my research project. Originally in Configuration.h I set the max temp to 400° and all was well.
#define HEATER_0_MAXTEMP 400

now I'm looking at other materials that need a higher temperature.
But when I want to go higher, I changed -- 
#define HEATER_0_MAXTEMP 500 but the software still errors out at 400° when I heat up the hotend

Is there another value in the temperatures pages that is overruling the config value? I can't find a clear table for the thermocouple like the thermistors table so I'm a bit stumped for ideas. 

Has anyone got a working solution they could share or advise?

Rich

----------


## Roxy

Are you sure you rebuilt the firmware and got it uploaded successfully?   What exactly is the error it sends?

----------


## CSMonkey

Yes it's rebuilt and uploaded, and is working until I hit 400°C then -
_Setting hotend temperature to 270.000000 degrees Celsius._
_Setting hotend temperature to 290.000000 degrees Celsius._
_Setting hotend temperature to 310.000000 degrees Celsius._
_Setting hotend temperature to 330.000000 degrees Celsius._
_Setting hotend temperature to 350.000000 degrees Celsius._
_Setting hotend temperature to 370.000000 degrees Celsius._
_Setting hotend temperature to 390.000000 degrees Celsius._
_Setting hotend temperature to 398.000000 degrees Celsius._
_Error:0_
_[ERROR] Error:0_

_: Extruder switched off. MAXTEMP triggered !_
_Error:Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)_
_[ERROR] Error:Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)_

_Setting hotend temperature to 0.000000 degrees Celsius.

_
I'm using a K type thermocouple [ temp sensor -1 ] with success for printing at 380°C with the MAX temp set at 400°. But the new sketch has been changed to 500°C, but still errors at 400°C

I can see lots of thermistor tables, but very little detail on the thermocouple definitions. Is the Thermocouple linked to a thermistor table?

Sorry for the noob questions, but thanks for any help

Rich

----------


## Roxy

It might be possible that the temperature is being checked multiple places.   It would not surprise me if there are multiple sanity checks for this.   But I searched the entire code base for 400 and didn't find anything.  I also looked at all the places an AD595 is handled.  I didn't see any limits at 400 C.    

First question:  Are you sure the AD595 reports values bigger than 400 C. ?   The reason is, if it doesn't, the temperature being reported will be stuck at 400 even though the software thinks it should be going up.  It will eventually trigger the thermal runaway code.   Also, a lot of the thermistor tables end at 400 C.   I wonder if that is a coincidence.

But checking the AD595 data sheet at:  http://www.analog.com/media/en/techn.../AD594_595.pdf

It says: The AD594/AD595 is available in two performance grades. TheC and the A versions have calibration accuracies of ±1°C and
±3°C, respectively. Both are designed to be used from 0°C to
+50°C, and are available in 14-pin, hermetically sealed, sidebrazed
ceramic DIPs as well as low cost cerdip packages.

That doesn't even sound like this part should be used by Marlin ????    I suggest you go to https://github.com/MarlinFirmware/Marlin/issues  and ask for some help.   There are a number of thermal experts over there and I bet they have seen this before.

----------


## Mjolinor

0 to 50 is the ambient temperature. With  K type thermocouple it is good up to 480 IIRC.

----------


## Roxy

> 0 to 50 is the ambient temperature. With  K type thermocouple it is good up to 480 IIRC.


Yeah...  I think I found a bug in Marlin.   This may be a work around:   

In Temperature.cpp change these lines:



```
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
static int minttemp[EXTRUDERS] = { 0 };
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(16383)
```

to




```
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 32000 , 32000  , 32000 , 32000 );
static int minttemp[EXTRUDERS] = { 0 };
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(32000)
```

I don't know that this will work...   Be very careful with this modified code.

----------


## Mjolinor

If all you need are higher temperatures but can put up with the display being wrong then a resistive potential divider direct on the thermocouple will allow that to happen. The disadvantage would be that it would read 300 at 400 and 400 at 500 etc but it would still be accurate enough if you allowed for the constant temperature error

----------


## Roxy

> If all you need are higher temperatures but can put up with the display being wrong then a resistive potential divider direct on the thermocouple will allow that to happen. The disadvantage would be that it would read 300 at 400 and 400 at 500 etc but it would still be accurate enough if you allowed for the constant temperature error


That's an interesting idea...   You probably would need to adjust the PID control numbers too because that algorithm would be getting incorrect error numbers.   But that would not be too tough to do.

Also...  You want to avoid doing it, but you can turn off the Thermal Protection code if you need to.  It is controlled by the 

#define THERMAL_PROTECTION_HOTENDS     in the Configuration.h file.

Also, another thing you can try is this.  It may be you are having a hard time getting hotter and hotter.  It may take more and more time to get a little bit hotter.  
You can change these numbers in Configuration_adv.h:

#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 60 // Seconds
#define THERMAL_PROTECTION_HYSTERESIS 1 // Degrees Celsius
#endif

And I just got reprimanded over in this thread:  https://github.com/MarlinFirmware/Marlin/issues/2857    There is also a 

#define WATCH_TEMP_PERIOD 16                // Seconds
#define WATCH_TEMP_INCREASE 4               // Degrees Celsius

On the heating up side, probably WATCH is more important.

----------


## CSMonkey

Hi Roxy,

Thanks for the quick response, really appreciate the help.

I tried with your modified code in temperature.c but I get an error pointing array extruders1 when compiling. I did remove the reference to Heater 3 as my original only had heaters 0,1,2 and ended up with the code below

I can't attached the INO file as it's an invalid file for the forum, and I'll try to avoid copy/pasta the whole text file.




> static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP );
> static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 32000 , 32000 , 32000 );
> static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0 , 0 , 0 );
> static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 32000, 32000, 32000 );


I just tried the code above, but again at 400°C it triggered max temp error. I didn't get chance to try with the thermal protection disabled, and heating up to ~395° is pretty quick


Mjolinor, interesting idea. I'll have to investigate.

----------


## printbus

For completeness, when you start talking about errors on temperatures measured by Marlin and RAMPS with a thermocouple, there's another substantial error component to consider. I ran into this compiling the data for thread Comparison of Type 1 thermistor and E3D thermocouple temperature measurements

That testing used a thermocouple adapter board from E3D that is based on the AD597, a less precise version of the AD595.  These and similar amplifiers all output a voltage that changes linearly with temperature.  The thermistor and thermocouple measurements all leverage the analog-to-digital (ADC) converter in the processor. Marlin (or perhaps the underlying Arduino libraries)  confugures the AVR processor to use the board VCC, nominally 5V, as the analog voltage reference to be considered as "full scale" by the ADC.  In converting the ADC sample value to a temperature, Marlin firmware (at least as of the becdac fork in late 2014) assumes an exact 5.0V as the supply voltage.  But regulator output voltages aren't all that precise, possibly leading to errors in the voltage being measured by the ADC. For thermistors, it turns out this doesn't cause an error since the VCC being applied to the ADC reference input is also being applied to the resistor divider containing the thermistor. If VCC is high, the ADC reference input will be high but the voltage coming from the resistive divider will also be high by the same percentage.  So, no error from the VCC being off from 5V for the normal thermistor approach. 

Thermocouple amplifiers like the AD595 are designed to output a voltage linear with temperature, and are designed for that output voltage to remain fairly stable regardless of the supply voltage, as they should. But this creates an error source between what the thermocouple amplifier is outputting and how RAMPS/Marlin measures it. For a given temperature and thermocouple amplifier output voltage, Marlin will result in a temperature result that changes as the electronics VCC (and the ADC reference input) changes. Options around this include hacking the electronics to provide your own VCC source set exactly to 5.00V like the Marlin conversions assume, or measuring your VCC and modifying the Marlin temperature calculation algorithm to reflect your actual voltage. The latter has another issue, however, in that the electronics VCC might vary over temperature or with different loading.  If so, this could result in a varying amount of temperature measurement error. 

None of this explains why Marlin is hitting MAXTEMP in this case, but I thought I'd point out this error source.

----------


## CSMonkey

Thanks for the feedback. I'm going to try B3D's 500C thermistor with the thermotable in their support pages as an alternative. I'm not back in the office to play with the hardware until the New Year, so hopefully it will get delivered by then.

Rich

----------


## Despistado

Good day, im new here, looking for answer on internet about my issue i found this and I have the same trouble, my temperature sensor reading dont get more than 395-400, im trying to get 420 using ad497 from e3d, the first time I thought was the simplify3D but then change to repetier and the same result, then i try with adafruit MAX31855 and with the demo from adafruit works great i can read more than 700 celsius, but I dont know how to wired and installed on marlin, or where to change to my own pins, or i dont know if is some kind of limit in marlin firmware, is there anyone has solved this?, can help me please.

----------


## oliviaisla

good work what other material you like to try now ?

----------

