Hello Guest it is March 28, 2024, 07:16:22 PM

Author Topic: LUA Problem with Jog Mode  (Read 1094 times)

0 Members and 1 Guest are viewing this topic.

LUA Problem with Jog Mode
« on: November 24, 2020, 02:55:47 PM »
Hello,

sorry for my english.

i have with arduino over USB and the serialDRO.lua a MPG. All function is ok. BUT i can't switch JOG Modus. INC Modus all ok.

   local JogVel = mc.MC_JOG_TYPE_VEL;
   mc.mcJogSetType(inst, 0, JogVel)
      mc.mcCntlSetLastError(inst, "Jog Cont")

Please can you me help for this Problem???
Code: [Select]
    elseif Command == "1" then
mc.mcJogSetInc(inst, 0, .001)
mc.mcJogSetInc(inst, 1, .001)
mc.mcJogSetInc(inst, 2, .001)
p:write("I 1\n", 5)
mc.mcCntlSetLastError(inst, "Jog Increment 0.001")
    elseif Command == "2" then
mc.mcJogSetInc(inst, 0, .010)
mc.mcJogSetInc(inst, 1, .010)
mc.mcJogSetInc(inst, 2, .010)
p:write("I 2\n", 5)
mc.mcCntlSetLastError(inst, "Jog Increment 0.010")
    elseif Command == "3" then
mc.mcJogSetInc(inst, 0, .100)
mc.mcJogSetInc(inst, 1, .100)
mc.mcJogSetInc(inst, 2, .100)
p:write("I 3\n", 5)
mc.mcCntlSetLastError(inst, "Jog Increment 0.100")
    elseif Command == "4" then
local JogVel = mc.MC_JOG_TYPE_VEL;
mc.mcJogSetType(inst, 0, JogVel)
mc.mcCntlSetLastError(inst, "Jog Cont")

Offline Bill_O

*
  •  563 563
    • View Profile
Re: LUA Problem with Jog Mode
« Reply #1 on: November 25, 2020, 02:05:22 PM »
I am not sure there is a mc.MC_JOG_TYPE_VEL.
I think you want to use mc.JogGetVelocity(inst, axisID)
Re: LUA Problem with Jog Mode
« Reply #2 on: November 25, 2020, 02:25:43 PM »
Hello,

i have change to mc.JogGetVelocity(inst, 0), but it comes a failue

the value is "NIL".
Re: LUA Problem with Jog Mode
« Reply #3 on: November 26, 2020, 02:49:54 PM »
I have tested with
mc.mcJogSetType(inst, 0, 1) and in mach4 comes no failure but the inc Modus remains. the steps remains example 0,1mm.
It switched not to Jog Modus.

I need the mc.mcJogIncStart and mc.mcJogIncStop?
I think this is only time steps.

Offline Bill_O

*
  •  563 563
    • View Profile
Re: LUA Problem with Jog Mode
« Reply #4 on: November 30, 2020, 10:04:24 AM »
I dont know.
I do not use it.
Hopefully someone who knows this better can help you out.

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: LUA Problem with Jog Mode
« Reply #5 on: November 30, 2020, 02:13:54 PM »
mcJogSetType() works with mcJogGetType() so that scripts can use the API to coordinate jogging.  This is helpful for building control panels and such where a hardware jog button is connected to a physical input and a hardware switch is connected to multiple inputs.  Assume the following code is put in the screen load script:
Code: [Select]
function JogStart(mInst, axis, dir)
    local type = 0
    type, rc = mc.mcJogGetType(mInst, axis)
    if (rc == mc.MERROR_NOERROR) then
        if (type == mc.MC_JOG_TYPE_VEL) then -- velocity
            mc.mcJogVelocityStart(mInst, axis, dir)
        else                -- incremental
            local inc = 0
            inc, rc = mc.mcJogGetInc(mInst, axis)
            if (rc == mc.MERROR_NOERROR) then
                inc = inc * dir
                mc.mcJogIncStart(mInst, axis, inc)
            end
        end
    end
end

function JogStop(mInst, axis)
    local type = 0
    type, rc = mc.mcJogGetType(mInst, axis)
    if (rc == mc.MERROR_NOERROR) then
        if (type == mc.MC_JOG_TYPE_VEL) then -- velocity
            mc.mcJogVelocityStop(mInst, axis)
        end
    end
end

A call to mcJogSetType() will change the way the above functions work.  Also, a call to mcJogSetIncr() will change the increment used if the jog is an incremental jog. 

mcJogSetType() will also modify the following Mach registers, depending on the axis parameter:
core/inst/JogTypeX
core/inst/JogTypeY
core/inst/JogTypeZ
core/inst/JogTypeA
core/inst/JogTypeB
core/inst/JogTypeC

mcJogSetIncr() will also modify the following Mach registers, depending on the axis parameter:
core/inst/JogIncX
core/inst/JogIncY
core/inst/JogIncZ
core/inst/JogIncA
core/inst/JogIncB
core/inst/JogIncC

What these functions do not do is modify the jog types or increments that are used by the screen.  The screen maintains its' own jogging parameters.  These APIs were developed primarily for the PMC functionality or plugin development.  But they can be used by scripts in the manner shown above. 

Steve