Mach4 Macro or Hotkey setup for Jogging

Hey Guys, I use a wired gamepad to control my CNC rather than the keyboard. Does anyone know how to create a macro or a hotkey assignment for controlling the jogging increments? You know, to switch between 1.0000, 0.1000, 0.0100, 0.0010 and 0.0001?

They don’t have to be independent macros for each value. Simply one that you can assign to a game pad button and cycle through to get what you want.

Thanks in advance,

That would be cool!! I think you can assign one of the triggers for that but it only works for what you have mach 4 set on. Check out this video on YouTube How To Setup Xbox controller For Avid Cnc Mach4 hope this helps…

P.S. You have some pretty awesome videos on there too!! :+1:

1 Like

You talking about the DazTheGaz xbox controller?

I think NewFangled expanded his code with 1 or two custom scripts that can be executed but I threw it away after the code crashed with the machine screaming down the Y axis. Had the soft limits not been on I would have had a mess on my hands.

After that I unplugged the thing and gave the controller to one of my kids.

I totally just did this!

I need to write up a document or make a video on how to do it. I mapped keys 1 through 4 to do this.

  1. Keyboard Plugin configure

  2. Control Config → Inputs

  3. Screen → Edit → Screen Load Script

1 Like

I like the way you did it. I have been meaning to add a hotkey to toggle through the inc. settings, but I like yours better because you can directly set it, and you don’t have to look at the screen to see where you are in the series.

I see you also wisely left off the 1" increment. At one point one of the Mach4 or AVID screen updates came out and kept defaulting to 1" instead of the 0.010" that I always use. There is nothing more frustrating that jogging up to the edge of something and tapping the increment button and having at 1" and snapping off your bit or ruining the workpiece.

nice job.

1 Like

Thanks Jim! Your tip helped me figure it out.

One other change I did: I made it so the keyboard inputs were only enabled when the machine was enabled. I kept editing the Screen set, and realizing my keyboard strokes were consumed by the plugin and not allowing me to type in “1, 2, 3, etc”.

Also, the function:

function SetJogIncToValue(value)
	mc.mcJogSetInc(inst, mc.X_AXIS, value);		
	mc.mcJogSetInc(inst, mc.Y_AXIS, value);
	mc.mcJogSetInc(inst, mc.Z_AXIS, value);

My generated ScreenScript.lua is here:

You can use it to copy/paste the signal inputs (search for SetJogIncToValue to see the related code)

Ya, thats frustrating. There is already a button on the mach4 screen for that. I just forget to use it sometimes. Then i try to arrow over something in Vectric and the machine starts jogging :slight_smile:

A little bit off topic but I have been looking for a way to Execute a Feed Hold with an offboard switch similar to a EStop switch. The Feed Hold button on the screen is too cumbersome to hit in a panic situation and many times a EStop is not necessary. Using a keyboard key is better but still not as fast or confident as a simple button switch. Do the Screen scripts increase the reaction time of execution over what it would be using the button on the screen?

Yes. I think you can map an ESS input to Mach4 and then to a function. I think I ran across a video on YouTube once for that.

I did something a little different. I always have my mini keyboard in hand when I’m at my machine, so I mapped two keys to stop and feedhold, then colored them to match the mach4 screen so I can find them quick.

I have a portable key board just like yours which is good for jogging but even with the colored keys I don’t trust me quickly finding and hitting them.

Nope, the screen scripts are what the button executes as well.