Welcome! Log In Create A New Profile

Advanced

Choosing Thermistor based on table - Marlin

Posted by Ohmarinus 
Choosing Thermistor based on table - Marlin
April 10, 2013 05:28PM
Hi guys, bought a new hotend, but I'm afraid to turn it on because I don't know which Thermistor I have!

I have a table with Ohm values, but I have NO idea how to convert or compare this to anything that is in the Marlin firmware in the thermistor table.

Here is the information about the ohms at which temperatures:
[www.smdking.com]

Can anyone give me the golden clue?


Btw, found this:
[calculator.josefprusa.cz]

But I have no idea what r0 r1 r2 and !?BETA?! is.. I am lost.

Also, the list that the site regerates looks nothing like the list in my Marlin so I would have no idea how to implement the data in that list again in Marlin. Pffff.


Oh and here is the thermistor itself:
[www.ebay.nl]

And this is the Hotend that it's in:
[www.ebay.nl]

Edited 3 time(s). Last edit at 04/10/2013 05:51PM by Ohmarinus.
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 06:14PM
Normally its much easier if you have any kind of method to read real hotend temperature. But i think i remember you said you dont, so here comes a way based on what you linked.

The thermistor table is a 2 column table. It links left values to right values, nothing more matters. More or less like the table you have in that document.

Left side are adc values, which are given by the voltage the adc reads. The voltage adc reads comes from a voltage divider where thermistor is on the low side with a 4.7k pullup: V * Rt / (Rt+4.7k). This is then split in 1023 intervals in adc comparators, where lowest is 0 adc value and highest is 1023 = adc value = coresponing to your logic level voltage (5v value can be say 4.92 or 4.82 etc). In this case just highest is never reached coz the upper resistor in divider is fixed, but otherwise thats the max of what an adc pin can read.

Right side column are temperatures. For most firmwares, are exact temperature, for Teacup are temps * 4 i guess coz the firmware doesnt need to do a certain multiplication all the time, which is neat and thoughtful.

To make your own talbe, you need If you figure out to make left side column math. Then pick 20 values from that table, like interval ends like zero and 300, then mostly values where you are interested in about 10C intervals, and 20-30-40C intervals where you are not interested.
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 06:21PM
For that addon try beta is 3950 and common electronics use r1=0 and r2=4700 ohms. At r0 you can put 100k and at t0 25.
However this doesnt guarantee your temps will be real unless you double check them.
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 06:23PM
Hi NoobMan, thanks! Nope, I don't have the equipment, but the tables are also good since they are measured by the reseller.

I re-read your reply about three times, but I am totally getting lost in the math. For things like mechanics, distances, sizes, volumes etc I am very good, but when it comes to 'low side' 'lullup' V*Rt ?? adc comparators I am completely losing track of what you are saying. Maybe it is because I am an art student trying to to math things.. And obviously we can't have it both ways winking smiley I can play you a song on the guitar, think of beautiful solutions for a logical problem, design you a chair or even a home, but more on a conceptual level...

Wish I was better at math.

The end of your reply makes sense though, the whole thing is that I really don't know how those numbers are made.

In my Marlin firmware it says this:
#define OVERSAMPLENR 16

I imagine this is the multiplier for the values in the left column, because:

