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

G2 arc code freeze #106

Closed
gendebeat opened this issue Dec 8, 2016 · 50 comments
Closed

G2 arc code freeze #106

gendebeat opened this issue Dec 8, 2016 · 50 comments
Milestone

Comments

@gendebeat
Copy link

gendebeat commented Dec 8, 2016

Hello. i think this programs is great!
I use it for a year and I like it more than the web of chilipeperr.com,It is comfortable and visually pleasing
I use now tinyg2, de 100.x branch.
i use vectric aspire and when i generate gcode with arcs, g2 or g3, the tinyg2 freeze or make bad arcs.
First i think was a tinyg2 issue, may be the configuration. i try other earlier versions but not resolve the problem.
But yesterday i try to send the same gcode through chilipepperr.com, and woilaa, it works correct.

When i use this program to send gcode like this:

G17
G21
G0 Z2.0010
G0 X0.0000 Y0.0000
G0 X5.0000 Y0.0000 Z2.0000
G1 Z-1.0000 F10000.0
G2 X0.0000 Y5.0000 I0.0000 J5.0000 F1000.0
G2 X5.0000 Y10.0000 I5.0000 J0.0000
G2 X10.0000 Y5.0000 I0.0000 J-5.0000
G2 X5.0000 Y0.0000 I-5.0000 J0.0000
G0 Z2.0000
G0 Z2.0010
G0 X0.0000 Y0.0000
M30

the program stops o make bad desings (like straigth instead of arcs).
some times in one point. sometimes in other.
may be the problem is with the J besause,
when i send code like this:

G17
G21
G2 I50 F2000
it makes the correct circle.

Can it be a problem sending the gcode through the json server?

thanks

@cheton
Copy link
Collaborator

cheton commented Dec 9, 2016

It works well if I send commands (in JSON format) line by line from the Console widget. You can try it manually:

{gc: "G17"}
{gc: "G21"}
{gc: "G0 Z2.0010"}
{gc: "G0 X0.0000 Y0.0000"}
{gc: "G0 X5.0000 Y0.0000 Z2.0000"}
{gc: "G1 Z-1.0000 F10000.0"}
{gc: "G2 X0.0000 Y5.0000 I0.0000 J5.0000 F1000.0"}
{gc: "G2 X5.0000 Y10.0000 I5.0000 J0.0000"}
{gc: "G2 X10.0000 Y5.0000 I0.0000 J-5.0000"}
{gc: "G2 X5.0000 Y0.0000 I-5.0000 J0.0000"}
{gc: "G0 Z2.0000"}
{gc: "G0 Z2.0010"}
{gc: "G0 X0.0000 Y0.0000"}
{gc: "M30"}

However, if I send the whole in a batch, things goes wrong just like you said - straight instead arcs. I will do a test on Chillipeppr and check for differences.

@cheton
Copy link
Collaborator

cheton commented Dec 9, 2016

Here is my output with cnc -vvv, I removed the last line M30 in this test:

