makerbot/ReplicatorG — pull request #266 by cbiffle (2012-03-09 05:39:01+00:00)
Title: Fix for "dithering" behavior

I noticed, after upgrading from 0023 to 0031, that my printer was making rapid Z-axis moves during horizontal motions --- like when laying infill.

I've tracked it down to the code that manages "excess" during rounding. See the test case in the first attached commit for a demonstration. In cases where the printer is moving along 1 or 2 axes, and the 3rd is positioned between steps, RepG currently "dithers" the 3rd axis instead of leaving it in place. If you decompile the S3G (I can send you a script if desired) the behavior becomes obvious.

I think I see what this code was trying to do, but I don't believe it's necessary. RepG maintains all coordinates in absolute G-Code units (typically millimeters) internally, so rounding errors won't accumulate from the discretization to steps. So, I've simply removed the code in question from the two affected drivers (MB4GA and MightyBoard).

In reviewing the MakerBot Operators list, I think this is responsible for several phantom problems people have reported. In particular, this can force a Z-axis hold even when the user has disabled it: the printer is being asked to move (very slightly) on Z during most horizontal moves, so it engages the axis at all times. In my case, the dithered moves can become rapid enough that the Z axis loses steps, ruining the print.

The code is also the cause of two aesthetic problems. First, it makes the printer a lot louder. Second, it can introduce jitter into otherwise straight walls, leading to visible ridges. (This is more obvious on machines with low steps/mm, like my original Gen3 Cupcake.)

You'll note that I've imported a couple of testing support libraries, in particular EasyMock. I know the use of EasyMock can be controversial, but I needed it (or something of equivalent power) to get the drivers under test harness. As I'm sure you're aware, this part of ReplicatorG isn't designed for testability, and EasyMock lets me circumvent that. Some refactoring of the drivers could render it unnecessary.