Extruder PID Temperature Controller 7

Posted by Tim on September 30, 2009

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)

Extruder default (bang-bang) temperature control

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:

Extruder temperature PID control

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.

RepRap (RepStrap) Completed!

Posted by Tim on September 24, 2009

After a day of adjustments and tweaking, I finally have the bot all assembled. Next step: Smoke test!

I started with testing the heater element. A little bit of smoke as the heater came up to temp, but otherwise, everything seemed fine, and I was able to get temp to stabilize around 220C.

Next, I put a short length of abs in the extruder and turned on the drive motor…

Success!

Some pics of the completed machine:

completed reprap/repstrap

completed reprap/repstrap

Z-Axis Progress

Posted by Tim on September 16, 2009

I’m pretty sure I completed all of the machine work today, so assembly should start tomorrow.  Lots of time at the drill press:

z-axis build

Laying out components in preparation for riveting:

z-axis build

I forgot to post a pic of the electronics mounting, so here it is:

control electronics mounting

Z-Axis Design Work

Posted by Tim on September 14, 2009

Some more progress on the z-axis design:

z-axis design

I’ve set it up for 4″ of vertical movement.

The cart will slide on a single linear axis (rod and brass bushings). A second rod off to the side will only provide rotational constraint to avoid binding issues. The middle rod is threaded, and attached to the stepper.  I think the drive rod will seat in a flanged bearing on the bottom rail to take the axial load.  At the top I’ll use a flexible drive coupler to attach it to the stepper.

RepRap/RepStrap Awakens

Posted by Tim on September 13, 2009

Mounted the electronics, completed all the wiring, and then fired up the bot for the first time:

X and Y axes only for now.

The NEMA 17 steppers are a lot more powerful than I expected. When they are moving, they set up some pretty significant vibrations in a couple of spots. I think I need to start by lowering the power settings. The higher feedrates also seem much smoother.

Can’t wait for the microstepping driver boards :)

XY Stage Complete 1

Posted by Tim on September 09, 2009

I completed milling the last stepper mount and installed the motor. The mounting holes were milled as slots to allow for belt tension adjustment. The drive belts are attached to each stage by clamping them between some small aluminum pieces.  This seems to hold the belt nicely.

Next, I started work on the endstop switches. I didn’t think about their location when I designed the stages, so of course there wasn’t much room for mounting. After a couple days of fiddling with them, I finally got them attached.

A progress shot:

build progress

Here you can see some of the endstops mounted:

endstops detail

Next: Hook it all up and get the motors running.

XY Stage Progress

Posted by Tim on September 01, 2009

Made a bunch of headway on the XY stage. Just need to mill the stepper mount for the x-axis and figure out how to clamp the stages to the belts.

IMG_0760

A closeup of some mechanicals:

IMG_0763

Using bronze bushings/steel rod seems to work well. There is very little breakout friction, and the movement is very smooth. I tried nylon bushings, but the breakout friction was suprisingly large. Didn’t try PFTE at $4/bushing — yikes!

The bronze bushings are finicky — they bind hard unless they are aligned well, which turned out to be pretty easy to do. The only issue I have now is that the 5/16″ rods I received from McMaster were precision ground, which I’ve found don’t work well for linear bearing use. They have very tiny grooves from the grinding process, so when you slide the bushing they buzz. I’ve had better luck with rolled steel, which has larger tolerances but has a smoother finish.

Next: Time to design the z-axis!