Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.5k stars 5.32k forks source link

Klipper is reading incorrect thermistor values #1910

Closed bryanboettcher closed 5 years ago

bryanboettcher commented 5 years ago

klippy.log

This is a weird one. Given the same physical machine, and a 320 ohm resistor in place of the extruder thermistor:

I am not concerned with the 1C difference between Klipper and Marlin2 on the RAMBo, but the Archim2 differences are enormous. It is a sliding scale, too ... the higher the commanded temperature, the worse the difference is (eg. at 220C commanded, the actual is 283C). Every thermistor in both Klipper & Marlin2 is set to "EPCOS 100K B57560G104F".

bryanboettcher commented 5 years ago

I should add this is only software, in some manner. All 4 thermistor input channels exhibit this behavior.

FHeilmann commented 5 years ago

I'm not sure how Marlin corrects for this, but it seems like the Archim2 (I looked at the rev2.1 board) board has some additional circuitry in place for the thermistors which might throw the reading of the temperature value off-course. Here is an example for T1: image

I haven't used Marlin in a while and don't know whether Marlin corrects for the inline circuitry somewhere, but that would be my guess why your readings differ on this particular board. Klippers table for the EPCOS thermistor probably assume no additional circuitry.

bryanboettcher commented 5 years ago

I noticed that too, except the RAMBo has the same circuitry, down to the resistor values. Klipper gets the temperature correct with RAMBo. Trying to add values for "inline_resistor" makes the temperature readings worse.

On Mon, Aug 26, 2019, 8:44 AM Florian Heilmann notifications@github.com wrote:

I'm not sure how Marlin corrects for this, but it seems like the Archim2 (I looked at the rev2.1 board) board has some additional circuitry in place for the thermistors which might throw the reading of the temperature value off-course. Here is an example for T1: [image: image] https://user-images.githubusercontent.com/4352664/63695110-3bd38900-c818-11e9-97a0-b6bd52f42738.png

I haven't used Marlin in a while and don't know whether Marlin corrects for the inline circuitry somewhere, but that would be my guess why your readings differ on this particular board. Klippers table for the EPCOS thermistor assume no additional circuitry.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAH35U4W5TV4GMA7ZYIF5STQGPM4DA5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ENECY#issuecomment-524866059, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH35UZ3G6QK4AV355TD3UDQGPM4DANCNFSM4IPHGUFA .

nophead commented 5 years ago

The series resistors should have negligible effect assuming the capacitor is a low leakage type. The diodes and input pin should only leak a few uA.

On Mon, 26 Aug 2019 at 14:55, Bryan Boettcher notifications@github.com wrote:

I noticed that too, except the RAMBo has the same circuitry, down to the resistor values. Klipper gets the temperature correct with RAMBo. Trying to add values for "inline_resistor" makes the temperature readings worse.

On Mon, Aug 26, 2019, 8:44 AM Florian Heilmann notifications@github.com wrote:

I'm not sure how Marlin corrects for this, but it seems like the Archim2 (I looked at the rev2.1 board) board has some additional circuitry in place for the thermistors which might throw the reading of the temperature value off-course. Here is an example for T1: [image: image] < https://user-images.githubusercontent.com/4352664/63695110-3bd38900-c818-11e9-97a0-b6bd52f42738.png

I haven't used Marlin in a while and don't know whether Marlin corrects for the inline circuitry somewhere, but that would be my guess why your readings differ on this particular board. Klippers table for the EPCOS thermistor assume no additional circuitry.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAH35U4W5TV4GMA7ZYIF5STQGPM4DA5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ENECY#issuecomment-524866059 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAH35UZ3G6QK4AV355TD3UDQGPM4DANCNFSM4IPHGUFA

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAEKHBLWCLYE3PXEWGLOY5DQGPOETA5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5EOE4Y#issuecomment-524870259, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEKHBOA74DZ3DATWMKNHT3QGPOETANCNFSM4IPHGUFA .

FHeilmann commented 5 years ago

going back to the original post, @bryanboettcher you stated that you're putting a 320 Ohm resistor in place of the thermistor. Thats a massive difference from what the thermistor will usually read (100kohm at room temperature). Maybe thats the reason for the inaccuracies. as @nophead pointed out the resistors on board will not affect the reading with a regular thermistor (2k vs 100k) but with a 320 Ohm resistor in place of the thermistor things may look different.

bryanboettcher commented 5 years ago

The behavior persists with an actual EPCOS 100k B57560G1104F thermistor in place of the resistor, I just can't get fractional temperature readings from the ADC because I'm manually unplugging & plugging the heated thermistor into another board. The effect is amplified the higher the temperature reading is supposed to be, and the correct temperature is always HIGHER than Klipper reads it as.

My initial test came by heating the hotend to a commanded 220C with Klipper, with the sensor set to EPCOS 100k B57560G1104F. Sitting near my printer, I had a RAMBo running Marlin (hear me out) with the thermistor harness all wired through and sitting next to the hotend. I had a script running M105 on a loop to get temperature readings. They usually read -15C since there was no thermistor. In one quick motion, which took less than 2 seconds, I would unplug the thermistor from Klipper and plug it into the Marlin harness. I would expect a reading of 220C or less if the hotend had cooled, but instead Marlin was reading 283C!

I then thought this was a Marlin / Klipper difference, so I tried it on a RAMBo running Klipper set to 220C / EPCOS 100k, moving to the same RAMBo from earlier running Marlin. The commanded 220C came out like 219C on Marlin, which I attribute to 2 seconds of hotend cooling from the safety shutdown.

