Hello Guest it is March 28, 2024, 11:23:43 AM

Author Topic: Mach4 ESS Probing Problems  (Read 5315 times)

0 Members and 1 Guest are viewing this topic.

Mach4 ESS Probing Problems
« on: March 23, 2017, 02:32:19 AM »
Hello,

I just started with Mach4 and the ESS board.  Everything seems to be working ok but I'm having a problem with the Lua scripts and probing.  I have tried many of the probing scripts on this site and got most of them to run under debug, but if I assign a script to a button, nothing happens. I'm sure it's something simple but it's giving me a run for my money.  I have watched all of the Daz tutorials and I have moved script files to different folders but nothing helps.  Any suggestions would be greatly appreciated.

Thanks,
Andre
Re: Mach4 ESS Probing Problems
« Reply #1 on: April 05, 2017, 01:41:08 PM »
Mine works great.  I have used the probing screen with no problems.  Now I have written Lua code to probe in a custom program using G31

Put your probe about .1 inches away and issue G31 to probe about .05 beyond at F10. then G90 G91 G0 rapid move back where the axis started.  You can open a probe file and it will store the axis values in that file automatically.  The file location needs double backslashes.   'C:\\Mach4Hobby\\\GcodeFiles\\"filename.csv"' for example  close the probe file when done.

I tried to use a copy of one of the functions from the probe module and it worked but would not work from a do loop.

Offline gorf23

*
  •  183 183
    • View Profile
Re: Mach4 ESS Probing Problems
« Reply #2 on: April 05, 2017, 05:31:38 PM »
Put a wxmessagebox in the script to see if you are running thought it...

if plugin not connected you need simulator turned on

if plugin connected turn off simulator..

Just a thought

Re: Mach4 ESS Probing Problems
« Reply #3 on: April 27, 2017, 08:20:30 AM »
The new ESS plugin now supports multiple probes so the G31.1 now works great!
Re: Mach4 ESS Probing Problems
« Reply #4 on: May 11, 2017, 05:08:42 PM »
Mine works great.  I have used the probing screen with no problems.  Now I have written Lua code to probe in a custom program using G31

Put your probe about .1 inches away and issue G31 to probe about .05 beyond at F10. then G90 G91 G0 rapid move back where the axis started.  You can open a probe file and it will store the axis values in that file automatically.  The file location needs double backslashes.   'C:\\Mach4Hobby\\\GcodeFiles\\"filename.csv"' for example  close the probe file when done.

I tried to use a copy of one of the functions from the probe module and it worked but would not work from a do loop.

*******

theinspector..

is any way to send me a copy of your Lua Code to probe using G31.

i was using this code in Mach3, but this code doesn't wor on Mach4

HERE IS THE CODE

CurrentFeed = GetOemDRO(818)
PierceHight = -10.0
ProbeFeed = 1300.0

Code "G90 F" &ProbeFeed

If GetOemLed(825) = 0 Then
Code "G31 Z-117 F" &ProbeFeed

While IsMoving()
Wend

Code "G4 P0.25"

ZprobePos = GetVar(2002)

Message "ProbePos is " &ZprobePos


Code "G0 Z" &ZprobePos
While IsMoving()
Wend

Call SetDRO(2,PierceHight)

While IsMoving()
Wend


Code "G4 P0.6"
Code "G0 Z 0"
Code "G92 Z0.0"

Message "Z at Pierce Hight   " & ZprobePos

Code "F" & CurrentFeed
StartTHC()
ZeroTHC()
Else
Code "(ERROR. Plate is Grounded)"
GotoSafeZ()
Exit Sub
End If   

Thanks for your help
Best Regards
Felipe

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 ESS Probing Problems
« Reply #5 on: May 13, 2017, 03:58:40 AM »
Quote
is any way to send me a copy of your Lua Code to probe using G31.

One of the most easiest methods is to use something like
Code: [Select]
mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-5 F25")
DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 ESS Probing Problems
« Reply #6 on: May 14, 2017, 07:14:23 AM »
Hope this helps

thespindoctor, Keith

Code: [Select]

----------------------
--CHECK diameter of a grinding WHEEL
--I have a grinding wheel in the chuck of a Z axis spindle motor.  It is moving toward a switch.
--  The switch is wired as a second probe in my setup
--    so I am using G31.1  It you are only using a single probe then use G31
--This program is to help learn how to probe as well as some basics of using Lua in Mach4
--I am just learning as well and I hope this can help other Mach4 users
----------------------

local inst = mc.mcGetInstance();

