Page 1 of 1

Jog from API?

Posted: Sat Feb 01, 2025 8:23 pm
by brettbond
I've found most things in the API OK, but the one thing I can't seem to locate is a jog function similar to what happens when you press the UI buttons to jog the machine. Ideally here's what I'd like to do:

* Jog continuous, adjust the jog rate and change the axis as I go.
* Jog incremental: step from the current position along an axis in either + or - direction by a set amount (eg +X0.1 -Y0.)

So far I've tried a variety of RunCommand calls with G1 heading toward a direction at a feed rate that I can cancel with CancelCommand. This doesn't really serve my purpose of adjusting the jog rate along the way.

Why am I doing this? I'm porting www.papertools.ai to work with CNC12.

Thanks for your help!

Re: Jog from API?

Posted: Sun Feb 02, 2025 4:55 pm
by cncsnw
Jogging actions are controlled by the PLC program.

Your API application can send signals to the PLC program ("skin events"), which the PLC program can then act upon.

If you review a standard factory PLC program, you will find the sections where it selects incremental or continuous and fast or slow, and where it activates jogging, in response to jog panel, keyboard and VCP requests.

If you are not also using the VCP, then you could just appropriate the VCP "skin" inputs for your jogging controls.

If you want to use the VCP in addition to your application, then you would probably want to define your own new skin event numbers, and add them to the existing PLC logic (generally, OR them together with the pre-existing inputs).

Re: Jog from API?

Posted: Tue Feb 04, 2025 11:40 am
by brettbond
@cncsw thanks for the tip, I managed to get jogging working by setting skin event state using:
cnc_pipe.plc.SetSkinEventState

To change from continuous to incremental jogging I check the LED state and look for bit 25, then based on that I "push" the button with skin event 26. I save the state and restore when I'm finished. You said I could create new event state numbers but then I'd need to modify the PLC code.

* Would this create a challenge distributing my own software because people may have custom PLC changes? I'd prefer not to overwrite or somehow merge with custom user PLCs and I very much want to avoid any kind of user intervention like modifying code or compiling.

* Is there any real problem with the approach to use the existing event numbers? Do they differ between VCPs for example on a plasma, lathe etc? Or are there Centroid reserved event numbers I can rely on for things like the jog buttons?

* Is there a better way to interact directly with the PLC such as by modifying specific memory bits or System Variable values?

Re: Jog from API?

Posted: Tue Feb 04, 2025 11:08 pm
by cncsnw
The skin event numbers for axis jogging controls are generally the same across all control versions. That part of the PLC program is rarely modified.

There may be some confusion over X axis jog buttons for a lathe with the tools in front (where the downward-pointing button jogs X+, and the upward-pointing button jogs X-), but otherwise your code should be portable among different controls.

If you want to offer an application for use by different people with different controls, it would be best to avoid requiring any custom PLC code. Using the VCP skin events is probably the best way to accomplish that.

You should experiment with running your application and the VCP simultaneously, to see if there are any interference issues. Chances are good that if you only initiate jogging from one or the other at a time, it will work just fine. Mostly you want to make sure there are no loopholes where, if you mix simultaneous inputs from the two sources, you get into a mode where a jogging move starts but does not stop.