I then thought this was a RAMBo / Archim2 difference, so I tried Marlin on the Archim2 moving to my same reference RAMBo running Marlin. The commanded 220C was still right about 220C.

This problem is NOT the thermistor, it is NOT Klipper on the whole, and it is NOT the Archim2 on the whole. It only happens with an Archim2 running Klipper.

I am happy to get my test setup to a Klipper developer for further testing if needed.

On Mon, Aug 26, 2019 at 3:36 PM Florian Heilmann notifications@github.com wrote:

going back to the original post, @bryanboettcher https://github.com/bryanboettcher you stated that you're putting a 320 Ohm resistor in place of the thermistor. Thats a massive difference from what the thermistor will usually read (100kohm at room temperature). Maybe thats the reason for the inaccuracies. as @nophead https://github.com/nophead pointed out the resistors on board will not affect the reading with a regular thermistor (2k vs 100k) but with a 320 Ohm resistor in place of the thermistor things may look different.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAH35U5KLCJK5S3EHDEYAGLQGQ5E5A5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5FTEWQ#issuecomment-525021786, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH35U2CWGQG2HECK5KRPADQGQ5E5ANCNFSM4IPHGUFA .

nophead commented 5 years ago

but with a 320 Ohm resistor in place of the thermistor things may look different.

The series resistors shouldn't make much difference at any temperature or thermistor resistance because very little current flows through them, so there is very little potential difference across them. All the current flows through the 4K7 and the thermistor.

320 Ohm is the value the thermistor should have at ~230C, so it should read correctly.

FHeilmann commented 5 years ago

I see, apologies for the confusion. Frankly I'm now out of ideas what the problem could be here.

bryanboettcher commented 5 years ago

Well, how should I proceed?

On Mon, Aug 26, 2019 at 4:24 PM Florian Heilmann notifications@github.com wrote:

I see, apologies for the confusion. Frankly I'm now out of ideas what the problem could be here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAH35U3VBZLALAULRK4DO53QGRCYRA5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5FXKGQ#issuecomment-525038874, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH35U6SBPYJ2374CCLWRUTQGRCYRANCNFSM4IPHGUFA .

nophead commented 5 years ago

If you have a digital multimeter you could measure the voltage on the thermistor input and confirm it is correct for a 320 Ohm resistor in a potential divider with 4K7. You could also check the voltage the other side of the series resistors to confirm it is the same. If so it looks like a software bug perhaps in setting up the ADC. I am not familiar with the boards or either firmware.

bryanboettcher commented 5 years ago

Is there a way we can leverage the proper behavior of Marlin2 to figure out what it's doing vs. Klipper on the Archim2?

On Mon, Aug 26, 2019 at 5:49 PM Chris notifications@github.com wrote:

If you have a digital multimeter you could measure the voltage on the thermistor input and confirm it is correct for a 320 Ohm resistor in a potential divider with 4K7. You could also check the voltage the other side of the series resistors to confirm it is the same. If so it looks like a software bug perhaps in setting up the ADC. I am not familiar with the boards or either firmware.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAH35U2KMENMCKVQJT62YBDQGRMWXA5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5F5F5Q#issuecomment-525062902, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH35U3X3C5CNIERWYS2ZT3QGRMWXANCNFSM4IPHGUFA .

nophead commented 5 years ago

You would need to compare the code.

bryanboettcher commented 5 years ago

Any suggestions for starting points? I could maybe fumble my way through the Python host part of Klipper, but I doubt the firmware core will do me any good ... and that's probably where any bug is.

On Mon, Aug 26, 2019 at 6:12 PM Chris notifications@github.com wrote:

You would need to compare the code.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1910?email_source=notifications&email_token=AAH35UYNIDJ27AFTFMAXPBTQGRPNFA5CNFSM4IPHGUFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5F6P2Y#issuecomment-525068267, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH35U5KXPYYGTES5U3OZQ3QGRPNFANCNFSM4IPHGUFA .

KevinOConnor commented 5 years ago

That's certainly odd behaviour.

As a quick test, if you run "make menuconfig", select "low level options", add "!PB18,!PB19" to the list of "GPIO pins to set at micro-controller startup", and reflash the micro-controller, does it change the behaviour on the Archim2?

Another useful test would be to simplify the Klipper config to verify there isn't an undesirable conflict with another device - for example, use "[printer] kinematics=None" and remove all config sections except [mcu] [printer], and [heater_bed].

-Kevin

bryanboettcher commented 5 years ago

It does change the behavior. I now get a temperature reading of 436C on the extruder thermistor (which should read 232C), and the heated bed is ~ 250C. The heated bed is reading an ambient temperature of about 25C.

I will try an empty config next.

KevinOConnor commented 5 years ago

Based on our conversation on IRC, it appears the SAM3x8e is leaving the internal weak pullup enabled even after the line has been enabled as an ADC pin. This should be fixed now (commit c95209bf).

It's unclear if the same issue impacts the SAM4s8c (Duet2 Maestro) and/or SAM4e8e (Duet2 Eth/Wifi). My best guess is that wiring of the Archim2 (in particular the additional series resistors) made the additional internal pullup much more noticeable than it would on other boards.

-Kevin

KevinOConnor commented 5 years ago

I'm going to close this issue as a fix was implemented for the original problem report.

-Kevin