Hello Guest it is October 18, 2019, 12:20:46 AM

Author Topic: Using a button script to set jog increments etc  (Read 4592 times)

0 Members and 1 Guest are viewing this topic.

Re: Using a button script to set jog increments etc
« Reply #70 on: May 29, 2018, 02:26:39 AM »
Or finally, perhaps someone at Mach might take this bug seriously and fix it!

It isn't a bug.  I explained in a earlier post that the jog units will follow the machine units mode.  The jogging USED to be ONLY in machine native units.  But we got so many support tickets about that so we made it follow the units mode.  Damned if we do and damned if we don't...

Steve

I think I must be missing something, because to my mind this is clearly a bug.

1) I set the machine units to MM
2) I NEVER set the program to use anything other than MM
3) I change the config, and the machine sometimes changes to Inches

Since I never change to Inches, that must be a bug. Things shouldn't change on their own.

Is there an event that happens on exit from Config that I can go into to run the following...

rc = mc.mcJogSetUnitsMode(inst, axis, mc.MC_UNITS_METRIC || mc.MC_UNITS_INCH);

The other problem this causes is with the HB04 MPG that I had the driver for. That showed the same problem, and ideally I'd like to be able to use it. The trouble is that I'm not certain whether it's ever going to end up in Inch mode and cause a crash. In that case, I have no idea how that interacts with Mach4 and therefore whether it's possible to force Metric mode for its commands.

Offline smurph

*
  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Using a button script to set jog increments etc
« Reply #71 on: May 29, 2018, 03:59:07 AM »
I see what is happening now.  It is not changing on its' own.  The config process destroys the axis jog planners and recreates them with the default of inches.  Nothing, at this point, will set the jog units other than a reset.  Pressing Reset will put the control in the proper mode.  

Ok, I'll call that a bug.  But you don't press reset after a config?!?

Steve
Re: Using a button script to set jog increments etc
« Reply #72 on: May 29, 2018, 06:20:44 AM »
The obvious question is why do the axis jog planners  not use the default units set by the user? Surely that overcomes the problem?

I don't know  why the Reset button is even there, it didn't exist in my Mach3 screen that I use. The only time I've pressed it was when Mach4 became unresponsive for any reason and I thought that might get back in control. I intend to remove it because I have no idea what it's supposed to be used for.
Re: Using a button script to set jog increments etc
« Reply #73 on: May 29, 2018, 06:21:51 AM »
striplar

If you look back at the earlier posts you will see that I reset the jog units to the default just prior to jogging. I don't recall that there is any event (e.g. signal)
 indicating that a configuration has occurred. I think this was discussed in some earlier thread.

Code: [Select]
   local defUnits = mc.mcCntlGetUnitsDefault(inst)
    rc = mc.mcJogSetUnitsMode(inst, axis, defUnits)

I've no idea how your MPG would be impacted. I use the CS Labs module which seemingly works independently of Mach4, but presumeably takes the units default from Mach. This has never given the wrong units when jogging.

Allan
Re: Using a button script to set jog increments etc
« Reply #74 on: May 29, 2018, 07:21:39 AM »
Hi Allan,
I see that now. It's certainly safer to explicitly state that it should use the default units, I might do that anyway. Now that Steve knows what the issue is, hopefully this will be addressed in future builds.

I don't know how the MPG driver is implemented so it's hard to know what might happen.

Of course, one way that might help in the interim is to just add this to the Enable button script since you have to have Mach4 disabled when changing the config. That way, it ought to be right for all of the things that move the machine?

Roger
Re: Using a button script to set jog increments etc
« Reply #75 on: May 29, 2018, 07:53:00 AM »
Roger

Good idea. Adding it to the Enable button should be fine assuming Config change is the only circumstance that upsets the units. Our current state of knowledge would suggest that that is the case, but when I wrote mine I was still unsure of just what caused this and didn't want to take any chances.

Allan
Re: Using a button script to set jog increments etc
« Reply #76 on: May 29, 2018, 10:04:04 AM »
Hi Allan,
I can't say I blame you, it's better safe than sorry since it could be dangerous. I hope I'm not being seen as a pain in the arse for pursuing these things doggedly. I think it's in everyone's interest to absolutely nail these issues once and for all.

Offline smurph

*
  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Using a button script to set jog increments etc
« Reply #77 on: May 29, 2018, 04:08:20 PM »
The obvious question is why do the axis jog planners  not use the default units set by the user? Surely that overcomes the problem?

I don't know  why the Reset button is even there, it didn't exist in my Mach3 screen that I use. The only time I've pressed it was when Mach4 became unresponsive for any reason and I thought that might get back in control. I intend to remove it because I have no idea what it's supposed to be used for.

