Hello Guest it is June 22, 2025, 01:56:33 AM

Author Topic: macro help to reference machine  (Read 186 times)

0 Members and 1 Guest are viewing this topic.

macro help to reference machine
« on: June 20, 2025, 05:24:55 AM »
macro help to reference machine

Good morning I have this macro generated with ChatGPT to reference the machine and it works well I ask if it could be
modified in two touches (the first fast the second slow to be precise) with AI I can't modify it, it's not in my
capacities / skills I ask if someone can help me to modify it or if there is a macro already made.
I thank those who can help me.

' === Macro Mach3 per Referenziare la Macchina CNC ===
' Esegue homing su X, Y e Z e azzera le coordinate macchina

' Homing Asse Z (di solito prima per sicurezza)
DoButton(22)

While IsMoving()
    Sleep(100)
Wend

' Homing Asse Y
DoButton(23)

While IsMoving()
    Sleep(100)
Wend

' Homing Asse X
DoButton(24)

While IsMoving()
    Sleep(100)
Wend

' Homing Asse A
DoButton(25)

While IsMoving()
    Sleep(100)
Wend
' Imposta le coordinate macchina a zero (opzionale)
'DoOEMButton(1008) ' Azzera X
'DoOEMButton(1009) ' Azzera Y
'DoOEMButton(1010) ' Azzera Z

MsgBox "Homing completato con successo!"

   

Offline TPS

*
  •  2,593 2,593
Re: macro help to reference machine
« Reply #1 on: June 20, 2025, 01:27:54 PM »
something like this, not tested just written down:

Code: [Select]
' === Macro Mach3 per Referenziare la Macchina CNC ===
' Esegue homing su X, Y e Z e azzera le coordinate macchina

' Homing Asse Z (di solito prima per sicurezza)
SetParam ("ZRefPer",40) 'set Z refspeed to 40%
Sleep 200
DoButton(24) 'Ref Z-axis fast

While IsMoving()
Sleep(100)
Wend

Code "G53 Z-2"  'move off switch 2mm
While IsMoving()
Sleep(100)
Wend

SetParam ("ZRefPer",5) 'set Z refspeed to 5%
DoButton(24) 'Ref Z-axis slow

While IsMoving()
Sleep(100)
Wend
SetParam ("ZRefPer",100)
Sleep 200

' Homing Asse Y
SetParam ("YRefPer",40) 'set Y refspeed to 40%
Sleep 200
DoButton(23) 'Ref Y-axis fast

While IsMoving()
Sleep(100)
Wend

Code "G53 Y2"  'move off switch 2mm
While IsMoving()
Sleep(100)
Wend

SetParam ("YRefPer",5) 'set Y refspeed to 5%
DoButton(23) 'Ref Y-axis slow

While IsMoving()
Sleep(100)
Wend
SetParam ("YRefPer",100)
Sleep 200

' Homing Asse X
SetParam ("XRefPer",40) 'set X refspeed to 40%
Sleep 200
DoButton(22) 'Ref X-axis fast

While IsMoving()
Sleep(100)
Wend

Code "G53 X2"  'move off switch 2mm
While IsMoving()
Sleep(100)
Wend

SetParam ("XRefPer",5) 'set X refspeed to 5%
DoButton(22) 'Ref Z-axis slow

While IsMoving()
Sleep(100)
Wend
SetParam ("XRefPer",100)
Sleep 200


' Homing Asse A
SetParam ("ARefPer",40) 'set A refspeed to 40%
Sleep 200
DoButton(25) 'Ref A-axis fast

While IsMoving()
Sleep(100)
Wend

Code "G53 A2"  'move off switch 2mm
While IsMoving()
Sleep(100)
Wend

SetParam ("ARefPer",5) 'set A refspeed to 5%
DoButton(25) 'Ref A-axis slow

While IsMoving()
Sleep(100)
Wend
SetParam ("ARefPer",100)
Sleep 200

' Imposta le coordinate macchina a zero (opzionale)
'DoOEMButton(1008) ' Azzera X
'DoOEMButton(1009) ' Azzera Y
'DoOEMButton(1010) ' Azzera Z

MsgBox "Homing completato con successo!"
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro help to reference machine
« Reply #2 on: June 20, 2025, 02:57:54 PM »
ok TPS i tried it and it seems to work fine
i changed:
SetParam ("ZRefPer",5) 'set Z refspeed to 5%
to
SetParam ("ZRefPer",3) 'set Z refspeed to 5%
to lower the speed and it seems to work
thanks again for the help offered
regards