wx.wxMessageBox("Ready for zeroing all axes?")

--xero all axes
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Y0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 X0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Z0.0")

--this path business is TRICKY   notice the double \\ and the .. 
--the path that the Lua code sees will be c:\Mach4Hobby\GcodeFiles\KFCProbeWheel.csv
--notice the formatting  the probing routine will automatically load the probe file
-- with coordinates of the probe eg.: -.4657,-.8949,9.000

local path = wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheel.csv"--this file is where I store the probed coordinates of the grinding wheel
mc.mcCntlProbeFileOpen(inst, path, "%.4AXIS_X,%.4AXIS_Y,%.4AXIS_Z", true);

---------Set up for 31.1 only  Using probe #2
local ProbeCode=31.1

------------- Check Probe -------------
--This is the function from the probing module Called CheckProbe that I just copied, renamed and put in my screen load script
-- it is not really mandatory to use this but it checks to see which probe and if the probe is working properly
-- to find the source look at the mcProbing.lua file in the Modules directory.  Look for the function called Probing.CheckProbe

local rc = KFCCheckProbe(1, ProbeCode); if not rc then; do return end; end

--move to set position near limit switch to check diameter
    rc=mc.mcCntlGcodeExecuteWait(inst,"G90 G01 X-.3652 Z-.6170 Y-.25 F30.0")
        mm.ReturnCode(rc)
        rc = KFCCheckProbe(1, ProbeCode); if not rc then; do return end; end

-- probe 31.1 for probe1 (limit switch which is the SECOND probe in my system)
-- Mach4 - IMPORTANT TO REALIZE THAT Mach4 USES "probe" for the first probe.  If you have a second probe it will be "probe1")   
-- G31 or G31.0 if you have a single probe.  G31.1 for the second probe called probe1, G31.2 for a third probe called probe2)

rc=mc.mcCntlGcodeExecuteWait(inst,"G31.1 Y-.525 F10.0")
        mm.ReturnCode(rc)
        rc = KFCCheckProbe(0, ProbeCode); if not rc then; do return end; end

--the probing routine places the machine coordinates in these #variables  5071 for x, 5072 for y, 5073 for z
local ProbedMeasXAbs1 = mc.mcCntlGetPoundVar(inst, 5071)
local ProbedMeasYAbs1 = mc.mcCntlGetPoundVar(inst, 5072)
local ProbedMeasZAbs1 = mc.mcCntlGetPoundVar(inst, 5073)

--position near the switch and aligned with the switch so it can probe
mc.mcCntlGcodeExecuteWait(inst,"G91G01 Y.05 F10.0")
mc.mcCntlGcodeExecuteWait(inst,"G90")

    mc.mcCntlSetLastError(inst,string.format("%1.4f:%1.4f:%1.4f",ProbedMeasXAbs1,ProbedMeasYAbs1,ProbedMeasZAbs1))

--I am putting the coordinates into the registry file
-- write to ireg0 in register
WriteRegister("Probe2XWheel",ProbedMeasXAbs1)
WriteRegister("Probe2YWheel",ProbedMeasYAbs1)
WriteRegister("Probe2ZWheel",ProbedMeasZAbs1)

--move all axes to zero
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Y0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 X0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Z0.0")

 --close the probe file   
mc.mcCntlProbeFileClose(inst)




Re: Mach4 ESS Probing Problems
« Reply #7 on: May 15, 2017, 01:57:59 PM »
DazTheGas

Thanks for your answer.

If you see this video you can understand what i need.

https://www.youtube.com/watch?v=ZwK58aWHsHQ

In Mach 3 i can do that, but in Mach 4 it doesn work, is my firts time using lua. if you read the post i paste a copy of my Vb script, work perfect in Mach 3, you say ONE OF THE EASIEST METHODS IS TO USE SOMETHING LIKE..

mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-5 F25")

My question is.. With only ONE line in lua, do the same, like the Mach 3 script what i paste.

PD. sorry for my English
Re: Mach4 ESS Probing Problems
« Reply #8 on: May 15, 2017, 08:56:29 PM »
Study the code I have given you earlier.  There is no shortcut to learning Lua but it will do the same thing as you have written in basic.  You can go line by line to translate what you did in Mach3 to Lua in Mach 4.  It seems difficult at first. I realize now looking back to where I was when I was asking the same questions you are, that it was worth the effort.
Re: Mach4 ESS Probing Problems
« Reply #9 on: May 16, 2017, 12:17:31 PM »
Thanks thespindoctor..  im reading and trying to understand your code... i hope solve this problem soon..

Felipe