Autoleveller and Mach 3 + BL-UsbMach-V22

Help for setting up and using
Post Reply
aislanmds
Posts: 1
Joined: Mon May 18, 2020 10:33 pm

Autoleveller and Mach 3 + BL-UsbMach-V22

Post by aislanmds »

Good evening for all.
I did some research here on the forum, but I couldn't solve my problem with Autoleveller. I saw that several users had problems with the Autoleveller and USB Card.

I'm using a Chinese USB card, and controller BL-UsbMach-V22.dll I'm having trouble probing the plate. I did a test using 2-stage to be able to view the log file, and on all lines it has the same information as the x, y, z coordinate.

I appreciate any help.

Thank you.

.nc File:
(This GCode script was designed to adjust the Z height of a CNC machine according)
(to the minute variations in the surface height in order to achieve a better result in the milling/etching process)
(This script is the output of AutoLevellerAE, 0.9.5u2 Changeset: ...2d0387 @ http://autoleveller.co.uk)
(Author: James Hawthorne PhD. File creation date: 17-05-2020 12:56)
(This program and any of its output is licensed under GPLv2 and as such...)
(AutoLevellerAE comes with ABSOLUTELY NO WARRANTY; for details, see sections 11 and 12 of the GPLv2 @ http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)

(The following is a checklist which can be used before the probe routine starts)
(The checklist may not be entirely correct given your machine, therefore you should make your own adaptations as appropriate)
(1. Make sure wires/clips are attached and the probe is working correctly)
(Test probe connections within control software before starting)
(2. Home all axis)
(3. Load GCode file that contains the probe routine into your software controller)
(4. Jog tool tip close to surface and touch off Z)
(5. Jog Z up a fraction to make sure surface is cleared)
(6. Jog to and touch off X and Y at the desired bottom left corner of the probe area)
(Note: The first probe will touch off Z to 0.0 when it first touches to the surface,)
(all other probe values are relative to this first point)

G90 G21 S20000 G17

M0 (Attach probe wires and clips that need attaching)
(Initialize probe routine)
G0 Z5 (Move clear of the board first)
G1 X0.27 Y0.27 F2500 (Move to bottom left corner)
G0 Z2 (Quick move to probe clearance height)
G4P1
G31 Z-15 F100 (Probe to a maximum of the specified probe height at the specified feed rate)
M2002
G92 Z0 (Touch off Z to 0 once contact is made)
M100
G0 Z2 (Move Z to above the contact point)
G4P1
G31 Z-15 F50 (Repeat at a more accurate slower rate)
M2002
G92 Z0
M100
G0 Z2

M40
G0 Z2
G1 X0.27 Y0.27 F2500
G4P1
G31 Z-15 F100
M2002
G0 Z2
G1 X10.59667 Y0.27 F2500
G4P1
G31 Z-15 F100
M2002
G0 Z2
G1 X20.92334 Y0.27 F2500
G4P1
G31 Z-15 F100
M2002
G0 Z2
G1 X31.25001 Y0.27 F2500
G4P1
G31 Z-15 F100
M2002
G0 Z2
G1 X41.57668 Y0.27 F2500
G4P1
G31 Z-15 F100
M2002
G0 Z2
G1 X51.90335 Y0.27 F2500
G4P1
G31 Z-15 F100
M2002
G0 Z2
G1 X62.23002 Y0.27 F2500
......
log File:
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
87.08814,52.40875,-21.79750
........
ngochoangimsat
Posts: 1
Joined: Mon Jul 07, 2025 6:50 am

Re: Autoleveller and Mach 3 + BL-UsbMach-V22

Post by ngochoangimsat »

This topic is very old but i will post here for someone, who still need:
Go to Operator -> Edit Button Script -> chose one button which you want to asign script then paste this script. It will work as Autoleveler to creat RPF then you can use this raw probe file in Autoleveler

Code: Select all

Dim AbortFlag
Dim fs, f, filePath
Dim x, y, z
Dim StartingX, StartingY, XWidth, YLength
Dim XYFeed, ZFeed, ProbeDepth, ProbeClearance, PointSpacing, ProbeSafeHeight
Dim xPos, yPos, xEnd, yEnd
Dim logFolder, logFileName
Dim spaceX, spaceY

Sub Main()
    AbortFlag = False

    ' Check if probe is already triggered
    If GetOEMLed(825) Then
        Message "Probe plate is grounded, check connection and try again!"
        MsgBox "Probe plate is grounded, check connection and try again!"
        Exit Sub
    End If

    ' Input parameters
    StartingX = CDbl(InputBox("Input Starting X", "Parameters", "0"))
    StartingY = CDbl(InputBox("Input Starting Y", "Parameters", "0"))
    XWidth = CDbl(InputBox("Input X Width", "Parameters", "50"))
    YLength = CDbl(InputBox("Input Y Length", "Parameters", "50"))
    XYFeed = CDbl(InputBox("Input XY Feed", "Parameters", "300"))
    ZFeed = CDbl(InputBox("Input Z Feed", "Parameters", "100"))
    ProbeDepth = CDbl(InputBox("Input Probe Depth", "Parameters", "-1"))
    ProbeClearance = CDbl(InputBox("Input Probe Clearance", "Parameters", "2"))
    PointSpacing = CDbl(InputBox("Input Point Spacing", "Parameters", "10"))
    ProbeSafeHeight = CDbl(InputBox("Input Probe Safe Height", "Parameters", "15"))

    ' Safety checks
    If Abs(ProbeDepth) > ProbeSafeHeight Then
        MsgBox "Probe depth exceeds safe height! Adjust ProbeDepth."
        Exit Sub
    End If

    If Int(XWidth / PointSpacing) = 0 Or Int(YLength / PointSpacing) = 0 Then
        MsgBox "Point spacing too large compared to probe area!"
        Exit Sub
    End If

    ' Folder selection
    Dim shellApp, folder
    Set shellApp = CreateObject("Shell.Application")
    Set folder = shellApp.BrowseForFolder(0, "Choose folder to save raw probe file", 0, "C:\Mach3\Logs")
    If folder Is Nothing Then
        MsgBox "You did not choose a folder. Exiting."
        Exit Sub
    End If
    logFolder = folder.Self.Path
    If Right(logFolder, 1) <> "\" Then logFolder = logFolder & "\"

    ' File name
    logFileName = InputBox("Input file name (e.g., GridProbeLog.txt)", "Raw Probe File Name", "GridProbeLog.txt")
    filePath = logFolder & logFileName

    ' Calculate grid spacing and end points
    spaceX = XWidth / Int(XWidth / PointSpacing)
    spaceY = YLength / Int(YLength / PointSpacing)
	xEnd = StartingX + (Int(XWidth / PointSpacing) * spaceX)
	yEnd = StartingY + (Int(YLength / PointSpacing) * spaceY)


    ' Open log file
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.OpenTextFile(filePath, 2, True)

    ' Initial setup
    Code "G90 G21"
    GoToZSafe()

    ' Move to starting point
    Code "F" & XYFeed
    Code "G0 X" & StartingX & " Y" & StartingY
    While IsMoving()
        Sleep(100)
    Wend

    ' Initial probing for Z0
    Code "G0 Z" & ProbeClearance
    While IsMoving()
        Sleep(100)
    Wend

    Code "F" & ZFeed
    Code "G31 Z" & ProbeDepth
    While IsMoving()
        Sleep(100)
    Wend
    Sleep(500)
    Call CheckProbe
    If AbortFlag Then GoTo Cleanup

    Code "G92 Z0"
    Code "G0 Z" & ProbeClearance
    While IsMoving()
        Sleep(100)
    Wend

    Code "F" & ZFeed / 2
    Code "G31 Z" & ProbeDepth
    While IsMoving()
        Sleep(100)
    Wend
    Sleep(1000)
    Call CheckProbe
    If AbortFlag Then GoTo Cleanup
    Code "G92 Z0"

    ' Zig-zag probing
    For yPos = StartingY To yEnd Step spaceY
        If ((yPos - StartingY) / spaceY) Mod 2 = 0 Then
            For xPos = StartingX To xEnd Step spaceX
                Call ProbePoint(xPos, yPos)
                If AbortFlag Then GoTo Cleanup
            Next
        Else
            For xPos = xEnd To StartingX Step -spaceX
                Call ProbePoint(xPos, yPos)
                If AbortFlag Then GoTo Cleanup
            Next
        End If
    Next

Cleanup:
    If Not f Is Nothing Then
        f.Close
        Set f = Nothing
    End If
    Set fs = Nothing

    If Not AbortFlag Then
        GoToZSafe()
        MsgBox "Grid probing complete. Log saved at: " & filePath
    End If
End Sub

Sub ProbePoint(xPos, yPos)
    Code "F" & XYFeed
    Code "G0 X" & xPos & " Y" & yPos
    While IsMoving()
        Sleep(100)
    Wend

    Code "G0 Z" & ProbeClearance
    While IsMoving()
        Sleep(100)
    Wend

    Code "F" & ZFeed
    Code "G31 Z" & ProbeDepth
    While IsMoving()
        Sleep(100)
    Wend

    Call CheckProbe
    If AbortFlag Then Exit Sub

    Sleep(1000)
    x = GetDRO(0)
    y = GetDRO(1)
    z = GetDRO(2)
    f.WriteLine(CStr(x) & "," & CStr(y) & "," & CStr(z))

    Code "G0 Z" & ProbeClearance
    While IsMoving()
        Sleep(100)
    Wend
End Sub

Sub GoToZSafe()
    Code("G0 Z" & ProbeSafeHeight)
    While IsMoving()
        Sleep(100)
    Wend
End Sub

Sub CheckProbe()
    If Not GetOEMLed(825) Then
        Call GoToZSafe()
        Message "Probe failed at X=" & GetDRO(0) & " Y=" & GetDRO(1)
        MsgBox "Probe did not trigger properly!"
        AbortFlag = True
    End If
End Sub
Post Reply