2016-12-09T02:44:19.961Z - silly: [TinyG2] < {"r":{},"f":[1,0,12]}
2016-12-09T02:44:19.962Z - silly: [TinyG2] < {"r":{},"f":[1,0,12]}
2016-12-09T02:44:19.966Z - silly: [TinyG2] < {"r":{},"f":[1,0,18]}
2016-12-09T02:44:19.966Z - silly: [TinyG2] < {"qr":27,"qi":1,"qo":0}
2016-12-09T02:44:19.967Z - silly: [TinyG2] < {"r":{},"f":[1,0,17]}
2016-12-09T02:44:19.968Z - silly: [TinyG2] < {"r":{},"f":[1,0,20]}
2016-12-09T02:44:19.969Z - silly: [TinyG2] < {"qr":26,"qi":1,"qo":0}
2016-12-09T02:44:19.970Z - silly: [TinyG2] < {"r":{},"f":[1,0,22]}
2016-12-09T02:44:19.970Z - silly: [TinyG2] < {"qr":25,"qi":1,"qo":0}
2016-12-09T02:44:19.972Z - silly: [TinyG2] < {"r":{},"f":[1,0,23]}
2016-12-09T02:44:19.973Z - silly: [TinyG2] < {"r":{},"f":[1,0,24]}
2016-12-09T02:44:19.975Z - silly: [TinyG2] < {"r":{},"f":[1,0,25]}
2016-12-09T02:44:19.978Z - silly: [TinyG2] < {"r":{},"f":[1,0,24]}
2016-12-09T02:44:19.980Z - silly: [TinyG2] < {"r":{},"f":[1,0,14]}
2016-12-09T02:44:19.982Z - silly: [TinyG2] < {"r":{},"f":[1,0,18]}
2016-12-09T02:44:19.984Z - silly: [TinyG2] < {"r":{},"f":[1,0,17]}
2016-12-09T02:44:19.988Z - silly: [TinyG2] < {"qr":5,"qi":20,"qo":0}
2016-12-09T02:44:20.213Z - silly: [TinyG2] < {"sr":{"vel":70.18,"stat":5,"cycs":1,"mots":1,"momo":0,"posz":0.069,"mpoz":0.069}}
2016-12-09T02:44:20.463Z - silly: [TinyG2] < {"sr":{"vel":228.65,"posz":0.784,"mpoz":0.784}}
2016-12-09T02:44:20.718Z - silly: [TinyG2] < {"sr":{"vel":156.70,"posz":1.665,"mpoz":1.665}}
2016-12-09T02:44:20.877Z - silly: [TinyG2] < {"qr":6,"qi":0,"qo":1}
2016-12-09T02:44:20.971Z - silly: [TinyG2] < {"sr":{"vel":118.62,"posx":0.168,"posz":2.001,"mpox":0.168,"mpoz":2.001}}
2016-12-09T02:44:21.224Z - silly: [TinyG2] < {"sr":{"vel":321.49,"posx":1.041,"posz":2.001,"mpox":1.041,"mpoz":2.001}}
2016-12-09T02:44:21.478Z - silly: [TinyG2] < {"sr":{"vel":418.91,"posx":2.708,"posz":2.000,"mpox":2.708,"mpoz":2.000}}
2016-12-09T02:44:21.733Z - silly: [TinyG2] < {"sr":{"vel":267.10,"posx":4.252,"posz":2.000,"mpox":4.252,"mpoz":2.000}}
2016-12-09T02:44:21.986Z - silly: [TinyG2] < {"sr":{"vel":110.41,"posx":4.945,"posz":2.000,"mpox":4.945,"mpoz":2.000}}
2016-12-09T02:44:22.011Z - silly: [TinyG2] < {"qr":7,"qi":0,"qo":1}
2016-12-09T02:44:22.241Z - silly: [TinyG2] < {"sr":{"vel":203.76,"feed":10000.00,"momo":1,"posx":5.000,"posz":1.479,"mpox":5.000,"mpoz":1.479}}
2016-12-09T02:44:22.491Z - silly: [TinyG2] < {"sr":{"vel":296.97,"posz":0.328,"mpoz":0.328}}
2016-12-09T02:44:22.746Z - silly: [TinyG2] < {"sr":{"vel":155.18,"posz":-0.686,"mpoz":-0.686}}
2016-12-09T02:44:22.896Z - silly: [TinyG2] < {"qr":8,"qi":0,"qo":1}
2016-12-09T02:44:23.002Z - silly: [TinyG2] < {"sr":{"vel":154.17,"momo":2,"posx":4.795,"posy":0.013,"posz":-1.000,"mpox":4.795,"mpoy":0.013,"mpoz":-1.000}}
2016-12-09T02:44:23.125Z - silly: [TinyG2] < {"qr":9,"qi":0,"qo":1}
2016-12-09T02:44:23.253Z - silly: [TinyG2] < {"sr":{"vel":254.47,"posx":4.052,"posy":0.428,"mpox":4.052,"mpoy":0.428}}
2016-12-09T02:44:23.508Z - silly: [TinyG2] < {"sr":{"vel":516.69,"posx":3.066,"posy":1.713,"mpox":3.066,"mpoy":1.713}}
2016-12-09T02:44:23.762Z - silly: [TinyG2] < {"sr":{"vel":554.75,"posx":1.623,"posy":3.593,"mpox":1.623,"mpoy":3.593}}
2016-12-09T02:44:24.016Z - silly: [TinyG2] < {"sr":{"vel":302.31,"posx":0.492,"posy":5.067,"mpox":0.492,"mpoy":5.067}}
2016-12-09T02:44:24.191Z - silly: [TinyG2] < {"qr":10,"qi":0,"qo":1}
2016-12-09T02:44:24.270Z - silly: [TinyG2] < {"sr":{"vel":236.26,"posx":0.098,"posy":5.932,"mpox":0.098,"mpoy":5.932}}
2016-12-09T02:44:24.524Z - silly: [TinyG2] < {"sr":{"vel":302.96,"posx":0.770,"posy":6.695,"mpox":0.770,"mpoy":6.695}}
2016-12-09T02:44:24.779Z - silly: [TinyG2] < {"sr":{"vel":528.01,"posx":2.281,"posy":7.705,"mpox":2.281,"mpoy":7.705}}
2016-12-09T02:44:25.033Z - silly: [TinyG2] < {"sr":{"vel":478.75,"posx":4.136,"posy":8.944,"mpox":4.136,"mpoy":8.944}}
2016-12-09T02:44:25.287Z - silly: [TinyG2] < {"sr":{"vel":256.20,"posx":5.378,"posy":9.774,"mpox":5.378,"mpoy":9.774}}
2016-12-09T02:44:25.363Z - silly: [TinyG2] < {"qr":12,"qi":0,"qo":2}
2016-12-09T02:44:25.541Z - silly: [TinyG2] < {"sr":{"vel":246.39,"posx":6.328,"posy":9.779,"mpox":6.328,"mpoy":9.779}}
2016-12-09T02:44:25.794Z - silly: [TinyG2] < {"sr":{"vel":409.25,"posx":7.040,"posy":8.713,"mpox":7.040,"mpoy":8.713}}
2016-12-09T02:44:26.048Z - silly: [TinyG2] < {"sr":{"vel":539.46,"posx":8.225,"posy":6.939,"mpox":8.225,"mpoy":6.939}}
2016-12-09T02:44:26.303Z - silly: [TinyG2] < {"sr":{"vel":371.28,"posx":9.355,"posy":5.248,"mpox":9.355,"mpoy":5.248}}
2016-12-09T02:44:26.528Z - silly: [TinyG2] < {"qr":14,"qi":0,"qo":2}
2016-12-09T02:44:26.557Z - silly: [TinyG2] < {"sr":{"vel":247.19,"posx":9.938,"posy":4.248,"mpox":9.938,"mpoy":4.248}}
2016-12-09T02:44:26.813Z - silly: [TinyG2] < {"sr":{"vel":258.41,"momo":0,"posx":9.503,"posy":3.456,"posz":-0.797,"mpox":9.503,"mpoy":3.444,"mpoz":-0.788}}
2016-12-09T02:44:27.068Z - silly: [TinyG2] < {"sr":{"vel":531.56,"posx":8.317,"posy":2.545,"posz":-0.060,"mpox":8.317,"mpoy":2.545,"mpoz":-0.040}}
2016-12-09T02:44:27.323Z - silly: [TinyG2] < {"sr":{"vel":555.64,"posx":6.574,"posy":1.208,"posz":1.022,"mpox":6.574,"mpoy":1.208,"mpoz":1.022}}
2016-12-09T02:44:27.578Z - silly: [TinyG2] < {"sr":{"vel":253.73,"posx":5.298,"posy":0.229,"posz":1.815,"mpox":5.298,"mpoy":0.229,"mpoz":1.815}}
2016-12-09T02:44:27.832Z - silly: [TinyG2] < {"sr":{"vel":6.32,"posx":5.001,"posy":0.001,"posz":1.999,"mpox":5.001,"mpoy":0.001,"mpoz":1.999}}
2016-12-09T02:44:27.901Z - silly: [TinyG2] < {"qr":16,"qi":0,"qo":2}
2016-12-09T02:44:28.087Z - silly: [TinyG2] < {"sr":{"vel":70.88,"momo":2,"posx":5.044,"posy":0.030,"posz":1.971,"mpox":5.044,"mpoy":0.030,"mpoz":1.971}}
2016-12-09T02:44:28.341Z - silly: [TinyG2] < {"sr":{"vel":436.09,"posx":5.819,"posy":0.547,"posz":1.468,"mpox":5.819,"mpoy":0.547,"mpoz":1.468}}
2016-12-09T02:44:28.596Z - silly: [TinyG2] < {"sr":{"vel":558.06,"posx":7.456,"posy":1.641,"posz":0.405,"mpox":7.456,"mpoy":1.641,"mpoz":0.405}}
2016-12-09T02:44:28.850Z - silly: [TinyG2] < {"sr":{"vel":359.38,"posx":8.966,"posy":2.650,"posz":-0.575,"mpox":8.966,"mpoy":2.650,"mpoz":-0.575}}
2016-12-09T02:44:29.102Z - silly: [TinyG2] < {"sr":{"vel":68.95,"posx":9.549,"posy":3.039,"posz":-0.954,"mpox":9.549,"mpoy":3.039,"mpoz":-0.954}}
2016-12-09T02:44:29.200Z - silly: [TinyG2] < {"qr":17,"qi":0,"qo":1}
2016-12-09T02:44:29.356Z - silly: [TinyG2] < {"sr":{"vel":169.14,"posx":9.519,"posy":2.883,"posz":-1.000,"mpox":9.519,"mpoy":2.883,"mpoz":-1.000}}
2016-12-09T02:44:29.465Z - silly: [TinyG2] < {"qr":18,"qi":0,"qo":1}
2016-12-09T02:44:29.610Z - silly: [TinyG2] < {"sr":{"vel":278.90,"momo":0,"posx":8.896,"posy":2.249,"posz":-0.699,"mpox":8.896,"mpoy":2.249,"mpoz":-0.699}}
2016-12-09T02:44:29.865Z - silly: [TinyG2] < {"sr":{"vel":508.53,"posx":7.609,"posy":1.506,"posz":0.193,"mpox":7.609,"mpoy":1.506,"mpoz":0.193}}
2016-12-09T02:44:30.118Z - silly: [TinyG2] < {"sr":{"vel":452.75,"posx":6.029,"posy":0.594,"posz":1.288,"mpox":6.029,"mpoy":0.594,"mpoz":1.288}}
2016-12-09T02:44:30.373Z - silly: [TinyG2] < {"sr":{"vel":126.88,"posx":5.105,"posy":0.061,"posz":1.928,"mpox":5.105,"mpoy":0.061,"mpoz":1.928}}
2016-12-09T02:44:30.606Z - silly: [TinyG2] < {"qr":19,"qi":0,"qo":1}
2016-12-09T02:44:30.627Z - silly: [TinyG2] < {"sr":{"vel":0.04,"momo":2,"posx":5.000,"posy":0.000,"posz":2.001,"mpox":5.000,"mpoy":0.000,"mpoz":2.001}}
2016-12-09T02:44:30.881Z - silly: [TinyG2] < {"sr":{"vel":185.13,"posx":5.189,"posy":0.093,"posz":1.858,"mpox":5.189,"mpoy":0.093,"mpoz":1.858}}
2016-12-09T02:44:31.136Z - silly: [TinyG2] < {"sr":{"vel":478.99,"posx":6.321,"posy":0.651,"posz":1.002,"mpox":6.321,"mpoy":0.651,"mpoz":1.002}}
2016-12-09T02:44:31.392Z - silly: [TinyG2] < {"sr":{"vel":447.24,"posx":7.847,"posy":1.404,"posz":-0.153,"mpox":7.847,"mpoy":1.404,"mpoz":-0.153}}
2016-12-09T02:44:31.645Z - silly: [TinyG2] < {"sr":{"vel":141.86,"posx":8.780,"posy":1.864,"posz":-0.859,"mpox":8.780,"mpoy":1.864,"mpoz":-0.859}}
2016-12-09T02:44:31.837Z - silly: [TinyG2] < {"qr":20,"qi":0,"qo":1}
2016-12-09T02:44:31.898Z - silly: [TinyG2] < {"sr":{"vel":64.03,"posx":8.934,"posy":1.918,"posz":-1.000,"mpox":8.934,"mpoy":1.918,"mpoz":-1.000}}
2016-12-09T02:44:32.092Z - silly: [TinyG2] < {"qr":21,"qi":0,"qo":1}
2016-12-09T02:44:32.155Z - silly: [TinyG2] < {"sr":{"vel":252.22,"momo":0,"posx":8.323,"posy":1.428,"posz":-0.925,"mpox":8.323,"mpoy":1.428,"mpoz":-0.925}}
2016-12-09T02:44:32.407Z - silly: [TinyG2] < {"sr":{"vel":443.30,"posx":7.046,"posy":1.209,"posz":-0.476,"mpox":7.046,"mpoy":1.209,"mpoz":-0.476}}
2016-12-09T02:44:32.661Z - silly: [TinyG2] < {"sr":{"vel":639.69,"posx":4.812,"posy":0.826,"posz":0.309,"mpox":4.812,"mpoy":0.826,"mpoz":0.309}}
2016-12-09T02:44:32.914Z - silly: [TinyG2] < {"sr":{"vel":588.93,"posx":2.329,"posy":0.400,"posz":1.182,"mpox":2.329,"mpoy":0.400,"mpoz":1.182}}
2016-12-09T02:44:33.168Z - silly: [TinyG2] < {"sr":{"vel":289.74,"posx":0.550,"posy":0.094,"posz":1.808,"mpox":0.550,"mpoy":0.094,"mpoz":1.808}}
2016-12-09T02:44:33.422Z - silly: [TinyG2] < {"sr":{"vel":26.97,"posx":0.016,"posy":0.003,"posz":1.995,"mpox":0.016,"mpoy":0.003,"mpoz":1.995}}
2016-12-09T02:44:33.566Z - silly: [TinyG2] < {"qr":22,"qi":0,"qo":1}
2016-12-09T02:44:33.677Z - silly: [TinyG2] < {"sr":{"vel":11.39,"momo":2,"posx":0.005,"posy":0.001,"posz":1.999,"mpox":0.005,"mpoy":0.001,"mpoz":1.999}}
2016-12-09T02:44:33.930Z - silly: [TinyG2] < {"sr":{"vel":263.21,"posx":0.451,"posy":0.058,"posz":1.833,"mpox":0.451,"mpoy":0.058,"mpoz":1.833}}
2016-12-09T02:44:34.185Z - silly: [TinyG2] < {"sr":{"vel":589.30,"posx":2.207,"posy":0.283,"posz":1.178,"mpox":2.207,"mpoy":0.283,"mpoz":1.178}}
2016-12-09T02:44:34.439Z - silly: [TinyG2] < {"sr":{"vel":634.68,"posx":4.687,"posy":0.602,"posz":0.252,"mpox":4.687,"mpoy":0.602,"mpoz":0.252}}
2016-12-09T02:44:34.693Z - silly: [TinyG2] < {"sr":{"vel":425.98,"posx":6.871,"posy":0.883,"posz":-0.563,"mpox":6.871,"mpoy":0.883,"mpoz":-0.563}}
2016-12-09T02:44:34.947Z - silly: [TinyG2] < {"sr":{"vel":107.04,"posx":7.860,"posy":1.010,"posz":-0.931,"mpox":7.860,"mpoy":1.010,"mpoz":-0.931}}
2016-12-09T02:44:35.136Z - silly: [TinyG2] < {"qr":23,"qi":0,"qo":1}
2016-12-09T02:44:35.206Z - silly: [TinyG2] < {"sr":{"vel":57.46,"posx":8.004,"posy":1.007,"posz":-1.000,"mpox":8.004,"mpoy":1.007,"mpoz":-1.000}}
2016-12-09T02:44:35.408Z - silly: [TinyG2] < {"qr":24,"qi":0,"qo":1}
2016-12-09T02:44:35.456Z - silly: [TinyG2] < {"sr":{"vel":271.07,"posx":7.354,"posy":0.598,"mpox":7.354,"mpoy":0.598}}
2016-12-09T02:44:35.622Z - silly: [TinyG2] < {"qr":26,"qi":0,"qo":2}
2016-12-09T02:44:35.706Z - silly: [TinyG2] < {"sr":{"vel":335.92,"posx":5.835,"posy":0.079,"mpox":5.835,"mpoy":0.079}}
2016-12-09T02:44:35.959Z - silly: [TinyG2] < {"sr":{"vel":104.65,"posx":5.055,"posy":0.004,"mpox":5.055,"mpoy":0.004}}
2016-12-09T02:44:36.058Z - silly: [TinyG2] < {"qr":28,"qi":0,"qo":2}
2016-12-09T02:44:36.210Z - silly: [TinyG2] < {"sr":{"vel":0.00,"stat":3,"cycs":0,"mots":0,"momo":0,"posx":0.000,"posy":0.000,"posz":2.001,"mpox":0.000,"mpoy":0.000,"mpoz":2.001}}
2016-12-09T02:44:36.398Z - debug: [cncengine] socket.command("/dev/cu.usbmodemFD121", "stop"): id=mqe6Iz2J_8JpQRO8AAAB, args=[]     at Socket.<anonymous> (/Users/cheton/.nvm/versions/node/v4.5.0/lib/node_modules/cncjs/dist/cnc/app/index.js:8240:32)
2016-12-09T02:44:36.399Z - silly: [TinyG2] > !%
2016-12-09T02:44:36.650Z - silly: [TinyG2] > {clear:null}
2016-12-09T02:44:36.650Z - silly: [TinyG2] > {"qr":""}
2016-12-09T02:44:36.651Z - silly: [TinyG2] < {"r":{"clear":null},"f":[1,0,12]}
2016-12-09T02:44:36.652Z - silly: [TinyG2] < {"r":{"qr":28},"f":[1,0,9]}

