After getting my extruder running, I noticed that the drive was struggling a bit. I could hear the motor working harder, and the filament would start slipping. The problem didn’t happen all the time — just periodically. That first got me thinking that the drive bushing wasn’t engaging the filament evenly. But then I noticed that the problem was synchronized with the blinking of the heater drive LED. Hmm…
Is it possible that the extruder temp was falling low enough during the heating cycle that the drive would have trouble pushing it through the extruder?
Mostly out of curiosity, I began to investigate the heater controller code. After a bit of poking around the code and tinkering with the thermistor location, I wasn’t quite satisfied with the temperature control, I decided to try to improve it a bit by implementing a PID controller. At the time, I also stumbled across the BareBones Coffee Controller which uses an Arduino to control the temperature of coffee and espresso machines and has a nice GUI temperature monitor. With a bit of tweaking, I was able to hook up the monitor to my extruder controller and do some experimenting.
Here’s a plot of the default bang-bang temperature control operating on my machine: (click image for larger version)
This shows the controller taking the heater temperature from ~50C to a target temp of 220C. The blue line shows the heater control PWM output (0-255). You can clearly see how the bang-bang control switches between high and low settings when the temperature crosses the target.
Now here is a plot of the PID controller in operation:
The target temperature is reached a bit slower, but with minimal overshoot. And when it is up to temp, the temperature error is greatly improved.
The heater control looks very erratic (and it is!), but I found that the spikes are from the D (damping) term which is a function of the temperature rate of change. Since the temperature sampling produces a relatively low resolution discrete value, the temperature changes in steps. And each of these steps looks like a big rate of change of temp to the controller. What is interesting is that it still works well. When I take out the damping term, I have more overshoot, so the term is still doing what it should.
Selecting good PID gains was a bit painful due to the slow moving plant. I’m not at all sure that I’ve got gains that are even close to optimal. But I’ve been using the controller for the past week, and it seems to work fine as it is.
Could the performance of the default bang-bang controller be improved? Most definitely. This is somewhat an unfair comparison because I did a lot of tweaking of the PID parameters, but didn’t change the default heater_high and heater_low parameters at all.
I’ve made the code for the PID controller available here as a patch to the arduino slave firmware. I’m working off the Makerbot svn codebase. The default controller or the PID controller can be selected at compile time.
To run the monitor, you need to connect your serial line directly to the extruder (the monitor can’t be used during normal printing operation — it is just for testing). I’ve included the ability to change target temp, toggle the motor on and off and change direction, and a few other things from the monitor. The code is available here.











