Remotely trigger jobs using the API?

Make your own CNC Control Apps

Moderator: cnckeith

johannes
Posts: 91
Joined: Wed Jan 26, 2022 4:53 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: Yes
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Remotely trigger jobs using the API?

Post by johannes »

In the API, is there an equivalent to setting a part position with a numerical input?
Screenshot 2024-12-12 at 18.36.56.png
I have an ultrasonic sensor that will detect X distance to the part along the track. So for each job segment, I will have an updated distance measurement in X (e.g. + 1.72 mm), and I want to set this as the new part position.
Perhaps an oversight from me on using SetWorkPieceOrigin, since it only zeros the WCS, it doesn't seem to accept a part position value input?


Centroid_Jacob
Web Developer
Posts: 93
Joined: Wed Oct 19, 2022 4:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: No
CNC12: No
CNC11: Yes
CPU10 or CPU7: No

Re: Remotely trigger jobs using the API?

Post by Centroid_Jacob »

johannes wrote: Thu Dec 12, 2024 1:41 pm In the API, is there an equivalent to setting a part position with a numerical input?
Screenshot 2024-12-12 at 18.36.56.png

I have an ultrasonic sensor that will detect X distance to the part along the track. So for each job segment, I will have an updated distance measurement in X (e.g. + 1.72 mm), and I want to set this as the new part position.
Perhaps an oversight from me on using SetWorkPieceOrigin, since it only zeros the WCS, it doesn't seem to accept a part position value input?
Currently there is no method or function for setting a part position using the API, we will try to add this functionality for the next release.
However, you can use Job.RunCommand to call G92 and pass it your axis values. (Note: G92 sets the currently active WCS to the specified values)

Code: Select all

public bool SetAbsolutePosition(double? X = null, double? Y = null, double? Z = null)
{
    string cmdText = "G92";
    if(X.HasValue)
        cmdText += $" X{X.Value}";

    if (Y.HasValue)
        cmdText += $" Y{Y.Value}";

    if (Z.HasValue)
        cmdText += $" Z{Z.Value}";

    var cncJob = new Job (m_pipe);
    if (cncJob.RunCommand(cmdText, GetCNC12WorkingDirectory(), false) == ReturnCode.SUCCESS)
    {
        return true;
    }
    return false;
}
Called like so, to set X's absolute position to 1.72:

Code: Select all

SetAbsolutePosition(1.72,null,null);
Alternatively, you can use a similar approach and use RunCommand to set the system variables to the value if you need to change other WCS locations.
WCS Vars.png

Code: Select all

cncJob.RunCommand("#2501 = 1.72; WCS #1 X val set to 1.72", GetCNC12WorkingDirectory(), false)
Let me know if I misunderstood your request.
When requesting support please read this post first.

A fresh report makes it easier to assist you. To make a report check this post


johannes
Posts: 91
Joined: Wed Jan 26, 2022 4:53 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: Yes
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Remotely trigger jobs using the API?

Post by johannes »

Centroid_Jacob wrote: Thu Dec 12, 2024 2:41 pm
Alternatively, you can use a similar approach and use RunCommand to set the system variables to the value if you need to change other WCS locations.

WCS Vars.png

Code: Select all

cncJob.RunCommand("#2501 = 1.72; WCS #1 X val set to 1.72", GetCNC12WorkingDirectory(), false)
I went for this, it was clean and simple and worked fine. Thanks for sharing! This is exactly what I was looking for.


Post Reply