@cheton
Copy link
Collaborator

cheton commented Dec 9, 2016

My firmware build is 78.02. It didn't work for me when running this G-code program on Chilipeppr's TinyG workspace as well. Sometimes G2 goes straight line with random moves and unexpected result, not sure if it's related to these issues.

Hi @jarretluft,

Do you have chances to test the G-code program with TinyG2 on Chilipeppr?

G17
G21
G0 Z2.0010
G0 X0.0000 Y0.0000
G0 X5.0000 Y0.0000 Z2.0000
G1 Z-1.0000 F10000.0
G2 X0.0000 Y5.0000 I0.0000 J5.0000 F1000.0
G2 X5.0000 Y10.0000 I5.0000 J0.0000
G2 X10.0000 Y5.0000 I0.0000 J-5.0000
G2 X5.0000 Y0.0000 I-5.0000 J0.0000
G0 Z2.0000
G0 Z2.0010
G0 X0.0000 Y0.0000
M30

@cheton
Copy link
Collaborator

cheton commented Dec 9, 2016

I made a firmware build 100.12 from G2 edge branch, and it still cannot work correctly on both cnc and Chilipeppr.

@gendebeat
Copy link
Author

??¡ I with Chilipeppr have not problems.
Summarizing:
I have g2 firmware 100.12 too. I have cnc 1.8.7, and Chilipeppr from web.
Now i try this gcode. Its a circle with radius 10mm. I use laser gcode to see the results.

