Hello Guest it is March 28, 2024, 11:03:19 AM

Author Topic: Configuring Keys In Key Board Inputs Configuration Table  (Read 3910 times)

0 Members and 1 Guest are viewing this topic.

Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #20 on: March 24, 2019, 12:45:32 PM »
I think the jog functions need an axis.  So when you get and set the jog rate you need to set it for each axis.   I ran into this problem about a month ago.   
Mc.jog (inst, Axis#, jog rate)
I can't double-check this right now, I'm not at home, but I think that is what it is looking for.  You will need 3 lines to set it for X, Y, and Z.
Chad Byrd
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #21 on: March 24, 2019, 12:54:09 PM »
Like this:?

-Set Jog Rate

function Feed2()
    local inst = mc.mcGetInstance()
    local Feed2 = mc.mcJogGetRate(inst)
   mc.mcJogSetRate(inst, 0, JogRate)  --Motor 0
   mc.mcJogSetRate(inst, 1, JogRate)  --Motor 1
   mc.mcJogSetRate(inst, 2, JogRate)  --Motor 2
   mc.mcJogSetRate(inst, 3, JogRate)  --Motor 3
    if Feed2 == 100 then
       mc.mcCntlSetLastError(inst, "Can't increase JogRate anymore.")
    else
       local Feed2 = (Feed2 + 10)
       mc.mcJogSetRate(inst, Feed2)
    end
end
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #22 on: March 24, 2019, 12:55:20 PM »
Ok, tried it, don't work.  rats and more rats
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #23 on: March 24, 2019, 01:23:55 PM »
I tried this, no work either   :-[

--Set Jog Rate

function Feed2()
    local inst = mc.mcGetInstance()
    local Feed2 = mc.mcJogGetRate(inst)
    if Feed2 == 100 then
       mc.mcCntlSetLastError(inst, "Can't increase JogRate anymore.")
    else
       local Feed2 = (Feed2 + 10)
      mc.mcJogSetRate(inst, mc.X_AXIS, SetRate) -- set set for axis
      mc.mcJogSetRate(inst, mc.Y_AXIS, SetRate) -- set set for axis
      mc.mcJogSetRate(inst, mc.Z_AXIS, SetRate) -- set set for axisMotor 3   
    end
   
end   
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #24 on: March 24, 2019, 03:12:11 PM »
Once I get home to my laptop I will proof some code out and post it.   
Chad Byrd
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #25 on: March 24, 2019, 05:01:22 PM »
Ok, Great, can't wait to see what you come up with.  Thank you.
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #26 on: March 24, 2019, 06:30:13 PM »
Here is what I came up with; I made two buttons and put the code in the Clicked Script inside the button, you can make it a function if you like, but these work to increase and decrease the jog rate by 10%.  You can change that to whatever you like, or add another button to change the resolution of change.


--Jog Rate +10%
local inst = mc.mcGetInstance()
local CurrentRate = mc.mcJogGetRate(inst, 1)
local JogRate = (CurrentRate + 10)
if JogRate <= 100 then
    mc.mcJogSetRate(inst, 0, JogRate)
    mc.mcJogSetRate(inst, 1, JogRate)
    mc.mcJogSetRate(inst, 2, JogRate)
else if JogRate > 100 then
    mc.mcCntlSetLastError(inst, "Can't set Jog Rate higher")
end
end

--Jog Rate -10%
local inst = mc.mcGetInstance()
local CurrentRate = mc.mcJogGetRate(inst, 1)
local JogRate = (CurrentRate - 10)
if JogRate >= 10 then
    mc.mcJogSetRate(inst, 0, JogRate)
    mc.mcJogSetRate(inst, 1, JogRate)
    mc.mcJogSetRate(inst, 2, JogRate)
else if JogRate < 10 then
    mc.mcCntlSetLastError(inst, "Can't set Jog Rate Lower")
end
end

Also,
There is a little glitch; this occurred to someone else, I just remembered that they mentioned it happens so be aware of it.
It won't display correctly when you lower it below 50% unless you first change it to 0% and then you can freely raise and lower it from 0-100%.
I don't know why, that's the way it is.  So, when you start, just manually change the jog rate to 0% and you'll be good to go.

Also, looking at your code, maybe change the Axis to an integer instead of writing out the axis, your code may work just fine.
« Last Edit: March 24, 2019, 06:31:50 PM by Cbyrdtopper »
Chad Byrd
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #27 on: March 24, 2019, 06:59:46 PM »
Well thank you, i'm going to do some plug and play to see how it works.   Let you know soon.......and thank you again for all your time on this. 
Fritz
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #28 on: March 25, 2019, 02:55:56 PM »
Hi,  Well, I didn't get your scripts to work, but I did figure it out using your parts, thanks to you!!   I got this working well in windows 7pro and 10pro.  The only thing is can't use the mouse on the slider or it will disrupt the DRO for some reason, but I don't use a mouse anyhow on any CNC machinery, I have touch screens.   Here is what I'm using and so grateful because of you.

Offline smav

*
  •  55 55
    • View Profile
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #29 on: January 06, 2020, 11:10:16 PM »
Chad--I had the same issue with DRO not wanting to accurately record the jog rate when I used my pendant. I found that what it was doing was it would count down to what ever the initial value was set at when I started up mach4 and then count no lower. What I did to curb that issue was to set it to default to the value of 1 at start up so after I start march4 up I can use the mouse with slider,my pendant or keyboard interchangeably with no issues, the DRO value always tracks on as it should.