Thursday, May 07, 2009
4D Printing

Wot? Another coat hook? So what's new here?
The fact that it was printed in four dimensions, that's what. I've upgraded the Java host software and the Arduino/Sanguino G-code firmware so that the system treats the filament length to be extruded in each movement as another independent movement variable, like X, Y, and Z (as proposed here; you've got to have a stepper-driven extruder - like the pinch-wheel extruder - for this to work).
That is to say, the DDA in the firmware, which previously generated straight lines in (X, Y, Z) space, now generates straight lines in (X, Y, Z, E) space, where E is the growing length of extrudate needed.
From the outside, this means that everything works exactly as before. So why bother? The reason is that it makes it a lot easier to do tricks like accelerating and decelerating the extrude head as it moves, which means that it can both go faster and run on less current. This will be the next thing that I do.
I've done a new release of the host software in the repository available here, and written an upgrade to the Arduino/Sanguino firmware called FourD_GCode_Interpreter available here. To turn on 4-dimensional behaviour, simply set the flag FourD=true in the reprap.preferences file. Set it false to make the machine work as it did before.
Perhaps surprisingly, the firmware doesn't need to know if it is being driven in 4D mode or 3D mode. Lines in the G-code now look like:
G1 X23.9 Y39.0 Z0.2526 E66.5 F3000.0 ;print segment
G1 X23.9 Y39.7 Z0.2526 E67.2 F3000.0 ;print segment
So, for example, the second line is saying move 0.7mm in Y from where you last were and extrude 0.7mm of filament while doing so, all at 3000 mm/minute. But if you leave the Es out and turn the extruder on and off separately, everything works just as before (so old G-code files will still work). You can still control the extrude rate separately too - just set the extruder to go at a different speed to the carriage, and everything comes out right automatically.
Unsurprisingly in retrospect, this taught me something about the control of the stepper which drives a pinch-wheel extruder: you don't want to turn the current off between plotted segments. If you do, the stored spring energy in the compressed filament and the pressure in the melt chamber cause the stepper to slip back (as no current is flowing to hold it) at the end of one line segment and before the start of the next, resulting in a poor-quality build. The new firmware turns the current on when the extruder is first used, and leaves it on until the temperature is set to cool. The latter is a bit of a hack (and we could easily add a "current off" M-code instead), but in practice it works very well. The resulting build quality is excellent.
One final thing: I have only tried the firmware in the Sanguino, and not the Arduino. I can see no reason why the latter shouldn't work, though. Let me know...
Labels: Bressenham DDA, four dimensions