Hello Guest it is January 26, 2020, 09:58:11 PM

Author Topic: Integers defined  (Read 1890 times)

0 Members and 1 Guest are viewing this topic.

Offline Bob49

*
  •  57 57
    • View Profile
Re: Integers defined
« Reply #10 on: June 07, 2017, 04:07:01 PM »
After pondering this all night, I decided the mcJogSetType function was maybe the wrong approach to the end game for my needs.  So I stripped the statements relative to that function and installed statements to do it through the ButtonJogModeToggle and the related osigs.  And in short order I got the Jog Type Toggle Button performing from my console switch.  Not that tough after I drilled through all the advise given.

But; you knew there would be a but, that now has messed up my toggling between the increment values that I had working perfectly before.  Part of what I expected from the Jog Type button proved to be true, in that the jog type would be persistent.  It would be one until changed to the other.  I was banking on that being the case.  So in my one switch that handles jog type and jog increment, coming off the jog type inc, that jog type stays.  But as I then progress through the incremental values, the only value that effects the jog amount is .001" if I use the on screen axis jog buttons.  Now that I say that, I can't say that was 100% the case as I never tried the on screen axis buttons before.

But I plan on adding a Shuttle Pro for those buttons and I tested the jog functions via the keyboard and they work as they should, so it's just the on screen buttons that have an issue.  But I don't plan on using them anyway.  I guess it would be nice if they did just because, but I'm not going to worry too much about that caveat.

So, I got things worked out, many thanks for the words of wisdom here.  Now on to order me a Shuttle Pro.

Regards
Bob

Offline DazTheGas

*
  •  752 752
  • DazTheGas
    • View Profile
Re: Integers defined
« Reply #11 on: June 07, 2017, 05:03:26 PM »
The reason I mentioned the function from the screen load script was that you can use the same principle within the SigLib, take a look at the following code that can be inserted into the SigLib using the inputs you have assigned to your 2 buttons.

Code: [Select]
local cont_in = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_CONT);
local inc_in = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_INC);

SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    ButtonEnable()
end,

[mc.ISIG_INPUT0] = function (state)
    if (state == 1) then  
mc.mcSignalSetState(cont_in, 0)
        mc.mcSignalSetState(inc_in, 1)
end
end,

[mc.ISIG_INPUT1] = function (state)
if (state == 1) then  
mc.mcSignalSetState(cont_in, 1)
mc.mcSignalSetState(inc_in, 0)
end
end,

DazTheGas
 
« Last Edit: June 07, 2017, 05:05:11 PM by DazTheGas »
Theres always time for a choccy biccy

Offline Bob49

*
  •  57 57
    • View Profile
Re: Integers defined
« Reply #12 on: June 07, 2017, 05:53:39 PM »
Hi Daz,

That's similar to what I ended up with, but started out with a bit of a mess.  The mess was yesterday and last night, it got cleaned up and working this morning.  I'm not using buttons, I have a 7 position rotary binary switch that has positions for jog types and jog increments.  So the pin combination was throwing my thinking off.  Until I ditched the function I started with, then things got clear.

Here's the jog portion of the screen script as it is now, and I think I'm mostly done tinkering with it as all my console functions work that I care about.  Though some might get changed around down the road.

Regards
Bob

Code: [Select]
end
}
---------------------------------------------------------------
function JOG()
---------------------------------------------------------------
    --Set Jogtype and jog increment from console switch
    local Input14 = 0                                                          --Clear local Input14
    local Input15 = 0                                                          --Clear local Input15
    local Input17 = 0                                                          --Clear local Input17
    local hSig = 0                                                             --Clear local hSig
    local cont = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_CONT)
    local inc = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_INC)
    local mpg = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_MPG)

    inst = mc.mcGetInstance()
    hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT14)
    Input14 = mc.mcSignalGetState(hSig)  --Get State of Input 14

    inst = mc.mcGetInstance()
    hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT15)
    Input15 = mc.mcSignalGetState(hSig)  --Get State of Input 15

    inst = mc.mcGetInstance()
    hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT17)
    Input17 = mc.mcSignalGetState(hSig)  --Get State of Input 17
   
    if ((Input14 == 1) and (Input15 == 1) and (Input17 == 1)) then
        local inst = mc.mcGetInstance(); --Jog Continous
        mc.mcSignalSetState(cont, 1)
        mc.mcSignalSetState(inc, 0)
        mc.mcSignalSetState(mpg, 0)
    elseif ((Input14 == 0) and (Input15 == 1) and (Input17 == 1)) then
        local inst = mc.mcGetInstance(); --Jog Incremental
        mc.mcSignalSetState(cont, 0)
        mc.mcSignalSetState(inc, 1)
        mc.mcSignalSetState(mpg, 0)
    elseif ((Input14 == 1) and (Input15 == 1) and (Input17 == 0)) then
        local inst = mc.mcGetInstance()
        mc.mcJogSetInc(inst, mc.X_AXIS, 0.0001)
        mc.mcJogSetInc(inst, mc.Y_AXIS, 0.0001)
        mc.mcJogSetInc(inst, mc.Z_AXIS, 0.0001)
        mc.mcJogSetInc(inst, mc.A_AXIS, 0.0001)
    elseif ((Input14 == 0) and (Input15 == 1) and (Input17 == 0)) then
        local inst = mc.mcGetInstance()
        mc.mcJogSetInc(inst, mc.X_AXIS, 0.001)
        mc.mcJogSetInc(inst, mc.Y_AXIS, 0.001)
        mc.mcJogSetInc(inst, mc.Z_AXIS, 0.001)
        mc.mcJogSetInc(inst, mc.A_AXIS, 0.001)
    elseif ((Input14 == 1) and (Input15 == 0) and (Input17 == 1)) then
        local inst = mc.mcGetInstance()
        mc.mcJogSetInc(inst, mc.X_AXIS, 0.01)
        mc.mcJogSetInc(inst, mc.Y_AXIS, 0.01)
        mc.mcJogSetInc(inst, mc.Z_AXIS, 0.01)
        mc.mcJogSetInc(inst, mc.A_AXIS, 0.01)
    elseif ((Input14 == 0) and (Input15 == 0) and (Input17 == 1)) then
        local inst = mc.mcGetInstance()
        mc.mcJogSetInc(inst, mc.X_AXIS, 0.1)
        mc.mcJogSetInc(inst, mc.Y_AXIS, 0.1)
        mc.mcJogSetInc(inst, mc.Z_AXIS, 0.1)
        mc.mcJogSetInc(inst, mc.A_AXIS, 0.1)
    elseif ((Input14 == 1) and (Input15 == 0) and (Input17 == 0)) then
        local inst = mc.mcGetInstance()
        mc.mcJogSetInc(inst, mc.X_AXIS, 1.000)
        mc.mcJogSetInc(inst, mc.Y_AXIS, 1.000)
        mc.mcJogSetInc(inst, mc.Z_AXIS, 1.000)
        mc.mcJogSetInc(inst, mc.A_AXIS, 1.000)
    end
end