Hello Guest it is March 19, 2024, 03:43:16 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jevs

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 »
31
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

 

32
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.

33
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.

34
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

35
If anyone else stumbles upon this thread looking for answers, open this file from your computer that has Mach4 installed.......

C:\Mach4Hobby\LuaExamples\MessageBoxes.mcs

Best to open it with the Zero Brain Editor, but most text programs should open it.

I stumbled upon this today digging around for info.

36
I did find those pages, but I did not find anything about those numbers representing different options. The numbers do work though and you can use them as variables to determine what to do with the answer after it is clicked.

Ultimately I have it working, but I still don't know how someone came to know about those numbers being different select options for the message box.

37
This seems to be working with the on screen button "Auto Tool Zero" I made where there was a blank button in my screen set. It is calling out the function AutoToolZero() when you click it.

This code is in the Screen Load Script in the functions area section I made for my mill.

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 selectedtool = mc.mcToolGetSelected(inst)  --ERASE THIS LINE IF NOT NEEDED
local currenttool = mc.mcToolGetCurrent(inst)

--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)
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0000") --Move the Z to Home
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X19.5300 Y14.4500") --Move the the X, Y Coords to to the touch pad location.
rc = mc.mcCntlSetLastError(inst, 'Now in Tool Measuring Position')

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
        mc.mcCntlSetLastError(inst, "Probing in Progress!")
        mc.mcCntlGcodeExecuteWait(inst, "G90 G31.1 Z-5. F5.0") --probe the new tool
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

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 NewOffset = probedz
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

Please feel free to critique.

I do think I want to add a data entry field on the screen to enter the height of the Tool Height Setter (Probe G31.1) and then utilize that in an equation to get proper offsets.....I am still trying to figure out how all this works with the 3D probe as tool 1....

38
I kept digging. I never found any documentation, but I found another post on here with info that got me going..........

local rc = wx.wxMessageBox("This is my Message", "This is my Caption",16) --Ok, Cancel

--wxMessageBox Types
--2 = Yes, No
--4 = Ok
--16 = Ok, Cancel
--18 = Yes, No, Cancel

--wxMessageBox Return Values
--Yes = 2
--OK = 4
--No = 8
--Cancel = 16

It would still be nice to know where this is documented though. For now I made myself a text file with the info and put it in my docs folder.

39
I am using an ESS

I have my backlash set to .0013 on the X axis and the compensation turned on with the ESS settings.

Many times when I home, the X axis machine coordinate becomes .0013 or .0014 after a home instead of .0000"

It seems to work out to zero if you move the X axis in a certain direction before homing.

Nothing strange like this ever happens with Y and I have compensation on that as well and it is a higher amount. It happens all the time on X. 

If I set the X backlash to zero, then it always takes the machine coords to X = 0.0000 on a ref all.

40
I am trying to create my own from what I can find, but it is turning into dead ends and no answer to be found on google.

The screen set that has this button is just blank on the button, so it does nothing.

I kind of have it working, but not very good....the wxMessageBox stuff in there is not really working right.
Everything I find here is old.
In the mean time I am still working on my own starting with some example of an M6 with auto tool change code in it, but something that just works would be nice.....

The manual references setting up an Auto Tool Zero macro in the manual for setting your TLO's using the gage line method....but then that becomes a dead end to actually do it since I cannot find anything further.

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 »