Hello Guest it is March 28, 2024, 11:57:20 AM

Author Topic: Keyboard Inputs enabled right after Mach4 starts  (Read 4112 times)

0 Members and 1 Guest are viewing this topic.

Keyboard Inputs enabled right after Mach4 starts
« on: March 14, 2021, 01:06:24 AM »
Please forgive my rookie question, since I am new in Mach4.
When I start Mach4, button Keyboard Inputs in Jogging tab is disabled by default (so when I enable drives, screen does obviously something else while pressing arrow keys and Page Up/Down buttons :D )
Please, how to make Keyboard Inputs button enabled right after Mach4 starts?
Thank you!
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #1 on: March 14, 2021, 02:55:35 PM »
No opinions? Come on... Don't tell me that it's not possible to set a default value for a variable in Mach4...

Offline thosj

*
  •  532 532
    • View Profile
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #2 on: March 14, 2021, 04:20:47 PM »
Opinions? My opinion is YOU can do it. Might start in the screen editor and see what's in the button that turns on keyboard jogging and duplicate it somehow in the Screen Start Script.
--
Tom
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #3 on: March 15, 2021, 01:21:15 AM »
Bet that I am pretty sure that I am the one who can do it. But I'd kindly ask at least for an representative example, either in Mach4 documentation or in an YouTube video. Frankly, I am Mach4 lama and I need a start somehow. (nobody was born with detailed Mach4 knowledge)
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #4 on: March 15, 2021, 03:32:11 AM »
I had this issue. When I put the command in the screen load it wouldn't turn the keyboard inputs on. So, I created a 2 second delay to occur after the screen "loads".

Screen Load Script:
Code: [Select]
loadTimer = 2
waitForScreenLoad = true

PLC Script:
Code: [Select]
if os.clock() > loadTimer and waitForScreenLoad then
waitForScreenLoad = false

local keyboardEnableReg = mc.mcIoGetHandle (inst, "Keyboard/Enable")
mc.mcIoSetState(keyboardEnableReg, 1)
end

To edit the Screen Load and the PLC scripts refer to this video: https://youtu.be/fKGJ3cfiW8s
« Last Edit: March 15, 2021, 03:35:45 AM by compewter_numerical »
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #5 on: January 19, 2022, 08:59:51 AM »
I think the simplest way is an add this Keyboard InputsToggle() here:

Code: [Select]
-------------------------------------------------------
--  PLC First Run
-------------------------------------------------------

if (testcount == 1) then --Set Keyboard input startup state
    local iReg = mc.mcIoGetHandle (inst, "Keyboard/Enable")
    mc.mcIoSetState(iReg, 1) --Set register to 1 to ensure KeyboardInputsToggle function will do a disable.
    KeyboardInputsToggle() -- This make KeyboardInputsToggle disable
    prb.LoadSettings()

    KeyboardInputsToggle() --This make KeyboardInputsToggle enable


Or try add KeyboardInputsToggle() to UP and DOWN script of Enable button.
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #6 on: September 06, 2022, 09:23:32 PM »
dobrzann
i just added the last line and worked great for me thanks

KeyboardInputsToggle() --This make KeyboardInputsToggle enable
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #7 on: March 25, 2023, 10:35:52 AM »
Like I said in another forum, you have to know programming to work Mach4. It is not hobby friendly. I am not dogging it for industrial but in my mind they should have transferred some of the basics from 3 to 4. It is hard for the basic user to study all this and make it work best for you.
Todd
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #8 on: March 26, 2023, 04:38:29 PM »
Hi,

Quote
they should have transferred some of the basics from 3 to 4.

They have. If you spent some time you'd find that ALL the basic stuff is there, you just have to turn it on or off to suit your purpose.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Keyboard Inputs enabled right after Mach4 starts
« Reply #9 on: March 26, 2023, 09:16:25 PM »
You will need to explain what basic function means. Having keyboard functions on when Mach has booted up seems like it should be a basic function but it appears its not. A script has to be written by a programmer to make it work. Moving the Z axis to a safe position while going to work zero to me would be a basic function but its not. A script has to be inserted in order for it to do this. Tons of basics that were not transferred from 3-4 which makes it a bit hard for a hobbyist to manipulate.
Todd