G17
G21
G0 X0.0000 Y0.0000 M03 S0
G0 X10.0000 Y0.0000 M03 S0
G1   F10000.0 M03 S50 
G2 X0.0000 Y10.0000 I0.0000 J10.0000 F2000.0 M03 S50
G2 X10.0000 Y20.0000 I10.0000 J0.0000
G2 X20.0000 Y10.0000 I0.0000 J-10.0000
G2 X10.0000 Y0.0000 I-10.0000 J0.0000
S0
M05
G0 X0.0000 Y0.0000
M30 

With Chilipeppr it make a fluid circle, not problem. It do a good round corners in squares too.
not problem using g2 or g3 code with I and J parameter.
With CNC 1.8.7 some software freeze: CNC, g2core? may be can laser a quartes of circle and then stop
(danger, laser stays ON) I need to reset arduino due, reset serial json server and reconect CNC sofware.
May be a problem with serial comunication CNC<->JSON ??

@amx1
Copy link

amx1 commented Dec 29, 2016

Dear Cheton, dear Gendebeat,

I observed the same behavior using arcs (G2 and G3 commands), even with the latest firmware 100.15. The problem seems to be the handshake protocol of the TinyG2 controller. G2 and G3 commands may lead to a buffer overflow of the planner buffer, because these commands fill the planner buffer directly. I tried to modify the code due to the description of the communication protocol. 1) send a command to the controler 2) wait for a receive (ack - send as r: 3) send next command. This didn't work with arc commands, because these commands fill the planner buffer with a lot more than one value and the qr response is to slow. If you send more commands when the planner buffer gets filled by the G2/G3 commands, the controler crashes (??) I tried to program around this issue, but I don't know if it is the best implementation using the status report of the controler when a motion command is finished. (sr: line: #) The commands will be checked before sending and generate line numbers. If a G2/G3 command is sent, the sender will wait until the planner buffer has some free space and motion command is completed. I tested it with some different programs and looks quite good. You will find the modified files as attachment.

Best

Axel

TinyG2.zip

@cheton
Copy link
Collaborator

cheton commented Dec 30, 2016

@amx1 I will do some tests for your code. Thank you so much for your help.

@amx1
Copy link

amx1 commented Jan 7, 2017

Hi,
I am still working on the TinyG2 problem. (Even the latest version of CNC has problems with arc commands on TinyG2). The update of the firmware V100.17 for TinyG2 arduino due based hardware changed the handshake behavoir of the controller pretty much. Alden Hart is working on it. The handshake is very close to the proposed protocol now. If you read the TinyG2 forum, he is still fighting with the input buffer overflow issue. I changed my old approach - which tried to overcome the problems of V100.16 and earlier. As attachment you will find my actual version, which is pretty much straight forward now. Dont forget to update the controller to V100.17. It doesnt run on 100.16 or earlier. It seems to run pretty smooth and you can really take advantage of the large planner queue.

I tested the codes of the example directory, e.g. jsdc.gcode, g2-arc.gcode, ... Some examples like the helical and the 3D print codes don't work, because the commands (E... and 3D arc) are not supported by TinyG2.

Best

Axel

TinyG2_V100.17.zip

@cheton
Copy link
Collaborator

cheton commented Jan 8, 2017

Thank you for the information. I did experience some problems with v100.15 and cannot figure out what went wrong. I will try your solution with v100.17 and keep you updated.

@amx1
Copy link

amx1 commented Jan 8, 2017 via email

@cheton
Copy link
Collaborator

cheton commented Jan 9, 2017

Note that I made some code changes to the controller interface in v1.8.13. If you want to merge with new changes, you need to update your code with new initialization parameter and the 'load' command callback.

https://github.com/cheton/cnc/blob/83377954b77ac84cd5c8b1aad6e11f47967ceaec/src/app/controllers/TinyG2/TinyG2Controller.js#L105

this.sender = new Sender(STREAMING_PROTOCOL_SEND_RESPONSE);

https://github.com/cheton/cnc/blob/83377954b77ac84cd5c8b1aad6e11f47967ceaec/src/app/controllers/TinyG2/TinyG2Controller.js#L491

'load': () => {
    const [name, gcode, callback = noop] = args;

    const ok = this.sender.load(name, gcode);
    if (!ok) {
        callback(new Error(`Invalid G-code: name=${name}`));
        return;
    }

    log.debug(`[TinyG2] Load G-code: name="${this.sender.name}", size=${this.sender.gcode.length}, total=${this.sender.total}`);

    this.workflowState = WORKFLOW_STATE_IDLE;
    callback(null, { name: name, gcode: gcode });
},

@cheton
Copy link
Collaborator

cheton commented Jan 9, 2017

I upgraded my Arduino Due firmware to g2core v100.19 and tested several gcode files (e.g. "jsdc.gcode") with your code, but it didn't report machine position and all stopped from the beginning.

image

May I have your terminal output to compare the differences? You can run cnc -vvv with verbose output and try loading jsdc.gcode as shown below:

image

cheton added a commit that referenced this issue Jan 9, 2017
@cheton
Copy link
Collaborator

cheton commented Jan 9, 2017

I created a g2core branch (https://github.com/cheton/cnc/tree/g2core). You can try it with v100.17 on an Arduino due board.

@amx1
Copy link

amx1 commented Jan 9, 2017 via email

@aldenhart
Copy link

aldenhart commented Jan 9, 2017

The machine position is always reported in MM, and in absolute (machine) coordinates with no offsets. This is to provide UIs with the ability to always display a graphic position without having to track the units more or state of the offsets (which can get complicated).

Update: I realize this could be clearer in the status reports page, so I updated it:
https://github.com/synthetos/g2/wiki/Status-Reports

@cheton
Copy link
Collaborator

cheton commented Jan 9, 2017

Hi amx1,

I cannot see your attachment, could you upload files again?

BTW, please let me know if you are interested in becoming a project collaborator, I can add you to the collaborator list, and you can push commits to the g2core branch for verification.

@amx1
Copy link

amx1 commented Jan 9, 2017 via email

@cheton
Copy link
Collaborator

cheton commented Jan 10, 2017

Invitation sent

@amx1
Copy link

amx1 commented Feb 1, 2017

The firmware TinyG2 for arduino due had some issues suddenly stopping the job, but the problems should be solved now. Aldenhart and Giseburt will include the changes in the next few days in the edge branch. You might test the FW branch dev-209b... synthetos/g2#209. I had no errors since then.

I also updated the TinyG controller part of cnc. Thank you cheton for inviting me and setting up a separate branch, but I hope it is fixed now and I will leave to you to include the changes into your dev branches. I think we don't need a separate branch for this now. There is one point left: The performance of the GUI depends very much on the power and the OS of the machine running the browser. My setup: the controller is connected to a X86 PC running Ubuntu 16.04 64bit. The front end is a dual boot laptop dell x86 Windows 8.1 or Ubuntu 16.04 64bit, Wifi. The GUI is quite slow and the updates of the positions of the machine are stuttering on Windows 8.1 either with chrome or firefox. On linux it is very smooth in both cases even on the same Laptop! The controller is not loosing any commands or steps in all cases. It is mainly a GUI problem.

Attached you will find the updated version based on v1.8.15. It implements the simple linemode protocol with a low / high water threshold to throttle the sender in case of very fast jobs. Otherwise you might get not updates of the position. See discussions with fw developers synthetos/g2#209

CNC_TinyG2_g2core_V1.zip

@amx1
Copy link

amx1 commented Feb 1, 2017

I just patched the 1.9.0 alpha version to support the latest g2core FW on Arduino Due

@cheton I had to change the init sequence, because you can't split the sr sequence in two parts. The first one will be overwritten on Arduino Due. There is a buffer limit of 254 chars, so I implemented a compression hack.

TinyG2_g2core_1.9.0.zip

@cheton
Copy link
Collaborator

cheton commented Feb 1, 2017

Thank you for your efforts! I will make a test by tomorrow.

@cheton
Copy link
Collaborator

cheton commented Feb 2, 2017

@amx1,

Thanks for the information. I took a look at synthetos/g2#209 and made several tests, the result of my experiment confirms the same thing as @giseburt said in synthetos/g2#209 (comment), sending {"gc":...} will bypass queue throttling and caused unexpected behaviour with G2 or G3 arcs. Change the sending routine to send simple command string instead of {gc:...} can resolve this issue with TinyG firmware version 0.97 and 0.98. 🥂

In addition, I'll also remove the help query (?) from my init commands, as it will turn subsequent status reports to standard text output, not in JSON format. That might be the actual reason why I chose to use {"gc":...} to send g-code lines from the beginning, since sending {"gc":...} will enforce JSON reporting.

Hi @giseburt,

After upgrading to g2core firmware build 100.19 for my Arduino Due, I faced two issues as listed below:

  • Both work and machine positions are not updated in status reports. You can check the output, after sending initialization commands, I manually send "G0X50Y50", "G0X20Y20Z50", "{sr:null}", and "G0X0Y0" as shown below, but couldn't get updated result for machine and work positions.
{"r":{"fv":0.99,"fb":100.19,"fbs":"100.19-12-gb6995","fbc":"settings_default.h","hp":3,"hv":0,"id":"0084-7bd6-29c6-7bd","msg":"SYSTEM READY"},"f":[1,0,1]}
> {"ej":1}
{"r":{"ej":1},"f":[1,0,10]}
> {"jv":4}
{"r":{"jv":4},"f":[1,0,10]}
> {"qv":2}
{"r":{"qv":2},"f":[1,0,10]}
> {"sv":1}
{"r":{"sv":1},"f":[1,0,10]}
> {"si":250}
{"r":{"si":250},"f":[1,0,12]}
{"sr":{"stat":3}}
> {sr:{line:t,vel:t,feed:t,stat:t,cycs:t,mots:t,hold:t,momo:t,coor:t,plan:t,unit:t,dist:t,frmo:t,path:t,posx:t,posy:t,posz:t,posa:t,mpox:t,mpoy:t,mpoz:t,mpoa:t}}
{"r":{"sr":{"line":7,"vel":0,"feed":500,"stat":3,"cycs":0,"mots":0,"hold":0,"momo":0,"coor":1,"plan":0,"unit":1,"dist":0,"frmo":1,"path":2,"posx":0,"posy":0,"posz":0,"posa":0,"mpox":0,"mpoy":0,"mpoz":0,"mpoa":0}},"f":[1,0,161]}
> {"hp":null}
> {"fb":null}
{"r":{"hp":3},"f":[1,0,13]}
{"r":{"fb":100.19},"f":[1,0,13]}
> {"mt":null}
> G0X50Y50
{"r":{},"f":[1,0,9]}
{"sr":{"line":0,"stat":5,"cycs":1}}
> G0X20Y20Z50
{"r":{},"f":[1,0,12]}
> {sr:null}
{"r":{"sr":{"line":0,"vel":0,"feed":500,"stat":5,"cycs":1,"mots":0,"hold":0,"momo":0,"coor":1,"plan":0,"unit":1,"dist":0,"frmo":1,"path":2,"posx":0,"posy":0,"posz":0,"posa":0,"mpox":0,"mpoy":0,"mpoz":0,"mpoa":0}},"f":[1,0,11]}
> G0X0Y0
{"r":{},"f":[1,0,7]}
  • With g2core firmware build 100.19, this gcode file "circle.nc"
G0 X-5 Y0 Z0 F200
G2 X0 Y5 I5 J0 F200
G2 X5 Y0 I0 J-5
G2 X0 Y-5 I-5 J0
G2 X-5 Y0 I0 J5
G1 Z1 F500
G0 X0 Y0 Z5

reported an error of "159: Arc specification error - endpoint is starting point"

> G2 X5 Y0 I0 J-5
{"r":{"n":2},"f":[1,159,17]}

This error doesn't happen with firmware version 0.98 (firmware build: 87.01).

@amx1
Copy link

amx1 commented Feb 2, 2017

@cheton
I made a fast check with my modifications. I see no errors with your short example. It is running without problems. I attached the full log (-vvv) of my actual version.

I saw also the effect of the missing reports of line, feed, etc. The problem is, that you split the configuration of the report in 2 parts from v1.8.15 to 1.9.0 during init. All switches not set to true, will be set to false by default. Therefore the first part is ignored. You can overcome this and the limitation of 254 character by compressing the commands using t instead of true. It will give you some extra space. With this option the whole configuration could be send in one line. If you take a look at my version, you can see that I put everything in one command and used a .replace after JSON.stringify. It was the fastest way to implement it. Take a look at the sent commands in the log marked as: "[TinyG2] > Init: ...."

Test.zip

@cheton
Copy link
Collaborator

cheton commented Feb 2, 2017

I've reduced the init command as below within the limit of 254 characters, so it should not be a problem of serial buffer overrun:

{sr:{line:t,vel:t,feed:t,stat:t,cycs:t,mots:t,hold:t,momo:t,coor:t,plan:t,unit:t,dist:t,frmo:t,path:t,posx:t,posy:t,posz:t,posa:t,mpox:t,mpoy:t,mpoz:t,mpoa:t}}

The strange thing is that my g2core firmware build 100.19 reported error code 159 for the line 2:

> G2 X5 Y0 I0 J-5
{"r":{"n":2},"f":[1,159,17]}

I also noticed that we have one minor difference in the fbs string: "100.19-16-g80bf-dirty" vs. "100.19-12-gb6995"

May I tried using your built firmware? Either .elf or .bin is fine. Thus we can make a test on the same basis. Thank you!

@amx1
Copy link

amx1 commented Feb 2, 2017

@cheton
for shure, btw did checkout the Motate branch too?

Test_g2core.zip

@amx1
Copy link

amx1 commented Feb 2, 2017

@cheton

looking at {"r":{"n":2},"f":[1,159,17]}, the controller takes this command as line number 2 because of "n":2. Which sender routine are you using? The original one or mine, because the original one checks only the f statement which means no error, my version waits for the correct line number. The {"r":{"n":... This is sent when the command is processed.

@cheton
Copy link
Collaborator

cheton commented Feb 2, 2017

I just tested your firmware build and it ran without problems. I remembered that I checkout edge branch for g2core, but forgot to checkout the edge branch for the Motate submodule. Would it be the problem?

@amx1
Copy link

amx1 commented Feb 2, 2017

@cheton
I used the marked branches: dev-209b-random-pauses and dev-5-usb-interrupts these are the latest modifications of aldenhart and giseburt and will be merged to edge/master in a few days. check your versions (git branch -l marked with *)

am@PC-LAB:~/workspace/git/TinyG2/g2core$ git branch -l

  • dev-209b-random-pauses
    edge
    am@PC-LAB:/workspace/git/TinyG2/g2core$ cd ../Motate
    am@PC-LAB:
    /workspace/git/TinyG2/Motate$ git branch -l
  • dev-5-usb-interrupts
    master
    am@PC-LAB:~/workspace/git/TinyG2/Motate$

@cheton
Copy link
Collaborator

cheton commented Feb 3, 2017

I also noticed that yesterday, it's fixed in this commit:
c64edd0

@giseburt
Copy link

giseburt commented Feb 3, 2017 via email

@aldenhart
Copy link

aldenhart commented Feb 3, 2017

Actually, it's the other way around. pos_ is returned in in work coordinates - current units with all offsets applied, and mpo_ is returned in internal machine coordinates - absolute coordinates (G53 with no offsets) and mm units. (MPO means machine position).

The reason for this is that DROs usually need pos responses, and graphics displays usually need mpo responses.

https://github.com/synthetos/g2/wiki/Status-Reports

@amx1
Copy link

amx1 commented Feb 3, 2017

@cheton
I will check this at the weekend

@cheton
Copy link
Collaborator

cheton commented Feb 4, 2017

@amx1

For the GUI performance issue you mentioned earlier, I will remove the list view from the G-code widget in 1.9. Each time when receiving new state update from server, it will re-render the list view again, and therefore cause significant performance drop on auto scrolling.

image

You can check if you have a performance gain after removing G-code widget from your workspace.

@amx1
Copy link

amx1 commented Feb 4, 2017

@cheton

I checked the latest master branch, sorry to say, the G2 error is back again. I tried both parameters: complete line mode and simple line mode. see test and log files.

I think the complete linemode is not needed, because the USB connection is fast enough. The idea of CLM is to "burst" the first 4 lines to fill the planner buffer and then loop in simple linemode, but it has the risk that even the first 4 lines scramble the input buffer.

I will check the code. I think I saw the problem already.

I had a different issue with GUI performance. It is related to the update of the position of the tool in the 3D graph. It is not due to your 3D implementation. It is due the concept of the software of the controller for very fast moves. It is clear that the controller has to prioritize the different tasks. The control of the steppers has to have the absolute priority. Therefore status reports are delayed or postponed in the case of very fast jobs (series of very fast moves). The only feedback is the ACK of a received command, {r: You can see this effect even in the attached log files. You send a lot of commands without receiving a status update of pos, vel, feed, ... You will have no information to update the position of the tool in the 3D widget. The tool is "jumping" with very large steps. It doesn't influence the correct function of the controller. The cnc machine is running properly, but the display doesn't look nice.

My approach was to implement the simple linemode, with a throttling when the planner buffer is full. I stop the sender if qr =4 and restart the sender when e.g. qr=6. This will give some headroom to receive an update of pos, vel and also line. You can see the different behaviour in the log files. I attached also the log for my actual version for the same test case

Test_20170204.zip
. (test_amx1.log)

@cheton
Copy link
Collaborator

cheton commented Feb 4, 2017

Thank you for your detailed and clear explanation.

I'm not aware the effect of delayed status reports for a very fast job. The reason why I tried not to watch queue reports since it will be deprecated as mentioned earlier by @giseburt.

G2 and G3 arcs did work when I tested yesterday, but now it happened again after I made several code changes. I think the G2 error might be caused by refactoring the workflow state (877b674). I will take a closer look at your attached logs for further investigation.

@amx1
Copy link

amx1 commented Feb 4, 2017 via email

@amx1
Copy link

amx1 commented Feb 4, 2017

@cheton

the sending routine seems to work, but the control of the workflow: start, pause, stop, resume is still buggy, I implemented the renumbering of gc lines also, because I like the display of lines sent and compare it with lines processed. you will find errors of the gcode a bit faster

Test_2017.02.041.zip

@amx1
Copy link

amx1 commented Feb 4, 2017

@cheton

quick and dirty solution with line numbers and throttling for fast jobs
Test_20170204_V1.zip

@amx1
Copy link

amx1 commented Feb 5, 2017

@cheton

thank you for fixing the imperial coordinates for 3D view, it is ok now. There is still a difference in the axes widget. The machine position is ok, the work position is to small by the conversion factor

image

@cheton
Copy link
Collaborator

cheton commented Feb 5, 2017

I changed a bit to your work, most were some name changes and refining if-else statements, you can checkout the master branch and do tests again. BTW, the work position was corrected in this commit 2bac497.

@cheton cheton added this to the 1.9 milestone Feb 5, 2017
@amx1
Copy link

amx1 commented Feb 5, 2017

I did a quick check. It looks really good now. I didn't find any critical issues yet. Thank you very much! We should thank also @aldenhart and @giseburt for their quick responses.

@amx1
Copy link

amx1 commented Feb 6, 2017

@cheton

the "pulldown" options of the TinyG widget are really cool, what do think of implementing this also for the G-code widget to show the gcodes, because in some error cases it might be helpful to see the actual gcode line.

@cheton
Copy link
Collaborator

cheton commented Feb 6, 2017

How about adding a button that opens a new window to show the gcode?

@amx1
Copy link

amx1 commented Feb 6, 2017 via email

@amx1
Copy link

amx1 commented Feb 7, 2017

@cheton

I checked the actual master branch, with the following errors

/home/am/workspace/git/cnc-master/showdown.js
1:1 warning Unexpected var, use let or const instead no-var
2:1 warning Unexpected var, use let or const instead no-var
3:1 warning Unexpected var, use let or const instead no-var
4:1 warning Unexpected var, use let or const instead no-var
5:1 warning Unexpected var, use let or const instead no-var
81:70 error Trailing spaces not allowed no-trailing-spaces
88:28 error Calls to require() should use string literals import/no-dynamic-require

@cheton
Copy link
Collaborator

cheton commented Feb 8, 2017

I applied https://cnc.js.org yesterday and integrated showdown into the post build process to generate a html page under /docs. It's fixed in the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants