Hello Guest it is March 28, 2024, 06:09:49 PM

Author Topic: Modification help  (Read 431 times)

0 Members and 1 Guest are viewing this topic.

Modification help
« on: March 24, 2023, 10:45:36 AM »
I'm using Mach4 with a EES/Warprunner and the Warprunner screenset. Below is somethings I'd like to modify. I've a newbie when it comes to editing Mach4.

1. Is it possible to make the machine jog at a slow rate until it's been homed? Issue is sometimes the guys forget to home the machine and it gets rapid jogged into the hard stops.

2. I would like the keyboard input enabled automatically. Currently, you have to click on the jogging tab and enable them at startup.

3. Under the jogging tab, there is a slider to change the jogging feed rate. It would be really convenient when positioning the torch if you could easily click a button for pre-set jog percentages. I'd like to put the buttons on the file ops tab as that's the tab we are normally on.

Thanks in advance.
Re: Modification help
« Reply #1 on: March 24, 2023, 10:21:10 PM »
Hi,
yes it should be possible to do all those things.

1) Consider the APIs:                                      (Mach4Hobby/Docs/Mach4CoreAPI)
Code: [Select]
LUA Syntax:
rc = mc.mcJogSetRate(
number mInst,
number axisId,
number percent)

Description:
Set the jog rate of the given axis as a percentage of the axis' maximum velocity.


and

Code: [Select]
LUA Syntax:
rc = mc.mcJogSetInc(
number mInst,
number axisId,
number increment)

Description:
Set the current jog increment for the give axis.

So these two APIs allow you to programmatically set the jog rate.

When Mach first loads the Screen Load script runs. You could place a macro in the Screen Load script that sets the jog rate and increment rate to some suitable value.

Another variation of the same idea: Once Mach loads the PLC script runs every 10ms or so. There is a counter, and on the first time the PLC runs, ie immediately after
Mach, loads you could append code to set the jog and increment rates, and it would run exactly once at first start up.

Another possibility is to test whether mach is Homed, if it is not then set the rates to what you consider appropriate. You could do this in the PLC script, and the test would be made
every 10ms or so. Its not a very efficient way to run code but it has the virtue of simplicity.

2) There is already a function in Mach4 coded to do exactly that. See the attached pic. The function is KeyboardsInputsToggle(). I'm guessing the function is defined in the screen load script.
Either way just invoke this function at the first run (only) of the PLC script. One line is all it takes. Note that I found this by opening the screen editor an looking at the Events tab of the Keyboard
Jog Enable button.

3) Use the screen editor to make the buttons. Each button should have a script to set the jog rate. You can put the buttons wherever you please, often the problem is space to do so.

For instance, see attached pic. I have placed two buttons on the FileOps tab, they are named Btn100 an Btn101, but you can call them anything you like. I have pictured the Properties tab
of Btn101. You'll see that I've give it a label of '20% Jog Rate'. Experiment with size, labels, colors etc.
The second pic is the Events tab of the same button, namely Btn101. Note that you have quite a range of events and/or actions that can be taken as a result. The ones most likely to be of
use to you are the Left-Up script, the Left-Down script or the Clicked-Script. I doubt any of Mach prepackaged Actions are going to be suitable. Basically you just put a function call
in one of the scripts like:

SetJogRate20()

And then in the screen load script define the function and what you want it to do:

function SetJogRate20()
......
.....
.....
end

and populate the script with the API calls to set the rate per your preference.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Modification help
« Reply #2 on: March 26, 2023, 03:39:27 PM »
Hi,
I have just posted in another thread how to turn the Keyboard on automatically, as it turns out you don't have to code anything....just comment out
one line of code.

https://www.machsupport.com/forum/index.php?topic=47199.new#new

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Modification help
« Reply #3 on: March 29, 2023, 08:39:12 AM »
Thank you for the help! I will start working on this and report back.