Inquiry on Real-Time Control Capabilities (CNC12 + API)

Make your own CNC Control Apps

Moderator: cnckeith

Post Reply
eastonhy
Posts: 2
Joined: Sun Feb 09, 2025 11:37 am
Acorn CNC Controller: No
Plasma CNC Controller: No
AcornSix CNC Controller: No
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

Inquiry on Real-Time Control Capabilities (CNC12 + API)

Post by eastonhy »

We are considering using the Centroid controller (e.g., Acorn or Acorn Six) for our benchtop CNC with a focus on real-time DIY control of machining parameters. We’d like to confirm if the Centroid controller, together with CNC12 software and available APIs, can support the following requirements:

1. Live G-code Monitoring:
1) Can we access the currently executing G-code line in real time (not the entire script)?
2) Are functions like GetCurrentLineInfo and GetActiveGCodes updated live?

2. Real-Time Command Injection
1) Can we programmatically insert and execute a single G-code line during execution?
2) Does RunCommand support real-time script execution?
3) How does the RunCommand function behave—does it interrupt or append to the current job?

3. Command Interruption
1) Can we pause or cancel a running G-code program via API (CancelExecution, ContinueExecution)?
2) What is the typical latency for such actions?

4. Real-Time Parameter Tuning and Feedback
1) Can we modify spindle speed, feed rate, etc., during EXECUTION using the API (SetMachineParameter)?
2) Can we retrieve current machine position, spindle speed, tool status, etc. via API?

5. G-code Sync with I/O
1) Can I/O operations be synchronized with specific G-code lines?

We would greatly appreciate any clarification, confirmations, or documentation references for these topics. Thank you!


ASPeters
Posts: 43
Joined: Thu Feb 10, 2022 5:55 pm
Acorn CNC Controller: No
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Inquiry on Real-Time Control Capabilities (CNC12 + API)

Post by ASPeters »

1.1 Can we access the currently executing G-code line in real time (not the entire script)?
State.GetCurrentLineInfo and State.GetCurrentStackLevelZeroLineInfo will give the current executing line number.
GetCurrentLineInfo can give the executing line of a sub program or macro.
This line number can be cross referenced with your job file to retrieve the current g-code line.

1.2 Are functions like GetCurrentLineInfo and GetActiveGCodes updated live?
There is not currently an outgoing pipe in the API so continuous calls have to be made to get the most up to date information. No stale information is returned with these calls.

2.1 Can we programmatically insert and execute a single G-code line during execution?
No, currently G-code can only inserted/run while on the main screen of CNC12

2.2 Does RunCommand support real-time script execution?
If you're looking to execute a full job file, it is better to use Job.Load and then a cycle start (either programmatically or by the user).
RunCommand can run a file immediately if you do Job.RunCommand("G65 \"your\\file\\path\"", "C:\\cncm", false);

2.3 How does the RunCommand function behave—does it interrupt or append to the current job?
Job.RunCommand only works while on the main screen of CNC12. It is generally used to run a single line of G-code

3.1 Can we pause or cancel a running G-code program via API (CancelExecution, ContinueExecution)?
You can programmatically issue a "Feed Hold" via a skin event to achieve a pause of a program. Job.CancelExecution will cancel a running G-code program. Job.ContinueExecution will continue a job from a M0/M200/M201 M-code provided that parameter 440 is set correctly

3.2 What is the typical latency for such actions?
We have not timed these calls specifically. In the current release (v5.30), the average call takes about 35 milliseconds. In the next release, the average call time will be reduced to 4 milliseconds after a substantial rewrite of the architecture.

4.1 Can we modify spindle speed, feed rate, etc., during EXECUTION using the API (SetMachineParameter)?
It would be possible to modify some values on the fly via skin events. SetMachineParameter and other configuration type calls will not work during execution.

4.2 Can we retrieve current machine position, spindle speed, tool status, etc. via API?
Yes, through various calls.

5.1 Can I/O operations be synchronized with specific G-code lines?
Your application would be able to trigger I/O while running a job. It would be up to you to trigger your operation at the correct point in a given job.


Post Reply