const short temptable_1[][2] PROGMEM = {
{       23*OVERSAMPLENR ,       300     },
{       25*OVERSAMPLENR ,       295     },
{       27*OVERSAMPLENR ,       290     },
{       28*OVERSAMPLENR ,       285     },
{       31*OVERSAMPLENR ,       280     },
{       33*OVERSAMPLENR ,       275     },
{       35*OVERSAMPLENR ,       270     },
{       38*OVERSAMPLENR ,       265     },
{       41*OVERSAMPLENR ,       260     },
{       44*OVERSAMPLENR ,       255     },
{       48*OVERSAMPLENR ,       250     },

And so on.
But still, I am clueless and *afraid* to really make that step of creating my table. I really don't want to destroy anything.
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 06:33PM
Aha, V is your logic level voltage, theoretical 5,00 practically something around it.

A voltage divider in our case with resistors, are 2 resistors in series between V and Gnd. In our case thermistor is at the ground side.
Typically a resistor that is tied to V+ is referred to as pullup and one tied to gnd is referred to as pulldown. Although thats usual when the line doesnt have other reistors so it "pulls" the line to either logic value high or logic low, that is to V+ or gnd. So i used the term bit out of context.

The voltage that matters is the one in between them, which is proportional to R_lower_ resistor / R_total which then doesnt have units and it needs to * V to get actual voltage.

If V is logic voltage and Rupper is = 4700 ohms, and Rt is the current value of thermistor resistance then current voltage is V * Rt / R_total or otherwise V * Rt / (Rt+Rupper) = V * Rt / (Rt+4700).
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 06:39PM
When you make your table should look something similar like that from the addon with the mentioned values. Quick comparison should look very similar in all values.

Tho rather prefer the values from manufacturer as function instead the theoretical beta function, the latter has is bound to have errors from the start. I honestly dont have any clue whats the deal with that OVERSAMPLENR, sry for that.
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 06:57PM
I am even more confused, because with my older hotend I have measured the voltage to be around 11.2V

Is this because my new hotend has two resistors? Am I correct? Is that why there is two holes on both sides of the alu block to evenly warm up the hotend? And is this why there is a naked crimped wire sticking out of the hotend on the front?

Hmm, things start to make sense, thanks!
I will re-read tomorrow because I still don't feel like I am able to safely make a table.
Re: Choosing Thermistor based on table - Marlin
April 10, 2013 07:21PM
Huh, what, no.

The logic voltage is 5v, in our case, this is the voltage that thermistor "is involved in". Microcontroller pins dont take any more than that. There is a voltage regulator onboard that takes in 12v and from it makes 5v and feeds it to microcontroller and wherever needed.

The voltage that the hotend resistor has, comes directly from psu, so its 12v, or whatever psu gives it. The hotend resistor and the thermistor just so happen to be on the same block of aluminium, one near another, but they are not electrically connected, and they work at different voltages. And if you mistakenly short 12v from hotend to the 5v thermistor wire, you will probably burn at least one pin of the microcontroller, if not worse.

Dunno why there are 2 holes, lets check it out. From the picture seems like the 2 hotend resistors are connected in series, so they probably have lower values like ~3-4 ohms each, giving a total resistance similar to what a single resistor would give, but with a double contact area which is very good. It could dissipate more heat and power while resistors would be "wearing out" less. Perhaps something like that would be the reason.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 03:09AM
So, the oversampler number in the Marlin table is 16, can I then say:
Ohms at given temp divided by 16 is the value for that temperature in the table?

Sorry I was sleepy, ofcourse I understand that the thermistor runs on 5v smiling smiley

I have contacted the reseller but he didnt have a clue for how to apply the table..

- Marinus
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 07:25AM
Again, i dont have a clue whats with that oversampler, and why its there, so i try to guess.

In principle an oversampler is a good ideea when there is a fast changing input. But well, that is really not our case. So i guess our case is that some software guy who didnt understood enough on the topic, implemented this and somehow hoped the errors will go away. Couldnt of done enough research as apparently didnt noticed the first thing, that is 10uF cap that sits on the input. So i think ADC reads perfectly ok and gets good and valid values as it is, could even be sampled more rarely for that matter. The error comes from that it tries to interpolate the read adc with wrong reference. The table represents a theoretical function which, especially at high temps, becomes more and more distant than the real behavior. Partly because of the function, but mostly coz after when thermistors stops being "interchangeable" the errors keep increasing exponentially, which becomes more and more issue at high temps. Sort of this implementation is probably a good "bloat" example.

Sort of the table values are wrong, and oversampling cant possibly help, it will just become a burden and create more comparator noise and stuff like that. Thats my opinion ofc, and for this i would search where is the "off" setting of the oversampling, and i would turn it off if it would be in a firmware that i'm using. And table values are going to be wrong until they are tweaked with real temp readings, unfortunately no way around that.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 09:40AM
I am not going to be able to do this..
I will just turn it on an register the temperature at which the hotend has a good flow when I hand-feed it.

My plan to make my own table for Marlin was ambitious and good but my knowledge and understanding is too limiting at this time.

Thanks for your insights. When I get home I will try to find more info but I couldn't already find any info about hoe to make your own table for Marlin.

Throwing in the towel

I managed to calculate Beta, it's 2514
R0 = 124922
T0 = 20ºC

R = 4064
T = 215ºC

Beta = 2514
Rz = 234057

But, when I use the generator it also needs R1 and R2... And I have no idea what they want? I don't know what kind of resistors are in the hotend!


Update:
Printing in 245ºC doesn't work properly, I get bad prints, the filament doesn't come out well. Upping to 260ºC now in the settings.

Update #2:
260ºC seems printable, but having someone help me make a Marlin thermistor table for my thermistor would really, really help. Putting the hotend on 260ºC doesn't feel good, even if it's only a temperature reading which may just be around 220ºC in real temperature....

Edited 3 time(s). Last edit at 04/11/2013 12:00PM by Ohmarinus.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 12:06PM
R1 and R2 are the sense resistors on your electronics. Most electronics only have R2, which is 4.7Kohm as standard. So set R1 to 0, R2 to 4700, and let it run.

Also, the newer script from this article:
[hydraraptor.blogspot.co.uk]

Gives more accurate results over a wide range. Here, rp is the sense resistor, r0,1,2 and t0,1,2 are three temperature/resistance pairs. You can get those from the datasheet, or measure them accurately if you have the right instruments.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 12:37PM
Ok, sounds worth a try.

So the sense resistor (RP) would be 4700 in this case? (4.7K Ohm)

and:
t0 = 20 / r0 = 124922
t1 = 120 / r1 = 36736
t2 = 220 / r2 = 3692

So these values are from the temperature vs resistance table.

I just chose to go from 20 to 220 with intervals of a 100.

Testing it now!


Update:
By using ErikZalm's calculator I got this:
// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=124922 --t0=20 --r1=0 --r2=4700 --beta=2514 --max-adc=1023
// r0: 124922
// t0: 20
// r1: 0
// r2: 4700
// beta: 2514
// max adc: 1023
#define NUMTEMPS 20
short temptable[NUMTEMPS][2] = {
   {1, -1810},
   {54, 771},
   {107, 525},
   {160, 423},
   {213, 361},
   {266, 318},
   {319, 285},
   {372, 257},
   {425, 234},
   {478, 213},
   {531, 195},
   {584, 177},
   {637, 160},
   {690, 144},
   {743, 127},
   {796, 110},
   {849, 92},
   {902, 71},
   {955, 44},
   {1008, -6}
};

By using nopheads calculator I got this:
Traceback (most recent call last):
  File "MakeTempTable.py", line 101, in 
    main(sys.argv[1:])
  File "MakeTempTable.py", line 97, in main
    r = exp((x - y / 2) ** (1.0/3) - (x + y / 2) ** (1.0/3))
ValueError: negative number cannot be raised to a fractional power

Edited 2 time(s). Last edit at 04/11/2013 12:51PM by Ohmarinus.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 01:05PM
In this thread r1 and r2 are first mentioned in 3rd post from the top spinning smiley sticking its tongue out

This is a better distribution of smaller intervals in interesting ranges.
// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=2514 --max-adc=1023
// r0: 100000
// t0: 25
// r1: 0
// r2: 4700
// beta: 2514
// max adc: 1023
#define NUMTEMPS 20
short temptable[NUMTEMPS][2] = {
{166, 400},
{311, 280},
{349, 260},
{370, 250},
{393, 240},
{416, 230},
{442, 220},
{468, 210},
{496, 200},
{526, 190},
{556, 180},
{588, 170},
{653, 150},
{753, 120},
{815, 100},
{872, 80},
{919, 60},
{957, 40},
{984, 20},
{1002, 1}
};
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 01:09PM
I will re-calculate, the way I did it now, my temp is reading -22....

Damn sad smiley
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 01:18PM
When I put in those values the hotend temp just displays a static 27ºc

Doesn't go up when heating up?

I added *OVERSAMPLENR from the other Marlin codes, but now at 220ºc and it doesn't want to work. The filament is nowhere near melting point.

Heres the latest code, using your 3950 beta:

#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11)
// 100k NTC van SMDKING (4.7k pullup)
const short temptable_11[][2] PROGMEM = {
   {1*OVERSAMPLENR, 937},
   {27*OVERSAMPLENR, 326},
   {53*OVERSAMPLENR, 268},
   {79*OVERSAMPLENR, 239},
   {105*OVERSAMPLENR, 219},
   {131*OVERSAMPLENR, 204},
   {157*OVERSAMPLENR, 192},
   {183*OVERSAMPLENR, 182},
   {209*OVERSAMPLENR, 174},
   {235*OVERSAMPLENR, 166},
   {261*OVERSAMPLENR, 159},
   {287*OVERSAMPLENR, 153},
   {313*OVERSAMPLENR, 148},
   {339*OVERSAMPLENR, 143},
   {365*OVERSAMPLENR, 138},
   {391*OVERSAMPLENR, 133},
   {417*OVERSAMPLENR, 129},
   {443*OVERSAMPLENR, 124},
   {469*OVERSAMPLENR, 120},
   {495*OVERSAMPLENR, 116},
   {521*OVERSAMPLENR, 112},
   {547*OVERSAMPLENR, 109},
   {573*OVERSAMPLENR, 105},
   {599*OVERSAMPLENR, 101},
   {625*OVERSAMPLENR, 97},
   {651*OVERSAMPLENR, 94},
   {677*OVERSAMPLENR, 90},
   {703*OVERSAMPLENR, 86},
   {729*OVERSAMPLENR, 82},
   {755*OVERSAMPLENR, 78},
   {781*OVERSAMPLENR, 74},
   {807*OVERSAMPLENR, 70},
   {833*OVERSAMPLENR, 65},
   {859*OVERSAMPLENR, 60},
   {885*OVERSAMPLENR, 54},
   {911*OVERSAMPLENR, 48},
   {937*OVERSAMPLENR, 41},
   {963*OVERSAMPLENR, 31},
   {989*OVERSAMPLENR, 18},
   {1015*OVERSAMPLENR, -8}
};
#endif

With these settings I can barely extrude at a 260ºC setting in Repetier.

Edited 3 time(s). Last edit at 04/11/2013 01:37PM by Ohmarinus.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 01:47PM
It's not gonna work. I tried every single way of applying it and In repetier it says that the nozzle is at 220 degrees, but the hotend won't do anything. I can barely get the filament flowing through at 260ºC.

I don't know why.

Now experimenting with #6
// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)


With Thermo #1 I can print on 260ºC
With Thermo #6 I can print on 250ºC

The other ones in the pre-made file don't come close to that, not even melting filament at 260ºC and the tables I make myself I also have to set the printing temp well over 260ºC.

I hope ErikZalm can help me, I will try to send him a note or something.

Edited 2 time(s). Last edit at 04/11/2013 02:34PM by Ohmarinus.
Re: Choosing Thermistor based on table - Marlin
April 11, 2013 03:15PM
Assuming exact numbers of 5v and 4700ohms, and the pdf with your temperatures and resistances my math looks like this:
Thermistor table
Adc Temperature
1007.71 1
985.91 20
939.93 40
859.42 60
740.71 80
595.75 100
448.8 120
269.25 150
186.24 170
154.56 180
128.37 190
106.79 200
89.06 210
74.51 220
62.55 230
52.73 240
44.63 250
37.94 260
27.76 280
19.49 304

For your firmware apparently the left side colum needs to be multiplied * 16, which you can do directly, and invert the order.
I copied the format from above so i hope i got that right. So here it is your thermistor table to test:

//Thermistor table
// For given temperature: Resistance to Adc voltage to Adc value
// 100k NTC van SMDKING (from pdf values)
const short temptable_11[][2] PROGMEM = {
{ 312 , 304 }
{ 444 , 280 }
{ 607 , 260 }
{ 714 , 250 }
{ 844 , 240 }
{ 1001 , 230 }
{ 1192 , 220 }
{ 1425 , 210 }
{ 1709 , 200 }
{ 2054 , 190 }
{ 2473 , 180 }
{ 2980 , 170 }
{ 4308 , 150 }
{ 7181 , 120 }
{ 9532 , 100 }
{ 11851 , 80 }
{ 13751 , 60 }
{ 15039 , 40 }
{ 15775 , 20 }
{ 16123 , 1 }
} ;
#endif

So its already multiplied * 16, dont use that oversample again on it, just copy-paste. Or if you want to use the oversample divide them by 16 first (you should get smth like first table column around). Let me know how this works out.

Edited 2 time(s). Last edit at 04/11/2013 03:21PM by NoobMan.
Re: Choosing Thermistor based on table - Marlin
April 12, 2013 05:08AM
Hi, with these values I still needed to put the values very high... So I reverted to using #6 and having to input the printing temp as 250ºC now.

I have discovered that 41*OVERSAMPLER (or 41*16=656) is the value that should be around 220ºC for my thermistor. Because thats the temperature where the ABS has a nice melting temperature. So I should get myself a table that has that value around 220/225ºC.
Re: Choosing Thermistor based on table - Marlin
April 12, 2013 07:06AM
Dunno about abs at 220c, i print abs at about 240c, and that was calibrated with thermocouple inside barrel. Why are you so fixed on the 220c value, to me that seems low for abs printing, and why are you so sure 220c is the real temp the abs printing should be done at. Or otherwise why u want the printer to show you 220c.
Re: Choosing Thermistor based on table - Marlin
April 13, 2013 05:32AM
I have now lowered my printing temp to 240ºC and it still seems to work pretty well.

There are some mechanical factors now also influencing how I print, I need a new extruder, yesterday my filament had a piece of more than 3.5mm wide instead of the usual 3mm. The thick filament broke my guide of the extruder! Can you imagine!?

Really pissed at the guy who sold me the filament.

And I discovered that I was printing at a too high temperature, at least, I think that was the problem with some properties of my prints. Going from 250 to 240 in my current setup seems to provide me good adhesion, and decent shapes. Still a few weird printing effects happen, but I will start printing some calibration pieces again and see if the machine does well now.

Also raising the filament multipier factor back from 0.9 to 1.0 seems to give better adhesion between layers.

Oh, and using the vibration limiter in slic3r is only useful when it's turned off in your firmware. When it is on in both slic3r and the firmware, you will get very weird slowdowns in your prints.
Hello, can you confirm that the table from Noobman (April 11, 2013 12:15PM ) is working with that thermistor?
I ordered a new hotend too and i need a good marlin table for the B=3950/100K.

Thanks.
Re: Choosing Thermistor based on table - Marlin
September 03, 2013 05:57AM
If you have a multimeter with a thermocouple, the very best thing you can do is start with that table (or any other that is sort of equidistant - see the temperatures column goes in 10C and 20C increments - e.g. adc values are sort of well split for zones of interest). Mount thermocouple on barrel or better inside barrel, then take a temperature from table, e.g. 150C give command in host to raise to that temperature, wait for temp to stabilize then notice that thermocouple reads say 155C, then replace in table 150 with 155. Do that for all temperatures, at least ones of high interest, then you got yourself a table that is calibrated against thermocouple. You can then upload the modified table and it should be better than any other table copied over the net.

This way it really does not even matter what thermistor you use, what is beta, or anything else, all the electronics could be inside a black box for what we care. Its just thermocouple feedback calibration process, thats all. So imho, on short, do it like that, and forget about beta and all rest. Its much better if you start with a table that has adc values well distributed like that one, but its not necessary. Imo this is best thing to do, as long as you have a multimeter with a thermocouple, or if you can borrow one.
Sorry, only registered users may post in this forum.

Click here to login