Access to raw ADC readings

  • On to the next problem.

    I notice many people have problems with heater faults. So do I, but that's not the first thing I need to worry about. I have a theory for what might be the most common cause for it, and I want to check it out first.

    I know my temperature sensors are not calibrated. Bed temperature gain is at least 50% off; the hot end is similarly out of whack. That did not matter much when the machine was controlled by Melzi. I simply knew what temperature values corresponded to good printing results and did not obsess about how far off they were. Besides, there was no easy way for me to get them right. Now I've got a good lab-grade thermometer with a very small thermocouple that will report accurate temperatures wherever I stick it. I can even insert it in the feed side of the nozzle. For that to be useful, I think I need to sample the ADC output (which I believe is fed directly into the PID model). I could calibrate it indirectly, by reversing the model, but that would no doubt require multiple iterations and a lot of time.

    I can't see how an auto-tuned PID model can behave well if it is trained on the wrong temperature scale. I may be wrong, but I suspect that the key to successful PID tuning lies in a reasonably accurate sensor calibration. We should be able to get it to within ±2℃ without much effort. It probably isn't much of a problem for people who use well-known high-precision thermistors, but I have no idea what mine are and want to get a good estimate of their parameters. I will appreciate any clues on how to read the encoded temperature values from the Duet.

  • administrators

    To access the raw ADC readings you would need to modify the firmware. But you could easily set up a spreadsheet to calculate them by reversing the algorithm used to turn the ADC reading into a temperature reading.

    Auto tuning doesn't care whether your temperature sensors are well-calibrated or not, as long as the room temperature reading is approximately right and the temperature readings that they provide bear a reasonably linear relationship with the actual temperatures.

    If you know the make and model of the thermistors in your printer, and you can find a B value for the bed thermistor and a resistance vs temperature chart for the hot end thermistor, then you should be able to get sufficiently accurate temperature readings by putting the correct thermistor parameters in config.g. If you want really accurate temperatures, then I suggest you use a PT100 sensor for the hot end, and either another PT100 or a close-tolerance thermistor for the bed.

  • No, I don't have any idea about the origin of my hot end thermistor. All I know is that it is extremely small. It looks like a tiny glass bead, less than 1mm in diameter. It came with a Diamond nozzle I bought from BiQu.

    Guess what. I was unable to achieve a 2-degree accuracy with this thermistor using the Steinhart-Hart model over the entire range of temperatures. Disappointingly, its worst error (-4℃) peaks in the most common range of printing temperatures. I am not sure if I overfit the model or it is just a weird thermistor.

    But the good news is that heater faults have completely ceased after I applied the calibration settings and re-tuned. Prior to that, I had to reset the heater a dozen times before it was able to reach the target temperature.

    M305 P1 T97000 B4800 C1.0705E-7
    M303 H1 S240
    M307 H1
    Heater 1 model: gain 358.7, time constant 266.1, dead time 3.3, max PWM 1.00, calibration voltage 13.5, mode PID, inverted no, frequency default
    Computed PID parameters for setpoint change: P39.9, I1.341, D92.7
    Computed PID parameters for load change: P39

    I suspected it all along but couldn't articulate it properly. I am still not sure I understand it, but something makes me think that if you calibrate your physical model in weird temperature units, you can't expect the resulting time constant to be commensurate with a time interval defined in seconds.

    I don't trust myself to do even the most trivial calculations, so I went for the dumbest and most direct method of calibration. I took a thermistor that I received with the original RepRap kit (also of unknown type, but it didn't matter) and stuck it between the hot end block and the insulation blanket. I connected it to the Duet instead of the hot end-mounted one that I was calibrating, just so I had a thermostat. That allowed me to use a high-impedance meter to measure that thermistor's resistance directly. The reference thermocouple fit very nicely in a set screw hole in the heater block. I believe it is the set screw that holds the heater cartridge, so it was close enough to the heater to be an accurate reporter. The only little problem with that method was that the thermocouple had a higher thermal mass than the thermistor (about 20x), so I had to wait half-a-minute for their readings to equilibrate. Also, I took an equal number of measurements while heating up and cooling down, to reduce the residual delay bias.

    So it feels like progress, but there are a few questions I am wondering about:

    • How bad is the deviation of 4℃ over 220℃?

    • Is the shape of the error curve I observed typical for the SH model?

    • If not, is it symptomatic of any known measurement error?

    • Is there a way to use the data I collected to build some sort of interpolated lookup table instead of a functional model?

  • administrators

    I think the S-H model is usually more accurate than that. You might like to take the published resistance vs. temperature table for the Semitec 104GT2 thermistor at and compare the fit.

    Perhaps you should buy a new thermistor with better-known characteristics?

  • I would expect that the Thermistor from BIQU is probably one of the std Chinese types that are generally a beta value of 3950 at 25/50 (These are the common ones currently used and are defiantly the ones the Keenovo use in there silicon beds.


    edit Link to Thermistor temp table added

  • I use an online calculator to get the B value and select 190 and 250 as my two reference temps then check it against a k-type thermocouple placed against the nozzle with thermal compound on it, sure it probably reads way off at much below 190 but then that doesn't matter.

    Or try pt100 / pt1000

  • Thanks to everyone for useful suggestions. I have tested all and got wildly different results. Then I dug in a bit deeper into this whole calibration issue and found that there is really no good way to do it without dismantling the hotend. The best option is to calibrate the thermistor in a precise bath thermostat before putting it in. You might be able to obtain a sensible result by doing an in-place calibration if your hotend is small and well-insulated, but with the Diamond Hotend, that is nearly impossible.

    I went ahead and did it the hard way, using a trick that does not seem to be easily reproducible. I did realize early on that it was a stupid thing to do, but it was too much fun to quit, and in the end, I did achieve a passable result. I have summarized my findings at

    The next time I have to do it (my bed thermistor is next), I will construct an external thermostat.

    David, your suggestion that it could be104GT seems to have been spot-on, although the best-fitting curve looks almost parallel to 102GT, which is an odd one in the family. It is possible that it is a somewhat odd 104GT. Maybe it is a QC reject. Its room-temperature resistance is within the norm but the estimated B value is almost 3% off. I posted a couple NLS fits on that github page.


Looks like your connection to Duet3D was lost, please wait while we try to reconnect.