Page 6 of 13

Thermistors and tuning the PID

PostPosted: Mon May 14, 2012 1:44 am
by dzach
Spent the day trying to debug my Marlin settings. Here is the first strange thing I discovered:
performance1.png
CuHotE performance curve

21 to 200°C in about 37 sec.
performance2.png
21-200deg C in 37 sec.

Not bad, but what is this ripple on the top?
performance3.png
Strange ripple and steps along the curve

Here are some close-ups of the graphs:
performance5.png
40-45°C

performance6.png
200-205°C

After looking into thermistortables.h in Marlin's source files I discovered that the table for setting 6 - EPCOS 100k, which I was using, has errors in it. I spent quite some time learning about thermistor internals and ended up verifying and using setting 1 - 100k thermistor
While going through the source I disabled the timeout check in line 230 in temperature.cpp which was giving me PID Autotune failed! timeout errors and could not complete the PID auto-tuning process.

This is the result:
performance7.png
Thermistor table corrected, PID tuned

performance8.png
21.6 to 200°C in 31 sec.

Looks good!

Printing!

PostPosted: Wed May 16, 2012 1:38 am
by dzach
I gave up on Marlin. It still refuses to work for me even after I disabled the error generating routines in the source.
So, I tried Sprinter and it printed immediately without any complain whatsoever.
This is what it printed, a single wall open cube:
2012-05-14-173830.jpg


Then I discovered that the filament I got from ReprapWorld is not round:
2012-05-15-165002.jpg
Min. 1.62, max. 1.81

Trying to calibrate the bot, I calculated the cross section area of this shape:
PLA_area.png
Min = 1.62mm, max = 1.81mm, avg = 1.72

From that I got the equivalent diameter, which is equal to 1.72mm.
Funny thing, the average of the min and max diameters is also 1.72mm :oops:

Now, Sprinter lacks a workable PID control so this is how CuHotE performs:
performance9.png
Heatsink reaches 33°C max with an ambient temperature @25°C.

This is what the tip of the filament looks like in the melt chamber:
2012-05-16-043423.jpg
The melted part measures 10mm, exactly the height of the cylindrical heating element.
The inner diameter of the barrel is 2mm.

I also did a feed vs. temperature measurement to see how CuHotE performs:
performance10.png
For each measurement, I extruded 100mm of PLA and accepted the measurement only if there was no missed steps.

It can extrude PLA filament at 300mm/min @200°C, but because of the ripple of the temperature with Sprinter, I'll have to repeat the measurement with Marlin and its working PID.

Re: Thermistors and tuning the PID

PostPosted: Mon May 21, 2012 6:24 am
by frob
Wow excellent work! this will benefit everyone here i think.
Me for sure, i was also having trouble getting the extruder temp right, i may have been experiencing the same problem ,
i'll try this as soon as my Hadron is rebuilt (probably next weekend)

Cheers!

dzach wrote:Spent the day trying to debug my Marlin settings.....
This is the result:... Looks good!

Re: dzach's Hadron build

PostPosted: Mon May 21, 2012 6:30 am
by Enraged
how do you log the temperature?

Re: dzach's Hadron build

PostPosted: Mon May 21, 2012 3:46 pm
by dzach
Enraged wrote:how do you log the temperature?

I use a small script to send temperature settings and M105's to read temperatures from the RAMPS @100ms intervals through the serial USB connection.
frob wrote:Wow excellent work! this will benefit everyone here i think.
Me for sure, i was also having trouble getting the extruder temp right, i may have been experiencing the same problem ,
i'll try this as soon as my Hadron is rebuilt (probably next weekend)

Thanks! I have a need to understand in more detail how an extruder/hotend pair works and I bet others need that too. Temperature fluctuations of +-5 deg, though tolerable, are too big for a quality print, I can now see the difference.

I have disabled the MINTEMP alarms and am able to print with Marlin, but I still have problems with USB communications. At 115200 bps I get checksum errors that stop the show, so I have to work at 57600 bps. Why would a checksum error stop a print? As soon as I manage to load the 3D development environment to another PC I'll know if it's a local problem or something to blame Marlin for.

