Hello Guest it is March 28, 2024, 07:35:42 AM

Author Topic: Error, Y axis commanded over SoftMin after auto tool touch then tool change?  (Read 1439 times)

0 Members and 1 Guest are viewing this topic.

Offline jevs

*
  •  315 315
    • View Profile
ESS version 248
Mach 4 Hobby Version 4.2.0.4310

If I do a tool probe or tool change many times I am getting "Error, Y axis commanded over Softmin".

I have been fighting this since I got the probing working. I updated the ESS to what they say works with this version of Mach 4.

One thing I notice is that my Y will say -0.0000. Not sure why it has a minus, but maybe this has something to do with it? I moved my tool setter .005 in from the soft limits to make sure that was not it. I moved the tool change location in also to make sure. No help.

Sometimes after this occurs, then it will also start my tool height check , but never actually move, yet my message window comes up that it is in position, even though it never moved. No moves will occur with the tool height check function, but I can jog the axis around still.

It may also have something to do with a tool change after the tool probe.

What I just did this time was power up mach, ref home everything, initiate a tool height probe sequence, which worked like it should. Then I sent an M6 T6 to change to the next tool, then I get the "Error, Y axis commanded over SoftMin". I am beginning to think this is a bug??

Once this occurs, even if I ref all home again, the Auto Tool Change button will no longer make any moves. When I hit it, it will say it is ready to probe (meaning it should have moved over the tool height setter), but it never moves and does not try to probe even if you say okay. It is like the moves are disabled within the function now for some reason. However, I can still jog around and home etc just fine after this. A tool change will not do anything either once it gets in this state.

.....I just tried again, and it does the same thing after a tool height check and then trying to do a tool change. However this time it did not give me a negative on the Y, but many times it does.

If this is not a bug, maybe something in my Tool Zero probe function is causing it?
Code: [Select]
-----Auto Tool Zero button------
function AutoToolZero()
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --Get the current mode so we can return to it when macro ends
local currenttool = mc.mcToolGetCurrent(inst)
local ToolRadius = mc.mcToolGetData(inst, mc.MTOOL_MILL_RAD, currenttool) --Get the radius of the current tool

--Get positions before moving to do tool change
local valX, rc = mc.mcAxisGetMachinePos(inst, mc.X_AXIS) --Get the position of the X axis in Machine Position
local valY, rc = mc.mcAxisGetMachinePos(inst, mc.Y_AXIS) --Get the position of the Y axis in Machine Position
local valZ, rc = mc.mcAxisGetMachinePos(inst, mc.Z_AXIS) --Get the position of the Z axis in Machine Position

rc = mc.mcCntlGcodeExecuteWait(inst, "M05") --Turns off the spindle (includes decel time)

if (ToolRadius < .4500) then --checks to see if the tool is too big for the touch plate
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000") --Move the Z to Home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X19.5250 Y14.4445") --Move the the X, Y Coords to to the touch pad location
rc = mc.mcCntlSetLastError(inst, 'Now in Tool Measuring Position')
else
local xValDiamCor = (19.5300 - ToolRadius) -- Tool plate center minus tool radius to hit edge of tool
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000") --Move the Z to Home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(xValDiamCor) .. "Y14.4500") --Move the the X, Y Coords to to the touch pad location minus tool radius

local MyChoice = wx.wxMessageBox("Manually rotate tool so lowest cutting edge is over the center of the touch plate","Click OK to continue once tool area is clear!" , 4)
end

local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)

if (MyChoice == 16) then
rc = mc.mcCntlSetLastError(inst, 'Auto Tool Zero was cancelled.')
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000 F15.0") --Retract back to Z home
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY)) --Move back to X & Y initial location
return
elseif (MyChoice == 4) then
rc = mc.mcCntlSetLastError(inst, "Probing in Progress!")
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G31.1 Z-8.125 F20.0") --Quick probe to find touch plate, Z distance min for shortest tool to hit

local touchLoc = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) --Assigns Z Probed position in Machine coords at touch plate
local RetractPoint = touchLoc + .200 --Adds retract distance to touch plate probed point

rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 Z" .. tonumber(RetractPoint) .. "F15.0") --Retracts to prepare for slow approach

local approachDist = RetractPoint - .210 --Subtracts retract distance to touch plate probe, slightly more to make sure probe trips

rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G31.1 Z" .. tonumber(approachDist) .. "F5.0") --Probe the new tool at slow speed
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000 F20.0") --Retract back to Z home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY)) --Move back to X & Y initial location

local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
        mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91

local ToolSetterHeight = mc.mcProfileGetDouble(inst , "ProbingSettings", "ToolHeightZ", 0.0000) --Gets the Tool Height Setter Z postion from the probing tab settings
local NewOffset = math.abs (probedz - ToolSetterHeight) --Gives the Absolute value of the probed Z minus the Tool Heigt Setter Z position
mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool, NewOffset)
mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
end
end
« Last Edit: October 23, 2019, 08:07:56 PM by jevs »

Offline jevs

*
  •  315 315
    • View Profile
So, it seems like it may be something with running the Auto Tool Zero function.

Rather than try to change to the next tool, I just try to run the Auto Tool Zero function again by hitting the button. It will not work the second time for some reason. To get things working "right" again, I have to exit and reboot Mach....

So, it is either a bug with probing or related to it, or there is an issue with my coding...not sure which.

Offline jevs

*
  •  315 315
    • View Profile
I did some more testing. This does seem to be a bug that at a certain point in the code it makes the Y machine coordinate -0.0000. I even expanded the digits out 6 places. It is 0.00000, so there is no hidden value out there that could make it a negative (at least to 6 digits). Al

From home at 0,0 it will run the auto tool height check no problem one time, but when it comes back it is at 0,-0 instead of 0,0. The next try to do a G code move, you get this Y soft limit message. This is why it will not run a tool change or another auto tool height check.

I also tested it by moving off the home position in Y a little so it is a positive position. It works every time then, it does not try to return to since it is not trying to return to a 0,0 (or 0,-0 so it thinks).

I guess until they fix this, maybe I can put a math.abs in there to make sure the -0 becomes a 0. (if that function will even work on a 0).....or some other workaround.
« Last Edit: October 23, 2019, 09:26:28 PM by jevs »

Offline jevs

*
  •  315 315
    • View Profile
Wow this is a pain. I cannot figure out why a Y returns to -0.0000 instead of 0.0000. Even if I take my formulas out and just tell it to straight up return to Y0, it still becomes -0.0000 when it is done.

So, after trying a few different things, this is what finally fixes it. It is a workaround, but it is not noticeable in actual operation. If the valY = 0 (the recorded position when the Auto Tool Zero function is initiated), then I have to tell it to return back to basically 0.0001 (using a new variable and equations). Then I have it move back using a variable that is that value -.0001 (which basically makes it zero again).
The fact that I am basing this on valY=0 to even run, proves the variable is also true zero, but the variable or an actual Y0 just won't work directly. It has to go through these extra BS steps to truly get back to 0.0000 instead of the impossible to even exist -0.0000...

This is skipped if the starting position is not Y=0.0000, because any other value works like it should and returns perfectly.

Here is the work around code. I will be interested to see why commanding it to just go back to Y0 directly will not even work.....
Code: [Select]
-----Auto Tool Zero button------
function AutoToolZero()
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --Get the current mode so we can return to it when macro ends
local currenttool = mc.mcToolGetCurrent(inst)
local ToolRadius = mc.mcToolGetData(inst, mc.MTOOL_MILL_RAD, currenttool) --Get the radius of the current tool

--Get positions before moving to do tool change
local valX, rc = mc.mcAxisGetMachinePos(inst, mc.X_AXIS) --Get the position of the X axis in Machine Position
local valY, rc = mc.mcAxisGetMachinePos(inst, mc.Y_AXIS) --Get the position of the Y axis in Machine Position
local valZ, rc = mc.mcAxisGetMachinePos(inst, mc.Z_AXIS) --Get the position of the Z axis in Machine Position

rc = mc.mcCntlGcodeExecuteWait(inst, "M05") --Turns off the spindle (includes decel time)

