Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: arhimedoffs on March 10, 2018, 03:22:15 AM

Title: Jog steps
Post by: arhimedoffs on March 10, 2018, 03:22:15 AM
I use script for motor remapping (CNC has two carriage on X axis)


function cnc2plc:selectX1()
   -- Disable X axis, unmap Motor2, map Motor1, reenable X axis
   local rc = mc.mcCntlConfigStart(inst)
   if rc ~= 0 then
      mc.mcCntlSetLastError(inst, "Failed to switch axis!")
      return
   end
   rc = mc.mcAxisUnmapMotors(inst, mc.X_AXIS)
   rc = mc.mcAxisMapMotor(inst, mc.X_AXIS, mc.MOTOR1)
   mc.mcProfileSave(inst)
   mc.mcCntlConfigStop(inst)
   mc.mcCntlSetLastError(inst, "Selected axis X1")
end


All work in metric units, but after motor switched JOG start working in imperial. All DRO still in mm, and G21 is still active. I reexecute G21 from MDI, and JOG start working normally :)

Mach4 Hobby 4.2.0.3481, same issue with ESS motion controller and simulator.
Title: Re: Jog steps
Post by: Fledermaus on March 10, 2018, 06:31:34 AM
I think this issue results from the configuration. You could try a later version to see if it has been fixed. or you might try issuing the following after configuration and prior to jogging:

    local defUnits = mc.mcCntlGetUnitsDefault(inst)
    rc = mc.mcJogSetUnitsMode(inst, axis, defUnits)


Allan
Title: Re: Jog steps
Post by: arhimedoffs on March 10, 2018, 09:02:29 AM
Yes, this works. All fine if I do this for all my axises.

One more question: where find full documentation on API? There is not documentation about mcJogSetUnitsMode in Docs, but it is in all *.exe and plugins headers.
Title: Re: Jog steps
Post by: arhimedoffs on March 10, 2018, 09:20:25 AM
As I found, my code change SetDefaultUnitsOnStart from 1 to 0. What can cause this change?
Title: Re: Jog steps
Post by: Fledermaus on March 10, 2018, 09:39:44 AM
Look at:

  C:\Mach4Hobby\Docs\Mach4CoreAPI.chm

You may need to install a viewer such as xchm to read this file.

I'm not sure why DefUnits would change, but you could assume 21 to force metric for jogging:

  rc = mc.mcJogSetUnitsMode(inst, axis, 21)

Allan
Title: Re: Jog steps
Post by: arhimedoffs on March 10, 2018, 09:43:09 AM
There is nothing about mcJogSetUnitsMode. And some other functions not described, but exists in Lua interface.
Title: Re: Jog steps
Post by: Fledermaus on March 10, 2018, 11:33:40 AM
Sadly the documentation tends to lag behind development - a consequence of the low price of Mach4.

Sorry I cannot remember where I found the above API call. I assume it must have been in a forum post or in the change notes, but I've just done a quick search and nothing showed up.

Allan
Title: Re: Jog steps
Post by: arhimedoffs on March 10, 2018, 11:44:26 AM
Great thanks for trick! It work and I will use it. (One more variant - call G21 via MDI execute from same script, but it slower).
Title: Re: Jog steps
Post by: Fledermaus on March 10, 2018, 12:31:30 PM
Glad it worked for you.

I assume (why I'm not sure) that issuing G21 sets the current units mode to metric. If you're inclined, you could test this using mcCntlGetUnitsCurrent().

Allan

Title: Re: Jog steps
Post by: Fledermaus on March 11, 2018, 10:21:10 AM
I had another look and found mention of mcJogSetUnitsMode() in the change log on the ftp site, so I guess that is where I found it.

There was no detail as to its use so I would just test it and fix any errors as they occurred.

Allan
Title: Re: Jog steps
Post by: arhimedoffs on March 11, 2018, 11:37:46 AM
Thanks, good resource for some reading.
Title: Re: Jog steps
Post by: arhimedoffs on March 11, 2018, 11:43:21 AM
And about builds. Latest build from site 3481, but on ftp much more fresh. What about stability and practical usage of newer builds, any experience?
Title: Re: Jog steps
Post by: Fledermaus on March 11, 2018, 12:51:15 PM
I've often used the latest development builds without any problems at all, but obviously do this at your own risk and be ready with the eStop just in case.

Allan