Hello Guest it is June 21, 2025, 08:22:30 PM

Recent Posts

Pages: « 1 2 3 4 5 6 7 8 9 10 »
11
Hi,
Here is my code for to avoid var(2002) issues on cheap controllers. (mine is a WixHC MKX-ET https://www.wixhc.com/en/pc/243.html).
  • Run a first rough probing with G31,
  • Move back up step by step until loosing contact,
  • Move down small step by small step to find the exact touch point.
The code is used on 4 different macros:
M1001 is TOOL LENGTH PROBE
M1002 is SET JOB Z ZERO
M1003 is TOOL CHANGE
M1004 is REF TOOL OFFSET

The code uses VB and DROs more than G-CODE. Most of the calculation are based on Machine Coordinates to avoid mistakes.
It's adapted to both imperial and metric systems.
Custom DROs are based on DarkScreen screenset, that I had to adapt a little bit.
You can find it all in the zip file and code is shown below.

Code: [Select]
' M1001
' TOOL LENGTH PROBE Macro with workaround concerning G31 limitations on chinese controlers
' Base code written by Big-Tex May 25 2010
' Mod David Marmilloud 06/2025 version 2025-0617.1 to work woith "DarkScreen DPD MM 23 03 27"
' https://www.machsupport.com/forum/index.php?topic=41912.60

InitialFeed = GetOemDRO(818) 'get the Initial feedrate to return to later
InitialAbsInc = GetOemLED(48) 'Get the Initial G90/G91 state
InitialWorkZ = GetOEMDRO(180) 'Get the Initial WORK Z position

Main

Sub Main()
'//////// Unit dependent parameters
If GetOEMLED(801) Then 'if unit is imperial (inches)
FirstProbeFeed = 8 'Approach Probe Feed Speed
SecondProbeFeed = 1 'Slow Probe Feed Speed
ProbeDepth = 10 'probing Depth
Res = 0.001 'set the measurement resolution
Else 'if unit is metric
FirstProbeFeed = 200.0 'Approach Probe Feed Speed
SecondProbeFeed = 30.0 'Slow Probe Feed Speed
ProbeDepth = 190 'Probing Depth
Res = 0.01 'set the measurement resolution
End If

'//////// Error Condition checking code
If GetOEMLED(16) Then 'Checks for machine coordinates
DoOEMButton(256) 'toggle to program coordinates
End If

If GetOEMLED(825)<>0 Then 'check probe first see if it is grounded
Code "(Probe Grounded, check connection and try again)" 'Status Bar display
End 'ERROR! exit the macro
End if

If GetOEMLED(807) or GetOEMLED(808) or GetOEMLED(809) Then 'Check all axes have been referenced
Code "(Ref all axis prior to Zero Z)" 'Status Bar display
End 'ERROR! exit the macro
End If

'//////// Get Tool change, and Tool measurement positions
ToolLoadXPos = GetOEMDRO(1150) 'Get tool load X position
ToolLoadYPos = GetOEMDRO(1151) 'Get tool load Y position
ToolLoadZPos = GetOEMDRO(1152) 'Get tool load Z position

ToolSensorXPos = GetOEMDRO(1006) 'Get Tool probe X position
ToolSensorYPos = GetOEMDRO(1007) 'Get Tool probe Y position

RefToolZOffset = GetOEMDRO(1008) 'Get Z offset, corresponding to REF tool Z position

'//////// Move to probe position
Code "G90 G0 G53 Z" & getOEMDRO(54) 'Move to Safe Z
Code "G90 G0 G53 X" & ToolSensorXPos & "Y" & ToolSensorYPos 'Move to Tool sensor position

'//////// Probing, first using G31, then refining with iterative method
Code "G4 P1" 'pause 1 seconds to give time to position probe plate
Code "F" & FirstProbeFeed 'First approach feedrate using G31
Code "(Probing)"
Code "G91 G31 Z-" & ProbeDepth 'probe move to probedepth - First travel
While IsMoving() 'wait for probe move to finish
Wend
Code "(1st touch)"

Code "F" & SecondProbeFeed 'set slow feedrate

ProbedZABS = GetZ(Res*10) 'Probing up to Low signal as Low res
ProbedZABS = GetZ(-Res) 'Probing down to High signal at High Res

ToolNumber = GetOEMDRO(824) 'get tool number

If ToolNumber <> 0 Then 'if not ref tool
Tool_Offset = ProbedZABS - RefToolZOffset 'Offset = This tool sensed position - Ref tool sensed positon
Call setOEMDRO(42, Tool_Offset) 'write it to current tool offset DRO
Code "G4 P.25" 'pause for Dro to update.
Code "(Tool #" & Tool_Num & " Offset is now set to" & ToolOffset &")"
Else 'if tool is ref tool
Ret = MachMsg("Ref Tool is active" & Chr(13) & Chr(10) & "Press OK to set Spindle Z offset," & Chr(13) & Chr(10) & "otherwise press CANCEL to abort", "WARNING", 1)
If Ret = 1 Then 'If answered OK
Call setOEMDRO(1008, ProbedZABS)'write sensed ABS position to Tool Setter Z offset
Code "G4 P.25" 'pause for Dro to update.
Code "(Ref tool is set ans stored on Settings Screen - Tool Setter coordinates Z)"
Else 'if answerd CANCEL
Code "(Set up canceled)"
RestoreInit
End If
End If

RestoreInit 'restore initial conditions

End Sub

Function GetZ(ResStep) As Double
'//////// Start Probing Code, Probe In -Z direction.
'//////// The vars will be Inch or Metric from above if/else statment

PlateOffset = GetOEMDRO(1001) 'get plate offset DRO
InitialContact = GetOEMLED(825) 'get probe contact state
i=0

Code "(Refining contact by " & ResStep & " step)"
While GetOEMLED(825)=InitialContact
'as long as the limit switch is ON
Code "G91 G1 Z" & ResStep 'move one step
While IsMoving() 'wait for probe move to finish
Wend
i = i+1 'count steps
If i=30 Then 'If probe moved more than 20 steps without switching
Code "(Can't reach the sensor. ABORTED)" 'ERROR!
RestoreInit 'restore initial conditions
End 'End the program
End If
Wend 'loop

Code "(Got it)"
Code "G4 P.25" 'pause for Dro to update.
GetZ = GetOEMDRO(85) - PlateOffset 'Return new touch point in Machine coordinates

End Function

Sub RestoreInit()
'////////// restoring initial conditions
Code "G90 G0 Z" & InitialWorkZ 'Move to initial work Z position
While IsMoving() 'wait for probe move to finish
Wend

If InitialAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
Else
Code "G90"
End If

Call SetOEMDRO(818, InitialFeed) 'restore feed rate
End Sub

Code: [Select]
' M1002
' SET JOB Z ZERO Macro with workaround concerning G31 limitations on chinese controlers
' Base code written by Big-Tex May 25 2010
' Mod David Marmilloud 03/2025 version 2025-0617.1 to work woith "DarkScreen DPD MM 23 03 27"
' https://www.machsupport.com/forum/index.php?topic=41912.60

InitialFeed = GetOemDRO(818) 'get the Initial feedrate to return to later
InitialAbsInc = GetOemLED(48) 'Get the Initial G90/G91 state
InitialAbsX = GetOEMDRO(83) 'Get the Initial MACHINE X position
InitialAbsY = GetOEMDRO(84) 'Get the Initial MACHINE Y position
InitialAbsZ = GetOEMDRO(85) 'Get the Initial MACHINE Z position
InitialWorkZ = GetOEMDRO(180) 'Get the Initial WORK Z position

Main

Sub Main()

InitialFeed = GetOemDRO(818) 'get the Initial feedrate to return to later
InitialAbsInc = GetOemLED(48) 'Get the Initial G90/G91 state
InitialAbsZ = GetOEMDRO(85) 'Get the Initial Z position
CurrentTLO = GetOEMDRO(42) 'Get the current tool length offset

'//////// Unit dependent parameters
If GetOEMLED(801) Then 'if unit is imperial (inches)

FirstProbeFeed = 8 'Approach Probe Feed Speed
SecondProbeFeed = 1 'Slow Probe Feed Speed
ProbeDepth = 2 'probing Depth
Res = 0.001 'set the measurement resolution
Else 'if unit is metric
FirstProbeFeed = 50.0 'Approach Probe Feed Speed
SecondProbeFeed = 10.0 'Slow Probe Feed Speed
ProbeDepth = 20 'Probing Depth
Res = 0.01 'set the measurement resolution

End If

'//////// Error Condition checking code

If GetOEMLED(16) Then 'Checks for machine coordinates
DoOEMButton(256) 'toggle to program coordinates
End If

If GetOEMLED(825)<>0 Then 'check probe first see if it is grounded
Code "(Probe Grounded, check connection and try again)" 'Status Bar display
End 'ERROR! exit the macro
End if

If GetOEMLED(807) or GetOEMLED(808) or GetOEMLED(809) Then 'Check all axes have been referenced
Code "(Ref all axis prior to Zero Z)" 'Status Bar display
End 'ERROR! exit the macro
End If

'//////// Probing, first using G31, then refining with iterative method

Code "G4 P1" 'pause 1 seconds to give time to position probe plate
Code "F" & FirstProbeFeed 'First approach feedrate using G31
Code "(Probing)"
Code "G91 G31 Z-" & ProbeDepth 'probe move to probedepth - First travel
While IsMoving() 'wait for probe move to finish
Wend
Code "(1st touch)"

Code "F" & SecondProbeFeed 'set slow feedrate

ProbedZABS = GetZ(Res*10) 'Probing up to Low signal as Low res
ProbedZABS = GetZ(-Res) 'Probing down to High signal at High Res
PartZOffset = ProbedZABS - CurrentTLO 'Part Z Offset = Probed Z ABS value - Tool Length Offset

Call SetOEMDRO (49, - GetOEMDRO(49)) 'Reset the Work Z offset (it's a workaround, because this DRO acts strange : it adds typed values instead of replacing them)
Call SetOEMDRO (49, PartZOffset) 'Job Z zero = Current MachineABS position - MachineABS probed point)
Code "G4 P.25" 'pause for Dro to update.
Code"(Z axis is zeroed for this job)"

