Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: LSoft on March 14, 2021, 01:06:24 AM

Title: Keyboard Inputs enabled right after Mach4 starts
Post by: LSoft 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!
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: LSoft 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...
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: thosj 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.
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: LSoft 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)
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: compewter_numerical 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
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: dobrzann 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.
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: frankg521 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
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: rufustoad 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.
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: joeaverage 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
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: rufustoad 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.
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: joeaverage on March 26, 2023, 10:59:29 PM
Hi,

Quote
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.

Its there already, all you have to do it TURN IT ON!!!! Have you bothered to read the post in the Mach3 board, there I have explained it in great detail. You don't have to write anything, just
comment out one line.

Quote
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.

There is already a <GoToWorkZero> button that operates on the X and Y axes....if you really want your machine to dive in on the Z axis to machine zero or any other number go for your
life......one line is all it takes. Don't be surprised when it crashes....remember you asked for it to operate this way.

You seem to imagine that NFS are clueless, and that they have half done things or not done other things because they don't know what they are doing. As it turns out their
collective machining experience well and truly exceeds yours and mine combined, and what they have done in fact is do are things that are logical, repeatable and as safe as they
can make it AND provide the tools for users to adjust it to their liking. If you cannot or will not take the effort to adjust to your liking then stick with Mach3.

Craig



Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: joeaverage on March 27, 2023, 12:40:28 AM
Hi,
This is the GoToZero function in the screen load script:

Code: [Select]
function GoToWorkZero()
    mc.mcCntlMdiExecute(inst, "G00 X0 Y0")--Without Z moves
    --mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")--With Z moves
end

See how one line works with the X and Y axes only, and the other line (commented out as standard issue) allows X, Y  AND Z moves. If you choose you can have
all three axes move, just comment out the first line and un-comment the second line.

The functionality you seek is already there.....choose which one you want. NFS chose to have a function WITHOUT Z moves being safest and would not catch users out,
however if you wish you can have the GoToZero function WITH Z moves....just choose it.

A word of caution...the function with Z moves drives to Z0 in work coordinates. If that is the surface of the material the machine will drive hard towards it and hopefully
stop with the tool just touching....if you make the slightest mistake you risk driving the tool into the material. Do you want that?

If not then add a little to the Z move like this:

Code: [Select]
mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z50")--With Z moves
This will mean that the Z axis stops 50mm above the surface of the material....which is for my money somewhat safer....but its your machine, your call.

Craig
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: kmaniei on September 04, 2023, 02:33:51 PM
It is interesting, because legally when they sell you the Mach4 for $200 it does not state that you HAVE to be professional programmer to use the software, So except they provide 100% of the coding with full guide OR they provide full GUI for all functions, it is not right.   
Title: Re: Keyboard Inputs enabled right after Mach4 starts
Post by: menardmfg on September 05, 2023, 08:20:49 AM
What’s more interesting is that Mach 3 also requires coding. VB scripting is coding. There are hundreds of different kinds of machines out there that are running Mach 3, and a lot of them have different operations that require a different VB script. I can tell you Fanuc also requires machine builders to code their own specific operations. There isn’t any cnc software out there that doesn’t have some type of coding available to the end user. When you purchase software you should research how to use it. This forum exists so people can do just that. I have had great experiences with this forum and with NFS support. If you want a machine that works right out of the box, then buy one from an actual machine builder. There are a lot of them.