Close



Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,437
    Add printbus on Thingiverse

    Comparison of Type 1 and Type 6 thermistortables.h data

    Multiple threads have been discussing the details of temperature measurements in the Marlin firmware. Most recently, this has been in thread Auto Bed Leveling troubles. This thread is an attempt at sharing what I've learned in researching the temperature measurements. Smartphone readers are forewarned that this is a lengthy post.

    NOTE: This is discussing Marlin file contents current as of mid-September 2014

    BACKGROUND
    For our MakerFarm printers, thermistors are used to sense temperatures at the hot end nozzle and heated bed. These are devices that change resistance with temperature. In the reprap world, the thermistors are used in a voltage divider network with a fixed resistor (typically 4700 ohms) going to VCC (5v) and the thermistor going to ground. The voltage observed at the junction of the two will vary with temperature following resistive voltage divider math. In Marlin/RAMPS, this voltage is measured using the 10-bit Analog-to-Digital Converter (ADC) in the Arduino Mega microcontroller. A decoupling capacitor is added to help filter low-frequency noise from the voltage being measured. Here's a summary diagram; this is repeated for each thermistor. There's only one ADC in the microcontroller, but it also has an analog switch that allows different inputs to be selected for measurement.


    Due the properties of the materials involved, thermistors are very non-linear. To simplify the firmware effort necessary to determine a temperature from the measured voltage across the thermistor, lookup tables are used that correlate ADC measurement values to predetermined temperatures.

    In Marlin, source file thermistortables.h contains the lookup tables for various thermistors and measurement schemes. In configuration.h, constant TEMP_SENSOR_BED is defined to specify which of the lookup tables should be used with the thermistor on the heated bed. Constant TEMP_SENSOR_0 specifies which of the lookup tables should be used with the thermistor on the primary hot end.

    Confusion and issues in all this surfaces in multiple ways -

    1. Our thermistors are considered to be "EPCOS 100K". File thermistortables.h contains two tables for 100K EPCOS thermistors (type 1 and type 6), without any explanation on what the difference is.
    2. MakerFarm's configuration.h file specifies the use of lookup data for a Type 6 thermistors on both the bed and the hot end. Configuration.h has comments indicating the Type 6 data is less accurate than Type 1, so why isn't Type 1 used instead?
    3. MakerFarm's thermistortables.h file has alterations for the Type 6 thermistor table. What's up with that?
    4. Some people have noted that when they migrate to a new Marlin firmware baseline and stick with the Type 6 selections in configuration.h, temperature readings differ from what they used to be. Others may just run into printing issues with the new firmware, not realizing that the temperature measurements they are working with are now providing different results.
    5. The configuration.h and thermistortables.h files only say Type 1 and Type 6 are for an EPCOS thermistor. EPCOS is a company name, not a specific part. The pool of possible thermistors is narrowed by knowing we're using a thermistor with 100K nominal resistance at room temperature that goes down in resistance as temperature increases (a Negative Temperature Coefficient or NTC thermistor), but EPCOS still has multiple parts that meet that criteria. The discussion page associated with http://reprap.org/wiki/Thermistor questions which of several EPCOS part numbers the table data is meant for. The question is currently unanswered.
    6. Reprap component suppliers typically say they are providing EPCOS part B57560G104F thermistors since that is considered the rep rap standard. Unfortunately, that part number has been obsolete for some time (as in apparently years). So just what is it that they're supplying? They should be asked.
    7. The table data in thermistortables.h is straightforward, but that isn't apparent to a casual observer not familiar with it. That complicates being able to compare data between thermistor types in different source files.


    DECODING THE THERMISTORTABLES.H TABLES
    If you're not familiar with the thermistortables.h file, find it in the Marlin source files and open it in the Arduino IDE or a text editor. Table entries look something like { 23*OVERSAMPLENR , 300 }. What this is basically saying is that for an ADC measurement result of 23, we should assume the thermistor is sensing 300 degrees C. The ADC doesn't directly provide the resistance of the thermistor. It doesn't even provide the voltage measured across the thermistor. Firmware configures the ADC to use the voltage at VCC as full-scale. The ADC will indicate where in a 10-bit range (scale of 0 to 1023) the voltage measured across the thermistor falls between 0 and VCC.

    In the above example, the sample count of 23 isn't used directly. It is multiplied by constant OVERSAMPLENR which is defined to be 16. So, the table entry is really {368,300}.

    FOLLOWUP COMMENT: In the thermistor data tables, the sample counts are multiplied by OVERSAMPLENR as a result of how Marlin does temperature measurements. Marlin builds an average temperature value from multiple readings of the voltage across the thermistor. OVERSAMPLNR also defines the number of consecutive readings used. Multiplying the sample counts in the thermistor tables "scales up" the data table. Using the example above, Marlin will measure the thermistor voltage 16 times, adding the sample count for each measurement to the previous readings in that group of 16. At the end, the sum should be around 16 times what an individual reading would be. Marlin can then compare the sum to the thermistor table, also multiplied by 16, for a temperature result. The effect of how OVERSAMPLNR is used is that the temperature result is the average across the 16 individual thermistor readings, without having to perform any processor-intensive division math in determining the average.

    When you start comparing data for different thermistor types, you'll notice the tables are inconsistent in the temperature range that they address, and that some don't provide data at the same temperature increments. No worries. Firmware using it likely builds it's own curve-fitting math based on whatever datapoints it is given in the specified table. Again, it just makes it hard to visually compare data.

    COMPARING THE TYPE 1 and TYPE 6 DATASETS
    The attached zipped PDF file provides a table that shows, for a 0 to 300 degree C temperature range, ADC measurement values for resistance truth data from EPCOS, Type 1 thermistor data, Type 6 thermistor data as provided by MakerFarm, and Type 6 thermistor data currently in the Marlin code baseline. Notes at the bottom of the table clarify data origins. It seems that python scripts are typically used to build the lookup tables used in Marlin; my use of the resistance data from EPCOS in voltage divider math was in a simple spreadsheet.

    EPCOS Summary.zip

    The EPCOS ADC column is based on tabular resistance data available at the EPCOS web site, assuming I happened to pick the right specific EPCOS thermistor part number. You'll notice only minor differences in the ADC values between the EPCOS data, the Type 1 data, and even the Type 6 data as provided by MakerFarm. The minor differences might be in how the python calculations were performed, in rounding vs truncation, etc. Major differences are evident in the Type 6 table obtained from the Marlin repository.

    OBSERVATIONS
    To grasp the non-linear nature of thermistors, look at the EPCOS Rnom column in the summary table. The 100k-ohm spec on our EPCOS thermistors refers to the thermistor resistance at 25 degrees C, and the table reflects that. Note how around room temperature a 5 degree temperature change causes a resistance change of 20,000 ohms or more. At 200 degrees, a 5 degree shift only changes the resistance by about 50 ohms. For our 100,000 ohm thermistors, the temperature range between 185 degrees (arbitrary PLA) and 230 degrees (arbitrary ABS) only leads to a resistance change in the neighborhood of 432 ohms. When using our printers, we put a lot of measurement emphasis on such a small change in resistance at those higher temperatures. Here's a resistance-vs-temperature graph of the EPCOS data -




    The Type 6 data in the Marlin baseline is likely someone's attempt to build a table using real-world measurements either on a printer or with a thermistor in a temperature chamber. This likelihood is supported by the comment for Type 6 in configuration.h that says it was compiled with a Fluke thermocouple. Without knowing more about how that data was collected, I have no idea how it might apply to my printer and I personally find it pretty worthless. The data is also immediately suspect since the same ADC count value is shown for both 40 and 45 degrees.

    For whatever reason, the Type 6 thermistor data provided by MakerFarm has been altered to basically reflect Type 1. My guess is they or their firmware source inadvertently started using Type 6, didn't like it, and not realizing there was really another type they should use instead they modified the Type 6 data. Now there's really no significant difference in specifying the use of the Type 1 thermistor, or in specifying Type 6 AS LONG AS you are also using the MakerFarm alterations to the Type 6 table. Those that update their firmware from the Marlin repository will need to either switch to using the Type 1 data or need to carry forward the MakerFarm manipulation of the thermistortables.h file. Seems to me that switching to Type 1 is the preferred path. Using the Marlin type 6 data as-is could lead to temperatures that read as much as 20-30 degrees different than they used to be with the old firmware. Whoever built the Marlin Type 6 table was evidently OK with reading the temperature differently.

    Except for the Marlin baseline data for Type 6, the thermistor tables involved here appear to be defining theoretical, perfect data not affected by real world factors such as thermistor self heating, temperature soak, drafts, or anything else that could affect the accuracy of the actual measured temperature. It's likely best to keep it this way rather than trying to build custom tables that factor real world observations measured on your printer with an independent thermometer or thermocouple. For one thing, otherwise you'd likely have to have different tablesets for your hot end thermistor and the heated bed since they'd act differently.

    The tolerance of the 4700 ohm resistor used in the voltage divider with the thermistor contributes an error in the temperature measurements. Ideally, that part would be a high precision, low temperature drift part in order to minimize the error it contributes. Errors due to leakage currents in the 10uF capacitors used to filter the voltage divider output should be insignificant. The absolute voltage of VCC is irrelevant, since the ADC is set up to use VCC as full scale. Since VCC is also used to source the voltage divider, any error from nominal 5V will affect both the voltage divider output and the ADC sampling, for no net effect.
    Last edited by printbus; 05-02-2015 at 09:02 PM. Reason: migrated to offsite attachment storage due to 3DPrintBoard issues

  2. #2
    Technologist
    Join Date
    Aug 2014
    Location
    Oklahoma
    Posts
    191
    Add usarmyaircav on Google+ Add usarmyaircav on Thingiverse
    That is impressive work Kevin!!!! In relation to this then, how often do people update their Marlin firmware, or maybe how often does the Marlin firmware come out with an update?

  3. #3
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,437
    Add printbus on Thingiverse
    Quote Originally Posted by usarmyaircav View Post
    That is impressive work Kevin!!!! In relation to this then, how often do people update their Marlin firmware, or maybe how often does the Marlin firmware come out with an update?
    On the board here, the temperature issues seem to be coming up most often when people are implementing auto-leveling. Migrating to a newer version of Marlin firmware is a prerequisite for that.

    Roxy or someone else can better speak to the Marlin updates. I have the understanding that it's constantly under change, and you just go grab the latest build from github when you want an updated version.

  4. #4
    Technologist dacb's Avatar
    Join Date
    Aug 2014
    Location
    Edmonds, WA
    Posts
    139
    Outstanding piece of work.

    Glad to know my diff is holding for now.

    I wonder what we can do as a community to create a more relevant Marlin prep. We can keep passing around Configuration.h files and trying to patch Roxy against trunk, but that feels really kludgey and prone to failure. A fork has a higher activation and maintenance barrier, but makes things more straightforward until the next iteration is released (of the i3 or Marlin or ABL or ...).

  5. #5
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,437
    Add printbus on Thingiverse
    Quote Originally Posted by dacb View Post
    Glad to know my diff is holding for now.

    I wonder what we can do as a community to create a more relevant Marlin prep. We can keep passing around Configuration.h files and trying to patch Roxy against trunk, but that feels really kludgey and prone to failure. A fork has a higher activation and maintenance barrier, but makes things more straightforward until the next iteration is released (of the i3 or Marlin or ABL or ...)
    I used your diff since I'd rather not go sort through github if I don't have to. Besides, I wanted to credit your diff file for being what tripped my WTF button.

    Yeah, I don't know on the firmware build issue. I think we're gaining followers here every week with new MakerFarm builds, so there could be growing interest in having a MakerFarm fork. I tend to leave things alone if they're not broke, but mainly because I hate opening up a can of worms with something I'm not familiar with. The pain and frustration some people go through to get auto bed leveling up and running is such a waste.
    Last edited by printbus; 09-25-2014 at 03:29 PM.

  6. #6
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,437
    Add printbus on Thingiverse
    Quote Originally Posted by XCopter View Post
    So I updated my marlin firmware and was running it fine from the makerfarms tables (used to use j-head) but then I switched to the e3d hotend (I used their supplied thermistor) and changed back to the original tables supplied in the marlin package. Now my heated bed maxes out at 86 degrees (using type 6 in my tables)(probably is actually around 110-115). I was wondering what I should do. Will makerfarms modified tables ONLY effect their type 6 thermistor (for my heated bed) or will it effect my type 5 (104GT-2) thermistor in my e3d v6 hotend? So should I switch back to makerfarms tables and select the type 5 thermistor (for my hotend) or stay with my current tables and select the type 1 thermistor (for my heated bed)?
    The MakerFarm thermistortables.h file only has changes for the Type 6 thermistor. The Type 5 values are the same in files from both the MakerFarm distribution and the Marlin repository. In configuration.h, the #DEFINE for TEMP_SENSOR_0 should be set to 5 for the E3D hot end regardless of what thermistortables.h file you are using. With the #DEFINE for TEMP_SENSOR_BED, you have two choices that will give you essentially identical results. You can either use Type 1 with either thermistortables.h file, or you can use Type 6 but only if you're using the MakerFarm thermistortables.h file.

  7. #7
    I'd just like to add that narrowing down the parts available on Digikey based on the specifications available on Makerfarm's spare thermistor page (plus assuming it is an EPCOS part) returns a single part. The exact part number appears to be B57560G0104F000. Here's a datasheet with the thermistor table starting at page 50. Can someone double-check I got all my info right?

  8. #8
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,437
    Add printbus on Thingiverse
    Quote Originally Posted by porksmash View Post
    I'd just like to add that narrowing down the parts available on Digikey based on the specifications available on Makerfarm's spare thermistor page (plus assuming it is an EPCOS part) returns a single part. The exact part number appears to be B57560G0104F000. Here's a datasheet with the thermistor table starting at page 50. Can someone double-check I got all my info right?
    Yeah, but I don't think you can actually order the B57560G0104F000. It's not a stocked part at either DigiKey or Mouser, and if you go to the EPCOS site that part number is no longer valid.
    Last edited by printbus; 11-03-2014 at 07:12 PM.

  9. #9
    That's true, but no thermistors from EPCOS currently in production match the exact specs as listed on Makerfarm's website either. The closest one is B57560G1104+000. Either specs are incorrect, the listing for the replacement thermistor is out of date, or Colin has a huge stockpile.

  10. #10
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,437
    Add printbus on Thingiverse
    Quote Originally Posted by porksmash View Post
    That's true, but no thermistors from EPCOS currently in production match the exact specs as listed on Makerfarm's website either. The closest one is B57560G1104+000. Either specs are incorrect, the listing for the replacement thermistor is out of date, or Colin has a huge stockpile.
    FWIW, B57560G1104+000 was the EPCOS part I "assumed" when I built the EPCOS summary table in the original post. That data tracks almost exactly (within one or two ADC counts) to what Marlin has for the Type 1 thermistor and also the MakerFarm adjustments to the Type 6 data. I don't know how much faith to put in the MakerFarm specs. They get a lot of their electronic stuff from reprapdiscount, and the B57560G104F 100K thermistor at reprapdiscount shows a different beta value from what MakerFarm says. MakerFarm doesn't state the temperature points for the beta curve, so it's hard to tell for sure if they're the same.

    I also suspect that 99% of the thermistors out there should more accurately be described as "B57560G104F equivalent" and are not truly EPCOS parts. Just like our Arduino Mega2560 board is not really a board built by Arduino - it's a clone.
    Last edited by printbus; 11-03-2014 at 08:48 PM.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •