Skip to content
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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Patrick Knöbel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions README-BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To build the program (with changes to the source):

- install version 1.8 (aka 8.0) of the `JDK`, (openJDK variants such as [Azul's Zulu JDK](https://www.azul.com/downloads/?package=jdk&show-old-builds=true#zulu) may have better support for modern systems).

- copy or hardlink `nrjavaserial-3.9.3.jar` and `jssc.jar` to the directory `./dist/lib/`

- run `ant` from the top level directory of the repo to build the changes, with a command of the form
```
ant -Dplatforms.JDK_1.8.home=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home -Dnb.internal.action.name=build jar
```

this will produce the output jar files in the dist directory.
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
cncgcodecontroller
CNC-GCode-Controller
==================
If you use a reprap Controller (like Marlin ...) for a CNC machine then this is your Program ;-)

CNC-GCode-Controller
### Features:
* Communication with the Controller over com port
* Basic movements with preview
* Loading cnc files
* Preview of cnc file
* Autoleveling (at this point only for Marlin firmware because of hit endstop message)
* for GRPL you neet to set $10=2 for this to work!
* Optimise G0 movements
* Most commonly used Gcodes are translated for a Reprap Controller (Tested with Marlin)
* Backlash correction
* Artsupport

### Tutorial Videos:
* [en] https://youtu.be/xxbBipRvp5I
* [de] https://youtu.be/hYSPs9B2VUM

### Infos:
http://reprap.org/wiki/CNC_Gcode_controller

![ccgc](https://cloud.githubusercontent.com/assets/5472845/19075920/327ab30e-8a47-11e6-9517-498ba40fde2b.png)
![ccgc2](https://cloud.githubusercontent.com/assets/5472845/19075921/32827026-8a47-11e6-8370-83a8877f99bc.png)
![cncgcode_simplecontrols](https://cloud.githubusercontent.com/assets/7280879/6883509/cc5aa17a-d5b0-11e4-99d4-b629e83e760d.png)
![cnccontroller2](https://f.cloud.github.com/assets/5472845/1229735/47a2a5e4-27c0-11e3-82fe-a572220cfceb.png)
![cnccontroller3](https://f.cloud.github.com/assets/5472845/1229736/47b8d0f8-27c0-11e3-904b-6daddec09239.png)
35 changes: 32 additions & 3 deletions src/cnc/gcode/controller/CNCCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,28 @@ public class Move
private final double[] s;
private final double[] e;
private double a;
private double spindle;
private final Type t;
private final boolean xyz;

public Move(double[] s, double[] e, double a, Type t, boolean xyz) {
public Move(double[] s, double[] e, double a, Type t, boolean xyz, double spindle) {
this.s = s;
this.e = e;
this.t = t;
this.a = a;
this.xyz=xyz;
this.spindle=spindle;
}

public Move(double[] s, double[] e, double a, Type t, boolean xyz) {
this.s = s;
this.e = e;
this.t = t;
this.a = a;
this.xyz=xyz;
this.spindle = Double.NaN;
}

public void scalexy(double[] scale){
for(int i=0;i<2;i++){
s[i]=s[i]*scale[i];
Expand Down Expand Up @@ -121,6 +132,10 @@ public double getA(){
return a;
}

public double getSpindle(){
return spindle;
}

public double getDistanceXY()
{
double dx = s[0]- e[0];
Expand Down Expand Up @@ -652,13 +667,17 @@ public State calcCommand(Calchelper c)
if(move.a!=0){
used=true;
}
if(Double.isNaN(move.spindle) == false){
message += "Spindle speed set";
used=true;
}
if(used == false)
{
if(state == State.NORMAL)
{
state = State.WARNING;
}
message += "Command without any movment! ";
message += "Command without any movment!";
}

if(move.s[2] != move.e[2] && Double.isNaN(move.e[2]) == false)
Expand Down Expand Up @@ -710,7 +729,11 @@ public Move[] getMoves()
case G1:
case HOMING:
case SETPOS:
moves.add(new Move(Arrays.copyOfRange(cin.axes, 0, 3), Arrays.copyOfRange(cout.axes, 0, 3),p.contains('A')?p.get('A').value:0.0, type,xyzmove));
if(p.contains('S')){
moves.add(new Move(Arrays.copyOfRange(cin.axes, 0, 3), Arrays.copyOfRange(cout.axes, 0, 3),p.contains('A')?p.get('A').value:0.0, type,xyzmove, p.get('S').value));
} else {
moves.add(new Move(Arrays.copyOfRange(cin.axes, 0, 3), Arrays.copyOfRange(cout.axes, 0, 3),p.contains('A')?p.get('A').value:0.0, type,xyzmove));
}
break;

case ARC:
Expand Down Expand Up @@ -933,6 +956,12 @@ String[] execute(Transform t, boolean autoleveling, boolean noshort) {
cmd += " " + 'A' + Tools.dtostr(move.a);
doMove = true;
}

if(Double.isNaN(move.spindle)==false){
cmd += " " + 'S' + Tools.dtostr(move.spindle);
doMove = true;
}

if(doMove == false && !Double.isNaN(cin.axes[3]) && !Double.isNaN(cout.axes[3]) && cin.axes[3] == cout.axes[3])
{
continue;
Expand Down
5 changes: 3 additions & 2 deletions src/cnc/gcode/controller/DatabaseV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public enum DatabaseV2 {

//Communication Type
COMTYPE(Communication.MARLIN.toString()),
CSTREAMAHEAD(EOnOff.OFF.name()),

//Color Settings:
CBACKGROUND(""+Color.WHITE.getRGB()),
Expand All @@ -86,7 +87,7 @@ public enum DatabaseV2 {
ARTSETTINGS((new ArtSettings()).toString()),
;

enum EHoming{
public enum EHoming{
//Homing Point 0= upper left; 1= upper right; 2= lower left; 3= lower right;
UPPER_LEFT,
UPPER_RIGHT,
Expand All @@ -107,7 +108,7 @@ public void set(){
}
}

enum EOnOff{
public enum EOnOff{
ON,
OFF;

Expand Down
2 changes: 1 addition & 1 deletion src/cnc/gcode/controller/JPanelAutoLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ protected String doInBackground() throws Exception {

if(pos == false)
{
throw new MyException("Timeout: No position report!");
throw new MyException("Timeout: No position report!\nFor GRPL you neet to set $10=2 for this to work!");
}

double thitValue = hitvalue;
Expand Down
41 changes: 35 additions & 6 deletions src/cnc/gcode/controller/JPanelSettings.form
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="jLabel43" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
Expand Down Expand Up @@ -68,6 +64,7 @@
<Component id="jBSCG0" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jBSCG1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jBSCNCAFeedrate" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jBSCStreamAhead" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jLabel44" alignment="0" min="-2" max="-2" attributes="0"/>
Expand All @@ -82,13 +79,18 @@
<Component id="jLabel47" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel48" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel45" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel51" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="50" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLSCNCAFeedrate" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLSCNCG0Feedrate" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="jLabel43" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="312" pref="312" max="-2" attributes="0"/>
<Component id="jLSCG1" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -169,9 +171,12 @@
<EmptySpace min="312" pref="312" max="-2" attributes="0"/>
<Component id="jLSHomeing" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="312" pref="312" max="-2" attributes="0"/>
<Component id="jLSCBack" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLSCStreamAhead" min="-2" max="-2" attributes="0"/>
<Component id="jLSCBack" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
Expand Down Expand Up @@ -290,6 +295,12 @@
<Component id="jLSComType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel51" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jBSCStreamAhead" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLSCStreamAhead" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel46" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jBSCBack" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -636,6 +647,24 @@
<Property name="text" type="java.lang.String" value="Settings Text"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel51">
<Properties>
<Property name="text" type="java.lang.String" value="Stream ahead"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jBSCStreamAhead">
<Properties>
<Property name="text" type="java.lang.String" value="Change"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBSettingsActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLSCStreamAhead">
<Properties>
<Property name="text" type="java.lang.String" value="Settings Text"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel46">
<Properties>
<Property name="text" type="java.lang.String" value="Background color:"/>
Expand Down
Loading