Hello Guest it is April 19, 2024, 11:03:17 PM

Author Topic: Custom Auto Calibrate script  (Read 1980 times)

0 Members and 1 Guest are viewing this topic.

Custom Auto Calibrate script
« on: January 21, 2017, 01:25:35 PM »
Hello I posted this question in another section but no luck.  I want to be able to calibrate two axis at once in mach3 using the auto-calibration feature but it only allows one axis at a time. I need it to move the Y axis and its slave axis at the same time (B). Below is the file that runs the script but I am not sure what to tweak. So I am hoping someone can help me.

Sub Main()
 Begin Dialog GroupSample 31,32,120,96,"Axis Selection"
   OKButton 38,75,40,14
   GroupBox 12,8,96,62,"Pick Axis to Calibrate",.GroupBox1
   OptionGroup .OptionGroup1
   OptionButton 20,24,40,8,"X Axis",.OptionButton1
   OptionButton 20,40,40,8,"Y Axis",.OptionButton2
   OptionButton 20,56,40,8,"Z Axis",.OptionButton3
   OptionButton 67,24,40,8,"A Axis",.OptionButton4
   OptionButton 67,40,40,8,"B Axis",.OptionButton5
   OptionButton 67,56,40,8,"C Axis",.OptionButton6
End Dialog



Dim Dlg1 As GroupSample
Button = Dialog (Dlg1)
 If Button = 0 Then
    Exit Sub
 End If   
AxisNum = Dlg1.OptionGroup1

Select Case AxisNum
      Case 0 'HSS
        Axis = "StepsPerAxisX"
        Axis_Letter = "X"
      Case 1 'HSStin
        Axis = "StepsPerAxisY"
   Axis_Letter =" Y"
      Case 2 'Carbide
        Axis = "StepsPerAxisZ"
   Axis_Letter = "Z"
      Case 3 'Carbide
        Axis = "StepsPerAxisA"
   Axis_Letter = "A"
      Case 4 'Carbide
        Axis = "StepsPerAxisB"
   Axis_Letter = "B"
      Case 5 'Carbide
        Axis = "StepsPerAxisC"
   Axis_Letter = "C"
End Select





Com_Move = Question ("How far would you like to Move the " & Axis_Letter & " Axis?")

If COM_Move = 0 Then
  MsgBox "Can't have a Move of Zero, Axis Calc aborted."
  Exit Sub
End If
Code "G0 G91 " & Axis_Letter & Com_Move
 While Ismoving()
 Wend
Code("G90")
Code "G4 P0.5"
Act_Move = Question("How far did the " & Axis_Letter & " Axis move? (Measured Value)")
If Act_Move = 0 Then
  MsgBox "Can't have a Move of Zero, Axis Calc aborted."
  Exit Sub
End If


Old_PPR = GetParam(Axis)

New_PPR = Abs((Com_Move/Act_Move) * Old_PPR)
Response =  MsgBox ( Axis_Letter & " Axis Will be Set to " & New_PPR & " Steps per Unit. Would you like to Accept it??", 4 , "Set Steps Per Unit")
If Response = 6 Then   ' User chose Yes.
   Call SetParam(Axis, New_PPR)
   MsgBox (Axis_Letter & " Axis Has Been Set")
Else   ' User chose No.
   MsgBox (Axis_Letter & " Axis Has NOT Been Set")
End If

End Sub
Main