RestoreInit 'Restore initial conditions

End Sub

Function GetZ(ResStep) As Double
'//////// Start Probing Code, Probe In -Z direction.
'//////// The vars will be Inch or Metric from above if/else statment

PlateOffset = GetOEMDRO(1161) 'get plate offset DRO
InitialContact = GetOEMLED(825) 'get probe contact state
i=0

Code "(Refining contact by " & ResStep & " step)"
While GetOEMLED(825)=InitialContact
'as long as the limit switch is ON
Code "G91 G1 Z" & ResStep 'move one step
While IsMoving() 'wait for probe move to finish
Wend
i = i+1 'count steps
If i=30 Then 'If probe moved more than 20 steps without switching
Code "(Can't reach the sensor. ABORTED)" 'ERROR!
RestoreInit 'Restore initial conditions
End 'End the program
End If
Wend 'loop

Code "(Got it)"
Code "G4 P.25" 'pause for Dro to update.
GetZ = GetOEMDRO(85) - PlateOffset 'store new touch point in Machine coordinates

End Function

Sub RestoreInit()
'////////// restoring initial conditions
'Code "G90 G0 G53 Z" & getOEMDRO(54) 'Move to Safe Z
'Code "G90 G0 G53 X" & InitialAbsX & "Y" & InitialAbsY 'Move to initial position
Code "G90 G0 G53 Z" & InitialAbsZ 'Move to initial Z position - Be carefull before uncomment. if tool is longer than previous, you migth crash
'Code "G90 G0 Z" & InitialWorkZ 'Move to initial work Z position
While IsMoving() 'wait for probe move to finish
Wend

If InitialAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
Else
Code "G90"
End If

Call SetOEMDRO(818, InitialFeed) 'restore feed rate
End Sub


Code: [Select]
' M1003
' TOOL CHANGE Macro with workaround concerning G31 limitations on chinese controlers
' Base code written by Big-Tex May 25 2010
' Mod David Marmilloud 03/2025 version 2025-0617.1 to work woith "DarkScreen DPD MM 23 03 27"
' https://www.machsupport.com/forum/index.php?topic=41912.60

InitialFeed = GetOemDRO(818) 'get the Initial feedrate to return to later
InitialAbsInc = GetOemLED(48) 'Get the Initial G90/G91 state
InitialAbsX = GetOEMDRO(83) 'Get the Initial MACHINE X position
InitialAbsY = GetOEMDRO(84) 'Get the Initial MACHINE Y position
InitialAbsZ = GetOEMDRO(85) 'Get the Initial MACHINE Z position
InitialWorkZ = GetOEMDRO(180) 'Get the Initial WORK Z position

Main

Sub Main()
'//////// Unit dependent parameters
If GetOEMLED(801) Then 'if unit is imperial (inches)
FirstProbeFeed = 8 'Approach Probe Feed Speed
SecondProbeFeed = 1 'Slow Probe Feed Speed
ProbeDepth = 10 'probing Depth
Res = 0.001 'set the measurement resolution
Else 'if unit is metric
FirstProbeFeed = 200.0 'Approach Probe Feed Speed
SecondProbeFeed = 30.0 'Slow Probe Feed Speed
ProbeDepth = 190 'Probing Depth
Res = 0.01 'set the measurement resolution
End If

'//////// Error Condition checking code
If GetOEMLED(16) Then 'Checks for machine coordinates
DoOEMButton(256) 'toggle to program coordinates
End If

If GetOEMLED(825)<>0 Then 'check probe first see if it is grounded
Code "(Probe Grounded, check connection and try again)" 'Status Bar display
End 'ERROR! exit the macro
End if

If GetOEMLED(807) or GetOEMLED(808) or GetOEMLED(809) Then 'Check all axes have been referenced
Code "(Ref all axis prior to Zero Z)" 'Status Bar display
End 'ERROR! exit the macro
End If

'//////// Get Tool change, and Tool measurement positions
ToolLoadXPos = GetOEMDRO(1150) 'Get tool load X position
ToolLoadYPos = GetOEMDRO(1151) 'Get tool load Y position
ToolLoadZPos = GetOEMDRO(1152) 'Get tool load Z position

ToolSensorXPos = GetOEMDRO(1006) 'Get Tool probe X position
ToolSensorYPos = GetOEMDRO(1007) 'Get Tool probe Y position

RefToolZOffset = GetOEMDRO(1008) 'Get Z offset, corresponding to REF tool Z position

'//////// Move to tool position
Code "G90 G0 G53 Z" & getOEMDRO(54) 'Move to Safe Z
Code "G90 G0 G53 X" & ToolLoadXPos & "Y" & ToolLoadYPos 'Move to Tool load position
Code "G90 G0 G53 Z" & ToolLoadZPos 'Move to Z load position
While IsMoving() 'wait for move to finish
Wend

ToolNumber = GetOEMDRO(824) 'get tool number

If MachMsg("Change the tool to #" & ToolNumber & Chr(13) & Chr(10) & "Press OK when done, CANCEL to go skip probing", "MANUAL TOOL CHANGE", 1)=2 then
End 'Exit the macro if probing is unwanted
End if

'//////// Move to probe position
Code "G90 G0 G53 Z" & getOEMDRO(54) 'Move to Safe Z
Code "G90 G0 G53 X" & ToolSensorXPos & "Y" & ToolSensorYPos 'Move to Tool sensor position

'//////// Probing, first using G31, then refining with iterative method
Code "G4 P1" 'pause 1 seconds to give time to position probe plate
Code "F" & FirstProbeFeed 'First approach feedrate using G31
Code "(Probing)"
Code "G91 G31 Z-" & ProbeDepth 'probe move to probedepth - First travel
While IsMoving() 'wait for probe move to finish
Wend
Code "(1st touch)"

Code "F" & SecondProbeFeed 'set slow feedrate

ProbedZABS = GetZ(Res*10) 'Probing up to Low signal as Low res
ProbedZABS = GetZ(-Res) 'Probing down to High signal at High Res

If ToolNumber <> 0 Then 'if not ref tool
Tool_Offset = ProbedZABS - RefToolZOffset 'Offset = This tool sensed position - Ref tool sensed positon
Call setOEMDRO(42, Tool_Offset) 'write it to current tool offset DRO
Code "G4 P.25" 'pause for Dro to update.
Code "(Tool #" & Tool_Num & " Offset is now set to" & ToolOffset &")"
Else 'if tool is ref tool
Ret = MachMsg("Ref Tool is active" & Chr(13) & Chr(10) & "Press OK to set Spindle Z offset," & Chr(13) & Chr(10) & "otherwise press CANCEL to abort", "WARNING", 1)
If Ret = 1 Then 'If answered OK
Call setOEMDRO(1008, ProbedZABS)'write sensed ABS position to Tool Setter Z offset
Code "G4 P.25" 'pause for Dro to update.
Code "(Ref tool is set ans stored on Settings Screen - Tool Setter coordinates Z)"
Else 'if answerd CANCEL
Code "(Set up canceled)"
RestoreInit
End If
End If

RestoreInit 'restore initial conditions

End Sub

Function GetZ(ResStep) As Double
'//////// Start Probing Code, Probe In -Z direction.
'//////// The vars will be Inch or Metric from above if/else statment

PlateOffset = GetOEMDRO(1001) 'get plate offset DRO
InitialContact = GetOEMLED(825) 'get probe contact state
i=0

