Hello Guest it is March 29, 2024, 06:44:25 AM

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

0 Members and 1 Guest are viewing this topic.

Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #10 on: January 31, 2019, 04:43:39 PM »
Using this macro, I can change the jog to whatever I want, notice I am changing the Jog% for each motor.  It won't update the display if you try and change it below 50%.  Not sure why, this is a question for someone who knows more than me.

--Set Jog Rate
function m324()
local inst = mc.mcGetInstance()
local JogRate = 72.3   --Jog %
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

end --m324

if (mc.mcInEditor() == 1) then
 m324()
end
Chad Byrd

Offline smav

*
  •  55 55
    • View Profile
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #11 on: January 31, 2019, 05:10:44 PM »
Thanks Chad, what i was reading last night kind of makes sense now. I was browsing the the manual for the various mach lua jog commands and from what I was reading, it appeared to me that when you wanted to change the jog rate it was axis dependent and not like a global command that would just apply to all four axis universally. So, I was looking for how they implemented the slider and dro function so that it controlled all four the same way but wasn't really finding anything. I will try this later today and let you know how it works. I am attempting to get the hand held controller that was configured for Mach 3 originally to work with mach 4 and being able to set the jog rate without having to walk back to the computer each time will make it much more user friendly.

Offline smav

*
  •  55 55
    • View Profile
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #12 on: January 31, 2019, 10:38:34 PM »
Chad--I was able figure out from your macro the script needed for the sig library and added an if statement to stop the jog rate increment at 1 and 100 when they were reached and used inputs 1 and 2 to trigger the jog + or - command from the screen load file. I also noticed what you saw with the DRO only decreasing say to 50 or whatever and found that it was actually only counting down to the point where the dro originally started from. So if the slider and DRO were showing say 65% then when you decreased the jog rate with the keyboard key and got to 65 the dro would stop counting until I came back up to it and started going above 65, the jog rate did actually continue to degrees as I tested it on the mill to see if was actually still decreasing even tho dro was not registering it. I found if I slid the slider to 1 then it would count the full range of 1 to 100 when I used the keyboard or my pendant buttons.

I figured the easiest fix would be to just have the jog rate reset to 1 in either the load or unload screen but although I was successful in getting the actual Jog Rate to reset to 1 using either method I was not able to get the DRO and slider to reset to 1 through either one. I  believe the dro is simply stored in a registry but I am not savvy enough to know where it is or how to manipulate it at this point. I appreciate all the advice and help. 

Offline smav

*
  •  55 55
    • View Profile
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #13 on: February 02, 2019, 12:10:30 AM »
Last Update--I figured out a script for the PLC so that it will run once at the beginning and will set the actual jog rate, Jog Rate% DRO  and Slider value to 1 on start up. Now the the keys and pendent buttons will scale up and down the jog rate since it is able to start out from 1. However, if you at any time adjust the slider with the mouse on the screen, then the slider and dro will only go back down to that value you set the slider to with the mouse, if you go back and use the keyboard or pendent after that. If you slide the slider back to 1 with the mouse it will then work as intended with the buttons or keyboard.
 
Again I really appreciate your suggestions and examples as those helped me figure out what I needed to do in regards the correct syntax as the manuals found in the help folder explain things in general but don't really have any exact examples.....
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #14 on: March 22, 2019, 11:43:12 PM »
smav,
There aren't any more functions from a drop down other than jogging from the Keyboard Plugin Config.  You will have to add your inputs to the Signal Library just like you did with the E Stop.
The EStop was easy because there is already a call for E Stop; but you will have to write a script to do other functions like increasing Jog %.

I made a script to increase and decrease the Spindle Override with the (+) and (-) buttons.
I mapped the Buttons to Input 3 and Input 4.
In the screen load script; I made a function called SpindlePlus() to increase by 10% and SpindleMinus() to decrease by 10%
In the Signal Library, I put those functions in Input 3 and Input 4 respectively.



[mc.ISIG_INPUT3] = function (State)
    if (State == 1) then   
       SpindlePlus()
     end
end,

[mc.ISIG_INPUT4] = function (State)
    if (State == 1) then   
       SpindleMinus()
     end
end,

---------------------------------------------------------------
function SpindlePlus()
    local inst = mc.mcGetInstance()
    local SSO = mc.mcSpindleGetOverride(inst)--Returns:  0.5 - 1.5
    if SSO >= 1.5 then
       mc.mcCntlSetLastError(inst, "Can't increase SSO anymore.")
    else
       SSO = (SSO + 0.1)
       mc.mcSpindleSetOverride(inst, (SSO))
    end
end
---------------------------------------------------------------
function SpindleMinus()
    local inst = mc.mcGetInstance()
    local SSO = mc.mcSpindleGetOverride(inst)--Returns:  0.5 - 1.5
    if SSO <= 0.5 then
       mc.mcCntlSetLastError(inst, "Can't decrease SSO anymore.")
    else
       SSO = (SSO - 0.1)
       mc.mcSpindleSetOverride(inst, (SSO))
    end
end
---------------------------------------------------------------
Chad, Your posted script works well, I did it for also the FRO.   Thanks.   Can you show me how this would look for the JogRate?   I been trying for days now, no luck for some reason.   I just keep getting errors.  This is what I have for JogRate:
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #15 on: March 23, 2019, 02:30:37 PM »
I can't see the code, the picture is too small.
Can you just copy the code into the thread?
Chad Byrd
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #16 on: March 23, 2019, 03:18:27 PM »
Ok, try this, I don't know how to copy code into a thread, im dumb as hell on this stuff, sorry.

I put a + & - button by the jograte slider, they work good, but I cannot get to do that with the keyboard, :(

Thanks for your time,
Fritz
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #17 on: March 23, 2019, 03:47:00 PM »
Hi,

Quote
I don't know how to copy code into a thread,

What you have done works but there is an even easier way.  You may have noted  a series of buttons
along the top of the text input panel, the one with the 'hash' icon will insert a code panel within your text.

There are many others, the quote and hyperlink insert buttons being commonly used ones.

They insert a matched pair of editing marks and all text within the marks is treated specially by your browser.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #18 on: March 23, 2019, 04:03:02 PM »
OK,  Thanks for that, always learning.

Re: Configuring Keys In Key Board Inputs Configuration Table
« Reply #19 on: March 24, 2019, 12:21:24 PM »
Craig,  What am I doing wrong here?   I get errors no matter what I put in for a jog API.  I'm trying to map this to my keyboard F1 key.

SigLib = {
   
[mc.ISIG_INPUT22] = function (state)
    if (state == 1) then --
      local inst = mc.mcGetInstance()
        Feed2()
    end
end,


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, Feed2)
    end
end