Re: dzach's Hadron build

PostPosted: Mon May 21, 2012 4:22 pm
by Enraged
would you mind posting the script?

I used google to find some PID settings for my J head, and even though I haven't done any long prints yet, they seem to have the temp pretty stable.

For reference, here is what mine is set too currently:
//J Head
#define DEFAULT_Kp 20.18
#define DEFAULT_Ki 0.69
#define DEFAULT_Kd 197.48

Re: dzach's Hadron build

PostPosted: Mon May 21, 2012 4:37 pm
by dzach
Here is the TCL script, you will need a TCL console to run it:
Code: Select all
proc rec usb {
   if {[chan gets $usb data] < 0} return
   incr ::cnt
   lassign $data ok T _ B _ _
   lassign [split $T :] _ T
   lassign [split $B :] _ B
   if {$T ne ""} {
      set res [expr {([clock milli] - $::t0)/1000.0}]\t$T\t$B
      puts $::out $res
   #   puts $res
      if {$::cnt >= 100} {
         puts $res
         set ::cnt 0
      }
   } else {
      puts $data
   }
}
proc ask {{stop 0}} {
   puts $::usb M105
   after 100 ask
}
proc stop {} {
   foreach a [after info] {
      puts "Stopping $a"
      after cancel $a
   }
   chan close $::usb
   chan close $::out
}
proc start {{dev /dev/ttyACM0}} {
   set ::usb [open $dev RDWR]
   chan config $::usb -buffering line -blocking 0 -mode 115200,n,8,1
   chan event $::usb read [list rec $::usb]

   set ::out [open temperatures.txt w+]
   set ::t0 [clock milli]

   after 2000 ask
}

start

# set temperature commands with:
#   puts $usb "M104 S200"

# switch off heater with
#   puts $usb "M104 S0"



The results are put in a file "temperatures.txt" at your home directory.

Re: dzach's Hadron build

PostPosted: Mon May 21, 2012 4:42 pm
by dzach
Enraged wrote:For reference, here is what mine is set too currently:
//J Head
#define DEFAULT_Kp 20.18
#define DEFAULT_Ki 0.69
#define DEFAULT_Kd 197.48


Why copy values form others? You can send a "M303" and let Marlin autotune the PID parameters for you. Here are mine for CuHotE:
Code: Select all
// CuHotE V1
#define DEFAULT_Kp 21.24
#define DEFAULT_Ki 0.05
#define DEFAULT_Kd 2324.5

Re: dzach's Hadron build

PostPosted: Mon May 21, 2012 4:46 pm
by Enraged
I wanted it in the right ballpark from the start, as I was dealing with stepper driver issues as well. I'm tuning everything today so I'll adjust it.

Temperature uncertainty

PostPosted: Mon May 21, 2012 11:16 pm
by dzach
I guess I have to correct myself. The temperatures shown in the graphs are what Sprinter and Marlin THINK they are, based on the 100k thermistor tables. I have not yet verified the actual temperatures, and when I do, I'm afraid I'll be surprised.

I keep extruding ABS at what seems to be very low temperature, about 180 deg. C. This, I think is not normal but rather an indication that my thermistor tables are the wrong ones, or that the difference between the thermistor reading and the actual melt chamber is a lot greater than I thought it is. I'll do a test with icy and boiling water and see how it comes out.

EDIT:
I just turned the heater off and kept pushing the filament by hand in the barrel. It stopped coming out of the nozzle at abt. 90°C !!
Is this normal? I definitely need to do a temperature verification.

EDIT 2:
Or I may have done something wrong while fiddling with the extruder tonight. :?

EDIT 3:
As it turns out, I fried the thermistor while doing some high temperature measurements last night. It continued showing temperatures, only they were way out of order. I will probably have to use thermocouples for such work. Ιt looks like the 300°C limit on the EPCOS thermistor needs to be taken seriously into consideration. :oops: