Hello Guest it is March 28, 2024, 07:54:54 AM

Author Topic: Mill Profile Initialisation String  (Read 1750 times)

0 Members and 1 Guest are viewing this topic.

Mill Profile Initialisation String
« on: July 05, 2019, 09:13:14 PM »
Hi All,
I am struggling to find the code that results in the initialization string that occurs in my mill profile.

In particular I wish to delete the G54 from the list. I have scanned through the machine.ini file and not found anything
that appears to be the init. string.

I am aware that I can provide my own init. string in Machs Control plugin but I still want to delete the G54. The correct
work coordinate set will provided by a script and may well vary between sessions. Therefore a fixed initialization string
as the one in the Control plugin is not suitable.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mill Profile Initialisation String
« Reply #1 on: July 07, 2019, 08:09:35 AM »
Hi,
I may have made some progress.

When messing around in Screen Edit Mode I found in the Rapid Group container a label called lblModals.
It would appears that the label displays a string that is internal to Mach4 and beyond editing. There is now the
question that if I write my own text string into that label would it be used as the modal string or would Mach4 use
its internal string even though the screen label was different?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline Mauri

*
  •  328 328
    • View Profile
Re: Mill Profile Initialisation String
« Reply #2 on: July 07, 2019, 08:03:42 PM »
Craig,
Interesting question.
If you make the Label Code "Blank" it will show nothing.
The list of G-Codes is part of the system.
For example if you change you default settings from "mm" to "inch" then your will see G21 go to G20 on that list of codes after a Mach4 Restart.
However like you I cannot find any anywhere else that makes a difference.
Steve is the person who knows.
Regards,
Mauri.

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Mill Profile Initialisation String
« Reply #3 on: July 09, 2019, 12:19:16 AM »
G54 is simply the default user coordinate system.  It really isn't in any init string.  It is modal group #14.  But it has to default to SOMETHING, so G54 it is.  All modal groups have a default value.  If you want to change it, put something else from that modal group in the init strings in the control configuration dialog (G55, G54.1, etc...). 

Steve
Re: Mill Profile Initialisation String
« Reply #4 on: July 09, 2019, 03:11:21 AM »
Hi Steve,
I had hoped to arrange it such that if I ended a session in g58 say that at the beginning of the next session Mach would
assume the same offset set. Having any particular, but fixed, offset in the init string defeats scripts ability to initialize the machine
with another set.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Mill Profile Initialisation String
« Reply #5 on: July 10, 2019, 02:06:35 AM »
Well...  You can save the last coordinate system used in the screen unload script to the profile. 

Get the modal 14 value by:
mc.mcCntlGetModalGroup()
or
mc.mcCntlGetPoundVar() with mc.SV_MOD_GROUP_14

Then read the profile in the screen load script, look for the control to be enabled in the PLC script, and then execute an MDI command to change modal group #14. 

That should do it.

Steve
Re: Mill Profile Initialisation String
« Reply #6 on: July 10, 2019, 02:54:22 AM »
Hi Steve,
thanks.

Yes, that is exactly how I have attempted to do it. The screen unload script records the currently used work offset number
in the .ini file. On starting a new session of Mach I wait until the first run of the PLC script to read the .ini entry and
initialize Mach to the recorded offset group.

The only fly in the ointment is that when Mach runs its default initialization string it resets the offset group back to g54.

I need either to prevent Mach from reading the g54 in the string OR have Mach set up my required offset group AFTER the
g54.

Do you know when the initialization string is read and executed?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Mill Profile Initialisation String
« Reply #7 on: July 10, 2019, 03:27:36 AM »
The initialization string is read when the core is loaded by the GUI.  It is then sent to the interpreter when the control is Enabled for the first time AND when the control is Reset.  You can change the init strings that are sent to the interpreter when reset by using mcCntlGetResetCodes() and mcCntlSetResetCodes() functions.  This string is initially built from the contents of the control configuration dialog's General tab. 

Basically, you could intercept the OSIG_MACHINE_ENABLED signal in the signal lib, get the reset codes, modify by adding your desired coordinate system (there won't be one in the reset codes unless you added it), and then set the new reset codes.  Then call mcCntlReset() manually to get them added to the interpreter.  Then forever after during the Mach session, every time you hit reset, the control will get your desired coordinate system until you change the reset codes.  If you shut down Mach, the modified reset codes will NOT be saved.  You will have to take care of saving the desired coordinate system at screen unload and retrieving it at screen load before modifying the reset codes. 

Steve
Re: Mill Profile Initialisation String
« Reply #8 on: July 10, 2019, 09:00:56 AM »
Does this happen the first time you press enable?
On a lathe in the shop, I get the first instance of the Enable, it is a Core/inst register "cmdEnable" if that is == to 1 then I run a function that will set the current tool in the turret and then set the cmdEnable to 2 that way it doesn't loop the function endlessly.   
You may be able to do this to set your desired work offset.
Chad Byrd

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Mill Profile Initialisation String
« Reply #9 on: July 10, 2019, 01:47:32 PM »
Oops...  there isn't a mcCntlGetResetCodes() API function.  :(  It is actually a compilation of a few constants and some profile settings in the order presented below.  I'll add a "Get" function at some point. 

The constants:
G40 // Always add G40 before G20 or G21!
G80 // Always add G80!

These next ones are in section/key, default format:
DefaultMode/UnitsMode, G20
DefaultMode/TraverseMode, G00
DefaultMode/MotionMode, G64
DefaultMode/DistanceMode, G90
DefaultMode/CenterMode, G91.1
DefaultMode/FeedMode, G95
DefaultMode/Plane, G17
DefaultMode/CanedCycleRetract, G98
DefaultMode/SpindleMode, G97S0
DefaultMode/UserDefaults1, ""
DefaultMode/UserDefaults2, ""

So construct a string by adding the constants and reading all of that from the profile, append your desired work coordinate system, and then set the new reset codes with mcCntlSetResetCodes().

Steve