Mach 4 is not Mach 3.  About the only thing they have in common is that they are windows programs that run G code.  If you want to make a comparison, Mach 4 is probably a lot more like a Fanuc than it is like Mach 3.  The reset button is normally on all machine controls (Fanuc, Ysanac, Fidia, etc...), Mach 3 being an exception.  It is there to put the machine into a known state.  For instance, what if you were running a program with cutter comp and stopped it.  And you wanted to restart it from the beginning.  Well...  comp is still in effect!  Or what if you ganked the machine state running MDI commands?  Reset ensures that the machine is put back into its' know state (no comp) before you run the file again.  Reset is all about safety.  You can spot the reset button on a Fanuc quickly because it one of the most used buttons and is probably worn more than others.  

Steve
Re: Using a button script to set jog increments etc
« Reply #78 on: May 29, 2018, 05:39:10 PM »
The obvious question is why do the axis jog planners  not use the default units set by the user? Surely that overcomes the problem?

I don't know  why the Reset button is even there, it didn't exist in my Mach3 screen that I use. The only time I've pressed it was when Mach4 became unresponsive for any reason and I thought that might get back in control. I intend to remove it because I have no idea what it's supposed to be used for.

Mach 4 is not Mach 3.  About the only thing they have in common is that they are windows programs that run G code.  If you want to make a comparison, Mach 4 is probably a lot more like a Fanuc than it is like Mach 3.  The reset button is normally on all machine controls (Fanuc, Ysanac, Fidia, etc...), Mach 3 being an exception.  It is there to put the machine into a known state.  For instance, what if you were running a program with cutter comp and stopped it.  And you wanted to restart it from the beginning.  Well...  comp is still in effect!  Or what if you ganked the machine state running MDI commands?  Reset ensures that the machine is put back into its' know state (no comp) before you run the file again.  Reset is all about safety.  You can spot the reset button on a Fanuc quickly because it one of the most used buttons and is probably worn more than others. 

Steve

Hi Steve,
Ok, I probably don't need it then. I don't use anything clever on the machine at all, it's all done in the CAM software.
The only commands I use are the following because of the pitfalls you describe.

(comment)
M3S###
G1X###Y###Z###F###
M5M30

I occasionally use M0 but that's the only other g-code I use.

I don't use rapids, so I can freely use commands like X50F30<cr> from the MDI line without any fear it will do something unintended.
I always output X,Y & Z so it's easy to restart, and I don't use arcs or any canned cycles because I don't need them.

This way Mach has a really easy time and I always know what's going on and what's going to happen. The CAD/CAM is on the same PC as Mach so it's trivial to change the compensation on the CAM and output the program again. The great thing about this is that the CAD/CAM become the documentation for any repeat jobs. Doing things quick and dirty using wizards leave no trace as to what you've done.

Doubtless I'm alone in adopting this simple approach, but I never get into trouble in the way you describe.

I adopted this really simple methodology because it's just that. No surprises and no having to keep resetting things back to a known state since that state never changes.
Re: Using a button script to set jog increments etc
« Reply #79 on: May 29, 2018, 06:18:35 PM »
This is the Down Script I've added to the Enable button, and this seems bullet proof. Try it by entering the config, make a change then exit. Then Enable and try the jog without pressing Reset.

Hopefully this will now allow me to go back and try the MPG again.


--Make 100% certain that we always use the machine Inch/Metric system set when exiting config.
--Mach has a bug where Config defaults jogging back to Inches!
----------AW Load error check module ---------------
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Modules\\?.lua;" .. path .. "\\Profiles\\" ..  profile .. "\\Modules\\?.lua;"
package.loaded.mcErrorCheck = nil
ec = require "mcErrorCheck"

--local defUnits
local rc

--defUnits, rc = mc.mcCntlGetUnitsDefault(inst)
-- c = mc.mcJogSetUnitsMode(inst, mc.X_AXIS, defUnits)

rc = mc.mcJogSetUnitsMode(inst, mc.X_AXIS, mc.MC_UNITS_METRIC)
if (rc ~= mc.MERROR_NOERROR) then
   mc.mcCntlSetLastError(inst, "Setting X-axis mode returned " .. ec[rc])
end
rc = mc.mcJogSetUnitsMode(inst, mc.Y_AXIS, mc.MC_UNITS_METRIC)
rc = mc.mcJogSetUnitsMode(inst, mc.Z_AXIS, mc.MC_UNITS_METRIC)
rc = mc.mcJogSetUnitsMode(inst, mc.A_AXIS, mc.MC_UNITS_METRIC)