Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for "dithering" behavior #266

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions src/replicatorg/drivers/gen3/Makerbot4GAlternateDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,22 @@ public class Makerbot4GAlternateDriver extends Makerbot4GDriver {

private boolean stepperExtruderFanEnabled = false;

public String getDriverName() {
@Override public String getDriverName() {
return "Makerbot4GAlternate";
}

public void reset() {
@Override public void reset() {
// We should poll the machine for it's state here, but it is more important to have the
// fan on than off.
stepperExtruderFanEnabled = false;

super.reset();
}

/** The excess, in steps, from previous operations. */
protected Point5d stepExcess = new Point5d();

/**
* Overloaded to manage a hijacked axis and run this axis in relative mode instead of the extruder DC motor
*/
public void queuePoint(Point5d p) throws RetryException {
@Override public void queuePoint(Point5d p) throws RetryException {
// If we don't know our current position, make this move an old-style move, ignoring any hijacked axes.
if (positionLost()) {
Base.logger.fine("Position invalid, reverting to default speed for next motion");
Expand Down Expand Up @@ -69,10 +66,7 @@ public void queuePoint(Point5d p) throws RetryException {

// okay, send it off!
// TODO: bug: We move all axes (even ones that shouldn't be moved) How to avoid?
Point5d excess = new Point5d(stepExcess);
queueAbsolutePoint(machine.mmToSteps(filteredPoint, excess), longestDDA);
// Only update excess if no retry was thrown.
stepExcess = excess;
queueAbsolutePoint(machine.mmToSteps(filteredPoint), longestDDA);
// Finally, recored the position, and mark it as valid.
setInternalPosition(filteredPoint);
} else {
Expand Down Expand Up @@ -100,19 +94,15 @@ public void queuePoint(Point5d p) throws RetryException {
delta.add(axesmovement);
filteredpoint.add(axesmovement);

Point5d excess = new Point5d(stepExcess);
// Calculate time for move in usec
Point5d steps = machine.mmToSteps(filteredpoint,excess);
Point5d steps = machine.mmToSteps(filteredpoint);

// okay, send it off!
// The 4. and 5. dimensions doesn't have a spatial interpretation. Calculate time in 3D space
double minutes = delta.get3D().distance(new Point3d())/ getSafeFeedrate(delta);

queueNewPoint(steps, (long) (60 * 1000 * 1000 * minutes), relative);

// Only update excess if no retry was thrown.
stepExcess = excess;

setInternalPosition(filteredpoint);
}
}
Expand All @@ -122,7 +112,7 @@ public void queuePoint(Point5d p) throws RetryException {
* In legacy use, delayed while a DC motor ran. For compatiblity, this function
* creates a Point5D to do 'extrude while sitting still'.
*/
public void delay(long millis) throws RetryException {
@Override public void delay(long millis) throws RetryException {
Base.logger.finer("Delaying " + millis + " millis.");

Point5d steps = pointsFromHijackedAxes( machine.currentTool(), millis / 60000d);
Expand Down Expand Up @@ -233,7 +223,7 @@ private Point5d pointsFromHijackedAxes(ToolModel curTool, double minutes) {
return steps;
}

public void stop(boolean abort) {
@Override public void stop(boolean abort) {
// Record the toolstate as off, so we don't excite the extruder motor in future moves.
machine.currentTool().disableMotor();

Expand Down Expand Up @@ -274,38 +264,41 @@ protected void queueNewPoint(Point5d steps, long us, int relative) throws RetryE
/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void enableMotor() throws RetryException {
machine.currentTool().enableMotor();
@Override public void enableMotor(int toolhead) throws RetryException {
if (toolhead == -1 ) toolhead = machine.currentTool().getIndex();
machine.getTool(toolhead).enableMotor();
}

/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void disableMotor() throws RetryException {
machine.currentTool().disableMotor();
@Override public void disableMotor(int toolhead) throws RetryException {
if (toolhead == -1 ) toolhead = machine.currentTool().getIndex();

machine.getTool(toolhead).disableMotor();
}

/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void setMotorSpeedPWM(int pwm) throws RetryException {
@Override public void setMotorSpeedPWM(int pwm) throws RetryException {
machine.currentTool().setMotorSpeedPWM(pwm);
}

/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void setMotorRPM(double rpm, int toolhead) throws RetryException {
@Override public void setMotorRPM(double rpm, int toolhead) throws RetryException {
machine.currentTool().setMotorSpeedRPM(rpm);
}

public void enableDrives() throws RetryException {
@Override public void enableDrives() throws RetryException {
enableStepperExtruderFan(true);

super.enableDrives();
}

public void disableDrives() throws RetryException {
@Override public void disableDrives() throws RetryException {
enableStepperExtruderFan(false);

super.disableDrives();
Expand All @@ -315,7 +308,7 @@ public void disableDrives() throws RetryException {
* Will turn on/off the stepper extruder fan if it's not already in the correct state.
*
*/
public void enableStepperExtruderFan(boolean enabled) throws RetryException {
@Override public void enableStepperExtruderFan(boolean enabled) throws RetryException {

// Always re-enable the fan when
if (this.stepperExtruderFanEnabled == enabled) return;
Expand Down Expand Up @@ -352,11 +345,10 @@ public void enableStepperExtruderFan(boolean enabled) throws RetryException {
/// This is a list of which axis are hijacked for extruder use.
EnumMap<AxisId,ToolModel> extruderHijackedMap = new EnumMap<AxisId,ToolModel>(AxisId.class);

@Override
/**
* When the machine is set for this driver, some toolheads may poach the an extrusion axis.
*/
public void setMachine(MachineModel m) {
@Override public void setMachine(MachineModel m) {
super.setMachine(m);
for (ToolModel tm : m.getTools()) {
Element e = (Element)tm.getXml();
Expand All @@ -380,12 +372,11 @@ public void setMachine(MachineModel m) {
}
}

@Override
/**
* Overridden to not ask the board for the RPM as it would report the RPM from the extruder
* controller, which doesn't know about it in this case.
*/
public double getMotorRPM() {
@Override public double getMotorRPM() {
double rpm = machine.currentTool().getMotorSpeedRPM();
machine.currentTool().setMotorSpeedReadingRPM(rpm);
return rpm;
Expand Down
8 changes: 1 addition & 7 deletions src/replicatorg/drivers/gen3/MightyBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ public void queuePoint(final Point5d p) throws RetryException {
}

// calculate absolute position of target in steps
Point5d excess = new Point5d(stepExcess);
Point5d steps = machine.mmToSteps(target,excess);
Point5d steps = machine.mmToSteps(target);

double usec = (60 * 1000 * 1000 * minutes);

Expand All @@ -486,9 +485,6 @@ public void queuePoint(final Point5d p) throws RetryException {
int relativeAxes = (1 << AxisId.A.getIndex()) | (1 << AxisId.B.getIndex());
queueNewPoint(steps, (long) usec, relativeAxes);

// Only update excess if no retry was thrown.
stepExcess = excess;

// because of the hinky stuff we've been doing with A & B axes, just pretend we've
// moved where we thought we were moving
Point5d fakeOut = new Point5d(target);
Expand Down Expand Up @@ -1023,7 +1019,6 @@ public boolean setConnectedToolIndex(int index) {
}


@Override
@Deprecated
protected void writeToToolEEPROM(int offset, byte[] data) {
writeToToolEEPROM(offset, data, machine.currentTool().getIndex());
Expand Down Expand Up @@ -1186,7 +1181,6 @@ public int getT0(int which, int toolIndex) {
return val;
}

@Override
@Deprecated
protected int read16FromToolEEPROM(int offset, int defaultValue) {
return read16FromToolEEPROM(offset, defaultValue, machine.currentTool().getIndex());
Expand Down
Loading