Test = false       ' testet December 12/2011, use onely for turn mode                                                              ' do not work in scaling mode ( G51 Z <> +1) (issue in Mach3)EndZ = tEndZ()     ' this is the Z in the G83  , must be included,                                 Q = Abs(tInFeed()) ' Q value , must be included, first peck depth                                     R = tZClear()      ' R value, must be specified                                   A = GetVar(1)      ' last peck depth , must be specifiedB = GetVar(2)      ' Z Start , must be specified                                                         StartZ = tZStart()                                   scaling = GetOemDro(61)  ' look is scaling activeIf scaling <> 1 Then                                 message("scaling active on G83 turn cycle !")MsgBox("scaling active on G83 turn cycle !")Code "M30"EndEnd If                If A > Q ThenMsgBox (" last peck greater first peck ! ")message("last peck greater first peck! ")Call Code("M30")EndEnd If           If A <= 0 ThenMsgBox (" last peck wrong value ! ")message("last peck wrong value ! ")Call Code("M30")EndEnd If                               If EndZ< R Then                 Right_Left = -1                 Else                 Right_Left =  1                 End If                 ZClearance = 0.02                                 If GetLED (2) Then                                   ZClearance = ZClearance * 25.4                                 End If If Right_Left = -1 Then                          ZClearance = ZClearance                                                                   Else ZClearance = ZClearance * Right_Left              End If Code "G00 Z" & R                                   Last_Pass = 0           NCounter = 1                                   Last_Depth = R        If Test = True Then                                    OpenTeachFile( "TestIt.tap")        Code "(R= " & R &")"                    Code "(Z= " & EndZ &")"           Code "(Q= " & Q &")"   Code "(A= " & A &")"   Code "(B= " & B &")"    Code "(Right_Left= " & Right_Left &")"           Code "(Last_Depth= " & Last_Depth &")"              End If           Code "G00 Z" & Last_Depth                   ' --------> start first Peck depth , Q value - ( A value )Do                                    Depth_pass = ( NCounter * Q * Right_Left ) + B                          If Right_Left = -1 ThenIf Depth_pass <= EndZ Then                                               Depth_pass = EndZ                                   Last_Pass = 1                                   End If                                   ElseIf Depth_pass >= EndZ Then                             Depth_pass = EndZ                                   Last_Pass = 1                                   End IfEnd IfCode "G01 Z" & Depth_Pass                                   Last_Depth = Depth_Pass + ZClearance                                                                                                If Last_Depth - ZClearance <> EndZ ThenCode "G00 Z" & REnd If                                                               If Q - (A/2 * NCounter) >= A ThenQ = Q - A/2ElseLast_Pass = 1End IfIf(Last_Pass < 1) ThenCode "G00 Z" & Last_DepthEnd If                                   NCounter = NCounter + 1If NCounter = 300 Then Exit Do                                   Loop While (Last_Pass < 1)   ' ------------------------------------------------------>  start second Peck depth , A valueLast_Pass = 0C = 1 + ( last_Depth * Right_Left / A )              '--- C = Counter 2If Last_Depth - ZClearance = EndZ ThenCode "G00 Z" & StartZIf Test = True Then CloseTeachFile()                   LoadTeachFile()End IfEnd                 End If         Code "G00 Z" & Last_DepthDo  If 1=0 Then Exit Do                                  '--- for testing Depth_pass = C * A * Right_Left                             If Right_Left = -1 ThenIf Depth_pass <= EndZ Then                                 Depth_pass = EndZ                                   Last_Pass = 1                                   End If                                   ElseIf Depth_pass >= EndZ Then                                 Depth_pass = EndZ                                   Last_Pass = 1                                   End IfEnd IfCode "G01 Z" & Depth_Pass                                  If(Last_Pass < 1) Then                                Code "G00 Z" & RElse  Code "G00 Z" & StartZ  End If                                                               Last_Depth = Depth_Pass + ZClearance If(Last_Pass < 1) ThenCode "G00 Z" & Last_DepthEnd If                                   C = C + 1NCounter = NCounter + 1If NCounter = 300 Then Exit Do                                   Loop While (Last_Pass < 1)                                 If Test = True Then                   CloseTeachFile()                   LoadTeachFile()           End If                       