if (ToolRadius < .4500) then --checks to see if the tool is too big for the touch plate
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000") --Move the Z to Home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X19.5250 Y14.4445") --Move the the X, Y Coords to to the touch pad location
rc = mc.mcCntlSetLastError(inst, 'Now in Tool Measuring Position')
else
local xValDiamCor = (19.5250 - ToolRadius) -- Tool plate center minus tool radius to hit edge of tool
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000") --Move the Z to Home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(xValDiamCor) .. "Y14.4445") --Move the the X, Y Coords to to the touch pad location minus tool radius

local MyChoice = wx.wxMessageBox("Manually rotate tool so lowest cutting edge is over the center of the touch plate","Click OK to continue once tool area is clear!" , 4)
end

local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)

if (MyChoice == 16) then
rc = mc.mcCntlSetLastError(inst, 'Auto Tool Zero was cancelled.')
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000 F15.0") --Retract back to Z home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY)) --Move back to X & Y initial location
return
elseif (MyChoice == 4) then
rc = mc.mcCntlSetLastError(inst, "Probing in Progress!")
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G31.1 Z-8.125 F20.0") --Quick probe to find touch plate, Z distance min for shortest tool to hit

local touchLoc = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) --Assigns Z Probed position in Machine coords at touch plate
local RetractPoint = touchLoc + .200 --Adds retract distance to touch plate probed point

rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 Z" .. tonumber(RetractPoint) .. "F15.0") --Retracts to prepare for slow approach

local approachDist = RetractPoint - .210 --Subtracts retract distance to touch plate probe, slightly more to make sure probe trips

rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G31.1 Z" .. tonumber(approachDist) .. "F5.0") --Probe the new tool at slow speed
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000 F20.0") --Retract back to Z home
---This Code is to fix an issue where returning to Y=0 changes the Y coord to -0.0000 (should not have a -)
if valY == 0 then
local valYfix = valY + .0001
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valYfix)) --Move back to X & Y initial location
local valYfixb = valYfix - .0001
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valYfixb)) --Move back to X & Y initial location
else
---^^This Code is to fix an issue where returning to Y=0 changes the Y coord to -0.0000 (should not have a -)
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY)) --Move back to X & Y initial location
end

local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
        rc = mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode)) --Return to pre macro mode G90, or G91

local ToolSetterHeight = mc.mcProfileGetDouble(inst , "ProbingSettings", "ToolHeightZ", 0.0000) --Gets the Tool Height Setter Z position from the probing tab settings
local NewOffset = math.abs (probedz - ToolSetterHeight) --Gives the Absolute value of the probed Z minus the Tool Height Setter Z position
rc = mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool, NewOffset)
rc = mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
end
end

 
« Last Edit: October 23, 2019, 10:41:06 PM by jevs »

Offline jevs

*
  •  315 315
    • View Profile
After contacting Artsoft and Warp 9 the consensus seems to be that the soft limits have to be set to something negative of the 0,0 position. I have set my x and y soft limits to -.0050 and took that extra code back out.

From Warp 9:
The ESS does allow for the possibility of both +0.0 and -0.0 This arises from the way that the SmoothStepper keeps track of the direction it is (or was last) going in, which can create a -0.0 This ability to track the direction of last movement along with the position helps with backlash compensation and a few other motion related details. But the ESS is working with the position in terms of integer steps. What we report to Mach4 is converted from integer steps to a double precision float.

My initial assumption would be that Mach is comparing -0.0 to 0.0 and that would likely result in a value of less than.. Why? Rounding - I am guessing that the number reported is something like -0.0000000001 due to the floating point conversion, This isn't reflecting that the SmoothStepper's position is off, since the integer steps are still true, but rather the mathematical issues of computer based floating point numbers.

Setting your Y soft limit to -0.01 should fix the issue.

From Artsoft:
I ran into this issue yesterday and the guy was homing too close to his soft limits, I can modify your ref all home function to see if moving the axis further away from the limits helps any, otherwise I'd suggest that your soft limits shouldn't be so close to your homing location (assuming they are).
I will however try to replicate this issue on a machine we have here using your profile.
Best Regards,