Code "(Refining contact by " & ResStep & " step)"
While GetOEMLED(825)=InitialContact
'as long as the limit switch is ON
Code "G91 G1 Z" & ResStep 'move one step
While IsMoving() 'wait for probe move to finish
Wend
i = i+1 'count steps
If i=30 Then 'If probe moved more than 20 steps without switching
Code "(Can't reach the sensor. ABORTED)" 'ERROR!
RestoreInit 'restore initial conditions
End 'End the program
End If
Wend 'loop

Code "(Got it)"
Code "G4 P.25" 'pause for Dro to update.
GetZ = GetOEMDRO(85) - PlateOffset 'Return new touch point in Machine coordinates

End Function

Sub RestoreInit()
'////////// restoring initial conditions
'Code "G90 G0 G53 Z" & getOEMDRO(54) 'Move to Safe Z
'Code "G90 G0 G53 X" & InitialAbsX & "Y" & InitialAbsY 'Move to initial position
'Code "G90 G0 G53 Z" & InitialAbsZ 'Move to initial Z position - Be carefull before uncomment. if tool is longer than previous, you migth crash
Code "G90 G0 Z" & InitialWorkZ 'Move to initial work Z position
While IsMoving() 'wait for probe move to finish
Wend

If InitialAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
Else
Code "G90"
End If

Call SetOEMDRO(818, InitialFeed) 'restore feed rate
End Sub
12
General Mach Discussion / Cycle time display
« Last post by lcs226 on June 18, 2025, 02:57:32 PM »
My cycle timer display window shows all zero's . Where is this display fed from? I have looked to see if there is a register that feeds it but could not find anything, or don't know what to look for.

Tks
13
PoKeys / MACH4 dev + Latest pokeys + Laser
« Last post by dedlefou on June 16, 2025, 04:34:15 PM »
Hello,

What dev version above 4.2.0.5325 is very stable ? I dont know how the versionning works for mach4.
The regular version is very stable but too old to manage the laser feature of the pokeys57cnc.

I installed the very latest dev (5920) version but it's almost unusable :(
Any version know to be stable ?

thx
14
General Mach Discussion / Re: Best controller for Mach3
« Last post by JohnHaine on June 16, 2025, 02:24:51 PM »
Did you make sure to buy genuine ones?  There are apparently clones around - best to buy from a genuine CNCDrive stockist.  Where are you based?

Did you download/install the plugin for the device, and configure it?

Can you tell us what steps you have followed to configure mach 3?  I found that most of the settings I was using for the parallel port carried across directly.
15
General Mach Discussion / Re: Best controller for Mach3
« Last post by Michaelc on June 16, 2025, 10:56:55 AM »
Best I have found is a CS-LABS motion controller. However they have become expensive now. But I had one on my milling machine and it just worked from the start. Now I am stuck trying too figure out why the UC100 is not moving the stepper motors.
16
Hi, this is my first go at mach3 turn. And I have a few questions.
1. How do you jog? What buttons do you press.
2. How do you tune the stepper motors in turn, I know it’s different from the milling program, but how do you tune the motors?
3. Is Mach4 turn more intuitive then Mach3 turn which I am finding very hard to get my head around due to lack of basic information.
17
General Mach Discussion / Re: UC100 problems
« Last post by Michaelc on June 16, 2025, 07:49:11 AM »
Hi, I had a phone call back from the UC100 supplier and he explained that I had to install Microsoft Net 3.5 to get the UC100 to function. I did that and it did clear the problem.
18
General Mach Discussion / Re: UC100 problems
« Last post by Tweakie.CNC on June 16, 2025, 07:03:21 AM »
Could be that you need to install .Net Framework 2.0.
The full instructions for for the UC100 are here; https://cncdrive.com/UC100.html

Tweakie.
19
General Mach Discussion / UC100 problems
« Last post by Michaelc on June 16, 2025, 05:21:12 AM »
Hi, I am having problems with the UC100 I purchased from a well respected dealer here in the U.K. I am running windows 10 on a pc free of any other software bar a new install of mach3. I run the UC100 install software for Mach3. However on starting Mach3 I get the error message stating that the DLL files are corrupted and not working. I can get no further.
I have uninstalled, and reinstalled countless times with no joy. All the pc safe guards are turned off. Anyone know what is going on here, and what is the answer. Thanks ps, I do have a green led light showing in the UC100, but nothing in the Mach3 plug in section.
20
*****VIDEOS***** / Re: Greetings from Tokyo
« Last post by myoshii on June 15, 2025, 02:05:56 AM »
Thanks as always, Tweakie.
Pages: « 1 2 3 4 5 6 7 8 9 10 »