so I had some Homing issues... lots of you out there have also posted about this, however for the most part mine were a bit different. Mach4 was only doing a HOME IN PLACE operation.. my servo's had their own homing routines that were triggered by an actual plc. Mach4 would receive an input thru my ESS from the plc, and my PMC coding would generate a HOME ALL command.. pretty simple I would expect... except the HOME ALL did very strange things and generated some bizarre position data.. we do use a G54 offset and I found that often Mach4 would modify that as well when the HOME ALL was generated (Yes, it was only one, countem, one time fella's).. I played with doing a HOME ALL and then setting the X,Y,Z positions to zero.. I read the G54 values and attempted to write them back at the end (don't bother) Mach4 generated all sorts of offsets, cleared or modified the G54 offsets in the table, and my machine positions which should be zero, and current positions which should have been the original G54 values were all over the place... 10~12 hours of testing across 2 days, and I had what looks like a solution. Does what I expect for a homing process... all my offsets (except my G54) are zero'd, and my positions are now the X,Y and Z in the G54 fixture offset. One of the biggest issues was determining that there is a minimal time which you must allow for, between commands. My guess would be because of the way Mach4 generates command threads, and overlaps will write into the same registers, or read data before its actually modified properly by a previously called routine or command. Actual reason doesn't matter since I now know its time dependent.
I used the PMC, PLC, and button coding to accomplish what I needed. Basically I switch the control from G54 to G55 (or any other non-used fixture offset). Then I generate an MDI commend "G92 X0 Y0 Z0". Then I generate the HOME ALL.. delay 100ms, zero all the axis. Delay 100ms and again generate an MDI command "G92 X0 Y0 Z0" and then set the control back to G54. This allows MACH4 to clear any offset values in the G55 which don't matter anyway.. as I said I then end up after a homing process with my Machine Coordinates at zero, my G92 offsets at zero, my work shift offsets at zero. My Work offsets are now the values in the G54 table, and my positions are what I expect (G54 values times -1).
Bit involved.. but now it all seems to work correctly regardless how I move or Jog any axis, change offsets, do random G92 commands, or nearly anything else. The setup personnel or the operators would need to grossly change their normal routines to make this not work correctly.
Weird stuff..
