[solved] X,Y,R support for arcs

Discussions around the CAM Add-On of QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Indicate the post processor used.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
lagnat
Junior Member
Posts: 24
Joined: Mon Dec 07, 2020 4:58 pm

[solved] X,Y,R support for arcs

Post by lagnat » Wed Jan 06, 2021 4:03 am

Short story: I've changed my post processor to generate XYR instead of XYIJ and that works fine most of the time. When the arcs are greater than 180 degrees, the convention is to specify a negative radius.

See "R Method Example 2"
http://www.manufacturinget.org/2011/12/ ... 2-and-g03/

Is there any way to make that work, perhaps with a different variable or a modifier on RADIUS?

Code: Select all

     
     this.firstArcCWMove = "[N] G2 [X] [Y] R[RADIUS] [F]";
     this.arcCWMove = "[N] G2 [X] [Y] R[RADIUS] [F]";

     this.firstArcCCWMove = "[N] G3 [X] [Y] R[RADIUS] [F]";
     this.arcCCWMove = "[N] G3 [X] [Y] R[RADIUS] [F]";
And because I know someone will ask, I'll explain why I did this. I'm using a TinyG and on occasion it's not happy with the arcs generated by QCad and throws a specification error. I *think* that is because of numerical precision and the TinyG isn't able to compute a solution. I've tried this.decimals = 3; and that didn't help. I might have tried 2 as well but I can't remember. Using XYR, the TinyG computes I and J at whatever precision it can and everything is happy.

And just in case anyone else out there has a TinyG with the same problem, the TinyG support for negative radii had a bug that I had to fix first.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: X,Y,R support for arcs

Post by CVH » Wed Jan 06, 2021 5:07 am

hi,

Building on this ...
https://qcad.org/rsforum/viewtopic.php?t=7429

Assuming your postprocessor is called 'MyPostProcessor'.
And in a way based on GCodeBase.
Remember that the R method can't handle full circles.

Code: Select all

MyPostProcessor.prototype.writeEntity = function() {
    // Converting RADIUS to -RADIUS:
    if (isArcEntity(this.currentEntity)) {
        if (this.arcSweep > Math.PI) {
            this.arcRadius = -this.arcRadius;
        }

    GCodeBase.prototype.writeEntity.call(this);
};
But I wouldn't really know at all if that is functional. :oops:
Not in coding and not in trajectory ... :?:
It is clear from your link that those arcs don't follow the same path :!:

Give it a try but make sure your are cutting air. :wink:

Regards,
CVH

lagnat
Junior Member
Posts: 24
Joined: Mon Dec 07, 2020 4:58 pm

Re: X,Y,R support for arcs

Post by lagnat » Wed Jan 06, 2021 5:46 am

That wasn't quite right but that link gave me what I needed..

Code: Select all

    this.nRadius = undefined;
    this.registerVariable("nRadius", "NRADIUS", true, "R", "DEFAULT", "DEFAULT");

    this.firstArcCWMove = "[N] G2 [X] [Y] [NRADIUS] [F]";
    this.arcCWMove = "[N] G2 [X] [Y] [NRADIUS] [F]";

    this.firstArcCCWMove = "[N] G3 [X] [Y] [NRADIUS] [F]";
    this.arcCCWMove = "[N] G3 [X] [Y] [NRADIUS] [F]";

Code: Select all

MyGCode.prototype.writeEntity = function() {
    if (isArcEntity(this.currentEntity)) {
        var r = this.currentEntity.getRadius();
        this.nRadius = this.currentEntity.getSweep() > Math.PI ? -r : r
    }

    CamExporterV2.prototype.writeEntity.call(this);
};

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: X,Y,R support for arcs

Post by CVH » Wed Jan 06, 2021 7:06 am

Glad you solved it. :wink:

A [NRADIUS] would avoid [RADIUS] to be overwritten.
All depends on the order of things.

Can you confirm that:
- this.arcSweep
- this.arcRadius
aren't known at prototype post level ...?
Rather weird, as the new this.nRadius is.

You are missing a ';' after '-r : r'
Not that it matters on a multi-line. :wink:

Regards,
CVH

lagnat
Junior Member
Posts: 24
Joined: Mon Dec 07, 2020 4:58 pm

Re: [solved] X,Y,R support for arcs

Post by lagnat » Wed Jan 06, 2021 4:59 pm

Can you confirm that:
- this.arcSweep
- this.arcRadius
aren't known at prototype post level ...?
Not sure I know what you mean by post level, but I'll try to answer anyway. this.arcSweep, etc.. are set in writeEntity itself so they are not available in the override. That fact also makes it impossible to alter RADIUS because (afaik) it's not possible to this.currentEntity.setRadius(-radius);

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: [solved] X,Y,R support for arcs

Post by CVH » Wed Jan 06, 2021 5:20 pm

This 'post' aka this 'postprocessor'.

Ok, got it, it's again the order of things. :wink:
The same as you can't alter [RADIUS] upfront.

That gives me the complete insight I needed. :idea:

this.currentEntity.setRadius(-radius);
No, indeed, this.currentEntity would be an RArcEntity and setting a negative radius for an Arc is a flaw ...
Or it could be considered as the inversion trough the centerpoint, but it is not.

Thanks,
Regards,
CVH

Post Reply

Return to “QCAD/CAM”