Skip to content

Commit

Permalink
Added acceleration MCode support to go with https://github.com/jetty8…
Browse files Browse the repository at this point in the history
…40/G3Firmware

MCodes:  201, 203, 204, 205, 206, 207, 208, 209, 215
  • Loading branch information
jetty840 committed Feb 20, 2012
1 parent a76b483 commit b48792d
Show file tree
Hide file tree
Showing 16 changed files with 477 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/replicatorg/app/GCodeEnumeration.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,25 @@ public enum GCodeEnumeration {
M141("M", 141, "Set Chamber Temperature (Ignored)"),
M142("M", 142, "Set Chamber Holding Pressure (Ignored)"),
M200("M", 200, "Reset driver"),
M300("M", 300, "Set Servo 1 Position"),
M301("M", 301, "Set Servo 2 Position"),
M310("M", 310, "Start data capture"),
M311("M", 311, "Stop data capture"),
M312("M", 312, "Log a note to the data capture store"),
M201("M", 201, "Set max acceleration"),
M203("M", 203, "Set max feedrate"),
M204("M", 204, "Set default acceleration"),
M205("M", 205, "Set Advanced Settings"),
M206("M", 206, "Set Filament Diameter"),
M207("M", 207, "Set Advance K"),
M208("M", 208, "Set Extruder Steps:mm"),
M209("M", 209, "Set Acceleration Control"),
M210("M", 210, "Mood Light Set RGB Color"),
M211("M", 211, "Mood Light Set HSB Color"),
M212("M", 212, "Mood Light Play Script"),
M213("M", 213, "Set Buzzer Repetitions"),
M214("M", 214, "Buzz"),

M215("M", 215, "Set Axis Steps Per:mm"),
M300("M", 300, "Set Servo 1 Position"),
M301("M", 301, "Set Servo 2 Position"),
M310("M", 310, "Start data capture"),
M311("M", 311, "Stop data capture"),
M312("M", 312, "Log a note to the data capture store"),
G0("G", 0, "Rapid Positioning"),
G1("G", 1, "Coordinated Motion"),
G2("G", 2, "Clockwise Arc"),
Expand Down
76 changes: 76 additions & 0 deletions src/replicatorg/app/GCodeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,72 @@ else if (gcode.hasCode('R'))
commands.add(new replicatorg.drivers.commands.DataCaptureNote(gcode.getComment()));
break;

case M201: //Set max acceleration
{
double x = gcode.getCodeValue('X');
double y = gcode.getCodeValue('Y');
double z = gcode.getCodeValue('Z');
double a = gcode.getCodeValue('A');
commands.add(new replicatorg.drivers.commands.SetMaxAcceleration(x,y,z,a));
}
break;

case M203: //Set max feedrate
{
double x = gcode.getCodeValue('X');
double y = gcode.getCodeValue('Y');
double z = gcode.getCodeValue('Z');
double a = gcode.getCodeValue('A');
commands.add(new replicatorg.drivers.commands.SetMaxFeedRate(x,y,z,a));
}
break;

case M204: //Set default acceleration
{
double s = gcode.getCodeValue('S');
double t = gcode.getCodeValue('K');
commands.add(new replicatorg.drivers.commands.SetDefaultAcceleration(s,t));
}
break;

case M205: //Set Advanced Settings
{
double s = (double)gcode.getCodeValue('S') / 10.0;
double t = (double)gcode.getCodeValue('K') / 10.0;
double x = (double)gcode.getCodeValue('X') / 10.0;
double z = (double)gcode.getCodeValue('Z') / 10.0;
commands.add(new replicatorg.drivers.commands.SetAdvancedSettings(s,t,x,z));
}
break;

case M206: //Set Filament Diameter
{
double s = (double)gcode.getCodeValue('S') / 100.0;
commands.add(new replicatorg.drivers.commands.SetFilamentDiameter(s));
}
break;

case M207: //Set Advance K
{
double s = (double)gcode.getCodeValue('S') / 100000.0;
commands.add(new replicatorg.drivers.commands.SetAdvanceK(s));
}
break;

case M208: //Set Extruder Steps:mm
{
double a = gcode.getCodeValue('A') / 10.0;
commands.add(new replicatorg.drivers.commands.SetExtruderStepsPerMM(a));
}
break;

case M209: //Set Acceleration Control
{
double s = gcode.getCodeValue('S');
commands.add(new replicatorg.drivers.commands.SetAccelerationControl(s));
}
break;

case M210: // Mood Light Set RGB Color
double fadeSpeed = (int)gcode.getCodeValue('S');
if ( fadeSpeed == -1 ) fadeSpeed = 8; //The default
Expand Down Expand Up @@ -737,6 +803,16 @@ else if (( repeats < 1 ) || ( repeats > 255))
else commands.add(new replicatorg.drivers.commands.Buzz(buzzes, duration, repeats));
break;

case M215: //Set Axis Steps Per:mm
{
double x = (double)gcode.getCodeValue('X') / 10000.0;
double y = (double)gcode.getCodeValue('Y') / 10000.0;
double z = (double)gcode.getCodeValue('Z') / 10000.0;
double a = (double)gcode.getCodeValue('A') / 10000.0;
commands.add(new replicatorg.drivers.commands.SetAxisStepsPerMM(x,y,z,a));
}
break;

default:
throw new GCodeException("Unknown M code: M" + (int) gcode.getCodeValue('M'));
}
Expand Down
21 changes: 21 additions & 0 deletions src/replicatorg/drivers/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,27 @@ public interface Driver {

public void buzz(int buzzes, int duration, int repeats) throws RetryException;

/**
* Acceleration Methods
*/
public void setMaxAcceleration(double x, double y, double z, double a) throws RetryException;

public void setMaxFeedRate(double x, double y, double z, double a) throws RetryException;

public void setDefaultAcceleration(double s, double t) throws RetryException;

public void setAdvancedSettings(double s, double t, double x, double z) throws RetryException;

public void setFilamentDiameter(double s) throws RetryException;

public void setAdvanceK(double s) throws RetryException;

public void setExtruderStepsPerMM(double a) throws RetryException;

public void setAccelerationControl(double s) throws RetryException;

public void setAxisStepsPerMM(double x, double y, double z, double a) throws RetryException;

/**
* Home the given set of axes at the given feedrate. If the feedrate is <=0, run at
* maximum feedrate for the appropriate axes.
Expand Down
32 changes: 32 additions & 0 deletions src/replicatorg/drivers/DriverBaseImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,38 @@ public void setBuzzerRepetitions(int repeats) throws RetryException {
public void buzz(int buzzes, int duration, int repeats) throws RetryException {
}

/***************************************************************************
* Acceleration interface functions
* @throws RetryException
**************************************************************************/

public void setMaxAcceleration(double x, double y, double z, double a) throws RetryException {
}

public void setMaxFeedRate(double x, double y, double z, double a) throws RetryException {
}

public void setDefaultAcceleration(double s, double t) throws RetryException {
}

public void setAdvancedSettings(double s, double t, double x, double z) throws RetryException {
}

public void setFilamentDiameter(double s) throws RetryException {
}

public void setAdvanceK(double s) throws RetryException {
}

public void setExtruderStepsPerMM(double a) throws RetryException {
}

public void setAccelerationControl(double s) throws RetryException {
}

public void setAxisStepsPerMM(double x, double y, double z, double a) throws RetryException {
}

/***************************************************************************
* pause function
* @throws RetryException
Expand Down
54 changes: 53 additions & 1 deletion src/replicatorg/drivers/VirtualPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,62 @@ public void buzz(int buzzes, int duration, int repeats)
}

@Override
public void homeAxes(EnumSet<AxisId> axes, boolean positive, double feedrate)
public void setMaxAcceleration(double x, double y, double z, double a)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setMaxFeedRate(double x, double y, double z, double a)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setDefaultAcceleration(double s, double t)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setAdvancedSettings(double s, double t, double x, double z)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setFilamentDiameter(double s)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setAdvanceK(double s)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setExtruderStepsPerMM(double a)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setAccelerationControl(double s)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void setAxisStepsPerMM(double x, double y, double z, double a)
throws RetryException {
// TODO Auto-generated method stub
}

@Override
public void homeAxes(EnumSet<AxisId> axes, boolean positive, double feedrate) {
// TODO Auto-generated method stub
}

@Override
Expand Down
17 changes: 17 additions & 0 deletions src/replicatorg/drivers/commands/SetAccelerationControl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetAccelerationControl implements DriverCommand {

double s;

public SetAccelerationControl(double s) {
this.s = s;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setAccelerationControl(s);
}
}
17 changes: 17 additions & 0 deletions src/replicatorg/drivers/commands/SetAdvanceK.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetAdvanceK implements DriverCommand {

double s;

public SetAdvanceK(double s) {
this.s = s;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setAdvanceK(s);
}
}
20 changes: 20 additions & 0 deletions src/replicatorg/drivers/commands/SetAdvancedSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetAdvancedSettings implements DriverCommand {

double s, t, x, z;

public SetAdvancedSettings(double s, double t, double x, double z) {
this.s = s;
this.t = t;
this.x = x;
this.z = z;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setAdvancedSettings(s,t,x,z);
}
}
20 changes: 20 additions & 0 deletions src/replicatorg/drivers/commands/SetAxisStepsPerMM.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetAxisStepsPerMM implements DriverCommand {

double x, y, z, a;

public SetAxisStepsPerMM(double x, double y, double z, double a) {
this.x = x;
this.y = y;
this.z = z;
this.a = a;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setAxisStepsPerMM(x,y,z,a);
}
}
18 changes: 18 additions & 0 deletions src/replicatorg/drivers/commands/SetDefaultAcceleration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetDefaultAcceleration implements DriverCommand {

double s, t;

public SetDefaultAcceleration(double s, double t) {
this.s = s;
this.t = t;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setDefaultAcceleration(s, t);
}
}
17 changes: 17 additions & 0 deletions src/replicatorg/drivers/commands/SetExtruderStepsPerMM.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetExtruderStepsPerMM implements DriverCommand {

double a;

public SetExtruderStepsPerMM(double a) {
this.a = a;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setExtruderStepsPerMM(a);
}
}
17 changes: 17 additions & 0 deletions src/replicatorg/drivers/commands/SetFilamentDiameter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package replicatorg.drivers.commands;

import replicatorg.drivers.Driver;
import replicatorg.drivers.RetryException;

public class SetFilamentDiameter implements DriverCommand {

double s;

public SetFilamentDiameter(double s) {
this.s = s;
}
@Override
public void run(Driver driver) throws RetryException {
driver.setFilamentDiameter(s);
}
}
Loading

0 comments on commit b48792d

Please sign in to comment.