Hello Guest it is March 28, 2024, 05:01:22 PM

Author Topic: Problem. How to make a generic MPG work with Mach 4 Guide,  (Read 3989 times)

0 Members and 1 Guest are viewing this topic.

Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #10 on: September 21, 2018, 03:19:51 PM »
Hi,
this is a list of the machine states:

Code: [Select]
mcStateCheck = {
[0] = "MC_STATE_IDLE",
[1] = "MC_STATE_HOLD",
[2] = "MC_STATE_FRUN_SUB",
[3] = "MC_STATE_MRUN_SUB",
[4] = "MC_STATE_JOG",
[5] = "MC_STATE_DRYRUN",
[6] = "MC_STATE_HOME",
[7] = "MC_STATE_CONFIG",
[100] = "MC_STATE_FRUN",
[101] = "MC_STATE_FRUN_FH",
[102] = "MC_STATE_FRUN_PROBE",
[103] = "MC_STATE_FRUN_PROBE_FH",
[104] = "MC_STATE_FRUN_THREAD",
[105] = "MC_STATE_FRUN_THREAD_FH",
[106] = "MC_STATE_FRUN_FH_JOG",
[107] = "MC_STATE_FRUN_TAP",
[108] = "MC_STATE_FRUN_MACROH",
[109] = "MC_STATE_FRUN_MACROH_JOG",
[110] = "MC_STATE_FRUN_SINGLE_BLOCK",
[111] = "MC_STATE_FRUN_RETRACT",
[112] = "MC_STATE_FRUN_HOMING",
[113] = "MC_STATE_FRUN_SINGLE_BLOCK_HOLD",
[199] = "MC_STATE_FRUN_END",
[200] = "MC_STATE_MRUN",
[201] = "MC_STATE_MRUN_FH",
[202] = "MC_STATE_MRUN_PROBE",
[203] = "MC_STATE_MRUN_PROBE_FH",
[204] = "MC_STATE_MRUN_THREAD",
[205] = "MC_STATE_MRUN_THREAD_FH",
[206] = "MC_STATE_MRUN_TAP",
[207] = "MC_STATE_MRUN_MACROH",
[208] = "MC_STATE_MRUN_MACROH_JOG",
[209] = "MC_STATE_MRUN_RETRACT",
[210] = "MC_STATE_MRUN_HOMING",
[299] = "MC_STATE_MRUN_END",
}


Before you can issue jog commands via the keyboard or MPG the machine MUST be in state "MC_STATE_IDLE" or already in state "MC_STATE_JOG".

You can use:
Code: [Select]
LUA Syntax:
mcState, rc = mc.mcCntlGetState(
MINSTANCE mInst)

To get the state of the machine prior to trying to issue any jog commands.

When RefAllHome is active, then jogging is not. When jogging is in progress RefAllHome is disabled.
Whenever the machine is idle then either the keyboard OR MPG can issue jog commands.
What is happening is your MPG is seizing control of Mach and not releasing it so other functions can run.


Have a look at Daz-the-Gaz videos on coroutines. It provides a way for an MPG to 'yield' so that other functions can run without
being blocked.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #12 on: September 22, 2018, 01:48:35 AM »
I understand why now, and this it might be the problem. but I don’t understand wich functions to edit?
when the code is added Mach won’t allow any jogging at all.

Why does it change the machine state? Or why would it block gui when the function is not called by axis select?  Maybe it’s enabled by default but before the code is added everything works great?
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #13 on: September 29, 2018, 11:25:55 AM »
Exactly the same problem here, BUT everything was fine until I moved from an earlier build of Mach4 (can't remember the build, but at least 18 months old) to the current 2.0.3804 build.

I have to turn the pendant off (Rotary axis selection switch to OFF position), then shut Mach4 down and re-start Mach4 (with hte pendant still OFF), for the Home All and Jogging functions to be active. As soon as I turn the pendant ON (by selecting an axis with the rotary switch), the Home All and Jogging functions are grayed out.

Nick.
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #14 on: September 29, 2018, 11:29:36 AM »
I haven’t tried a pendant, just the code, but it seems like we have the exact same problem.
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #15 on: September 29, 2018, 05:45:37 PM »
My Mach 4 won’t lock up the gui when code is added.. so I’m not sure if it’s a coroutine?
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #16 on: October 11, 2018, 06:23:48 PM »
I uninstalled and then re-loaded Mach4 3.0.3804. Everything now working fine again.

Nick
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #17 on: October 14, 2018, 03:56:48 AM »
That’s strange? Do you run a non-modified Mach 4 setup? Nothing is changed more than the ports&pins and so on? I doubt that reload would cut it for me due to custom macros and profiles “old files”  and so on. I still need to install and port all the pins for my mpg, then I’ll have a look at the things mentioned above “Coroutines” it may be that’s who’s causing the trouble,
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #18 on: October 21, 2018, 05:10:25 AM »
I’ve put the Mpg together and plugged it in, it works fine, the only thing I didn’t think of is to not use a enable button on the input voltage on the pulse generator wheel, it triggers A-B input every time the button is pressed, it’s a quick fix.

other than that it does what i want it to do? I’ve uploaded a video on YouTube that demonstrates the problem with the flashing buttons and no ref all home button,

https://youtu.be/ynx5scc5eAQ