synthetos / TinyG

Affordable Industrial Grade Motion Control
https://github.com/synthetos/TinyG/wiki
897 stars 293 forks source link

M2 does not report changes in the offset #79

Closed krasin closed 10 years ago

krasin commented 10 years ago

M2 is supposed to stop the program, and, in particular, it calls G92.1. In practice, the output differs a bit.

Here is G92.1:

> {"sr":""}
{"r":{"sr":{"mpox":0.000,"mpoy":0.000,"mpoz":0.000,"mpoa":0.000,"ofsx":0.000,"ofsy":0.000,"ofsz":0.000,"ofsa":0.000,"unit":1,"stat":1,"coor":2,"momo":4,"dist":0,"home":0,"hold":0,"macs":1,"cycs":0,"mots":0,"plan":0,"prbe":0}},"f":[1,0,10,2205]}

> G0 X10
{"r":{},"f":[1,0,7,4400]}
{"sr":{"mpox":0.000,"stat":5,"momo":0,"macs":5,"cycs":1,"mots":1}}
{"qr":27}
{"sr":{"mpox":3.707}}
{"sr":{"mpox":9.502}}
{"sr":{"mpox":10.000,"stat":3,"macs":3,"cycs":0,"mots":0}}
{"qr":28}

> G92 X0
{"r":{},"f":[1,0,7,4400]}
{"sr":{"ofsx":10.000}}
{"qr":28}

> G0 X20
{"r":{},"f":[1,0,7,4400]}
{"sr":{"mpox":10.000,"stat":5,"macs":5,"cycs":1,"mots":1}}
{"qr":27}
{"sr":{"mpox":13.593}}
{"sr":{"mpox":19.689}}
{"sr":{"mpox":25.785}}
{"sr":{"mpox":29.994}}
{"sr":{"mpox":30.000,"stat":3,"macs":3,"cycs":0,"mots":0}}
{"qr":28}

> G92.1
{"r":{},"f":[1,0,6,4399]}
{"sr":{"ofsx":0.000}}
{"qr":28}

That's correct. G92.1 resets the offsets and ofsx:0.000 is correctly reported.

Now, let's try with M2:

> {"sr":""}
{"r":{"sr":{"mpox":0.000,"mpoy":0.000,"mpoz":0.000,"mpoa":0.000,"ofsx":0.000,"ofsy":0.000,"ofsz":0.000,"ofsa":0.000,"unit":1,"stat":1,"coor":2,"momo":4,"dist":0,"home":0,"hold":0,"macs":1,"cycs":0,"mots":0,"plan":0,"prbe":0}},"f":[1,0,10,2205]}

> G0 X10
{"r":{},"f":[1,0,7,4400]}
{"sr":{"mpox":0.000,"stat":5,"momo":0,"macs":5,"cycs":1,"mots":1}}
{"qr":27}
{"sr":{"mpox":3.830}}
{"sr":{"mpox":9.502}}
{"sr":{"mpox":10.000,"stat":3,"macs":3,"cycs":0,"mots":0}}
{"qr":28}

> G92 X0
{"r":{},"f":[1,0,7,4400]}
{"sr":{"ofsx":10.000}}
{"qr":28}

> G0 X10
{"r":{},"f":[1,0,7,4400]}
{"sr":{"mpox":10.000,"stat":5,"macs":5,"cycs":1,"mots":1}}
{"qr":27}
{"sr":{"mpox":13.707}}
{"sr":{"mpox":19.432}}
{"sr":{"mpox":20.000,"stat":3,"macs":3,"cycs":0,"mots":0}}
{"qr":28}

> M2
{"r":{},"f":[1,0,3,4396]}
{"sr":{"stat":4,"momo":4,"macs":4}}
{"qr":28}

As you can see, stat, momo and macs are reported, but ofsx is not. Let's query it with sr:

> {"sr":""}
{"r":{"sr":{"mpox":20.000,"mpoy":0.000,"mpoz":0.000,"mpoa":0.000,"ofsx":10.000,"ofsy":0.000,"ofsz":0.000,"ofsa":0.000,"unit":1,"stat":4,"coor":2,"momo":4,"dist":0,"home":0,"hold":0,"macs":4,"cycs":0,"mots":0,"plan":0,"prbe":0}},"f":[1,0,10,6405]}

Whoa! ofsx is still 10.000! Let's try M2 again:

> M2
{"r":{},"f":[1,0,3,4396]}
{"sr":{"ofsx":0.000}}
{"qr":28}

Voila! Now, ofsx:0.000 is reported.

krasin commented 10 years ago

A bit more details:

commit cb410e90acbbb0c96e3b79c116c84107b65be072
Author: alden.hart <alden08@harts.org>
Date:   Mon Apr 14 17:53:07 2014 -0400

    424.03 changed cm_queue_flush() to agree with OMC-style jogging
krasin commented 10 years ago

The fix is #80 With the fix applied, I see the following output:

> {"sr":""}
{"r":{"sr":{"mpox":0.000,"mpoy":0.000,"mpoz":0.000,"mpoa":0.000,"ofsx":0.000,"ofsy":0.000,"ofsz":0.000,"ofsa":0.000,"unit":1,"stat":1,"coor":2,"momo":4,"dist":0,"home":0,"hold":0,"macs":1,"cycs":0,"mots":0,"plan":0,"prbe":0}},"f":[1,0,10,2205]}

> G0 X10
{"r":{},"f":[1,0,7,4400]}
{"sr":{"mpox":0.000,"stat":5,"momo":0,"macs":5,"cycs":1,"mots":1}}
{"qr":27}
{"sr":{"mpox":3.830}}
{"sr":{"mpox":9.502}}
{"sr":{"mpox":10.000,"stat":3,"macs":3,"cycs":0,"mots":0}}
{"qr":28}

> G92 X0
{"r":{},"f":[1,0,7,4400]}
{"sr":{"ofsx":10.000}}
{"qr":28}

> G0 X10
{"r":{},"f":[1,0,7,4400]}
{"sr":{"mpox":10.000,"stat":5,"macs":5,"cycs":1,"mots":1}}
{"qr":27}
{"sr":{"mpox":13.707}}
{"sr":{"mpox":19.432}}
{"sr":{"mpox":20.000,"stat":3,"macs":3,"cycs":0,"mots":0}}
{"qr":28}

> M2
{"r":{},"f":[1,0,3,4396]}
{"sr":{"ofsx":0.000,"stat":4,"momo":4,"macs":4}}
{"qr":28}

As you can see, ofsx is correctly reported this time, just like with G92.1