Hello Guest it is January 23, 2022, 01:19:03 PM

Author Topic: Skipping over entire blocks of code  (Read 1766 times)

0 Members and 1 Guest are viewing this topic.

Skipping over entire blocks of code
« on: June 09, 2012, 08:03:38 AM »
I having trouble with code being skipped over. When I step through the following it works as you would expect, but when you run it from the command line or from within a Gcode file, it skips over almost all of it. I will here a solenoid activate and deactivate but that's about it. Surely I'm doing something simply wrong. I've tried using While Ismoving() Wend and it causes it to hang in the while loop. Any suggestions?

tbyrd

REM M4016 Tip Measure
Dim AmountOff
Dim NewYGrindPos
Dim OldYGrindPos
Dim AllowableOff
Dim RejectAmount
Dim UserCounter
Dim AbsoluteAmount

rem 'Makes sure machine is homed and calibrated
If (GetOEMLED(807)) Then
     Message ("Not Homed Yet")
     Else
     If (GetOEMLED(808)) Then
          Message ("Not Homed Yet")
          Else
          If (GetOEMLED(809)) Then
            Message ("Not Homed Yet")
            Else
            If (GetUserLED(2012)) Then
                 Message ("Not Calibrated Yet")
                 Else
                 Message ("Good to Go!")
     

               rem Code "M1003" 'Gripper back
               rem M1003 Gripper Back
            DeActivateSignal (output6)   
            ActivateSignal (output5)
            While Not IsActive (OEMTRIG5)
                 Message ("I'm goin' back!")
                 Sleep 50
            Wend
            Message ("Made it") 

            Code "G90G00 B1.0"

            rem Code "M4017" 'Measure pin down
            REM M4017 Measure Pin Down
            DeActivateSignal (output8) 'Measure Pin Up
            ActivateSignal (output7)   'Measure Pin Down
            While Not IsActive (OEMTRIG7)
                Message (" I'm working on it")
                Sleep 50
            Wend
             Message ("Made it!")

            rem Code "M2040" 'Goto Load position all axis
            REM M2040 GoTo X Y And Z load And unload
            Dim ZLoadUnload
            Dim XOpenPos
            Dim YOpenPos
            XOpenPos = GetOEMDRO(2014)
            YOpenPos = GetOEMDRO(2017)
            ZLoadUnload = GetOEMDRO(2018)

            rem Code "M1003" 'Gripper back
            rem M1003 Gripper Back
            DeActivateSignal (output6)   
            ActivateSignal (output5)
            While Not IsActive (OEMTRIG5)
                 Message ("I'm goin' back!")
                 Sleep 50
            Wend
            Message ("Made it") 

            Code "G90G00 Y" & YOpenPos
            Code "G90G00 X" & XOpenPos
            Code "G90G00 Z" & ZLoadUnload

            rem Code "M2060" 'goto Z Measure
            REM M2060 GoTo Z MEASURE
            Dim ZMeasure
            ZMeasure = GetOEMDRO(2019)

            rem Code "M1003" 'Gripper back
            rem M1003 Gripper Back
            DeActivateSignal (output6)   
            ActivateSignal (output5)
            While Not IsActive (OEMTRIG5)
                 Message ("I'm goin' back!")
                 Sleep 50
            Wend
            Message ("Made it") 

            Code "G90G00 Z" & ZMeasure

            rem Code "M1002" 'advance arm
            rem M1002 Gripper Forward
            DeActivateSignal (output5) 
            ActivateSignal (output6)
            While Not IsActive (OEMTRIG4)
                 Message ("I'm goin' forward!")
                 Sleep 50
            Wend
            Message ("Made it")

            rem Code "M4018" 'Measure pin up
            REM M4018 Measure Pin up
            DeActivateSignal (output7) 'Measure Pin Down
            ActivateSignal (output8)   'Measure Pin Up
            While Not IsActive (OEMTRIG6)
                Message (" I'm working on it")
                Sleep 50
            Wend
             Message ("Made it!")

            rem Code "M1005" 'release gripper
            rem M1005 gripper release
            DeActivateSignal (output10)
            ActivateSignal (output9)
            While Not IsActive (OEMTRIG2)
                 Message ("I'm trying to let go")
                 Sleep 50
            Wend
            Message ("You're FREE!")

            rem Code "M1003" 'retract arm
            rem M1003 Gripper Back
            DeActivateSignal (output6)   
            ActivateSignal (output5)
            While Not IsActive (OEMTRIG5)
                 Message ("I'm goin' back!")
                 Sleep 50
            Wend
            Message ("Made it") 

            Code "G90G00 B.05"

            While Not (IsActive (OEMTRIG1))
               Code "G91G00 B-.001"
               Sleep 50
            Wend

            While (IsActive (OEMTRIG1))
               Code "F.5"
               Code "G91G01 B.00005"
               Sleep 20
            Wend                     

            AmountOff = GetOEMDRO(804) '182
            OldYGrindPos = GetOEMDRO(2011)
            RejectAmount = GetOEMDRO(2004)
            GrindsBetweenCounter = GetOEMDRO(2008)

            Code "G90G00 B1.0"

            rem Code "M4017" 'Measure Pin Down
            REM M4017 Measure Pin Down
            DeActivateSignal (output8) 'Measure Pin Up
            ActivateSignal (output7)   'Measure Pin Down
            While Not IsActive (OEMTRIG7)
                Message (" I'm working on it")
                Sleep 50
            Wend
             Message ("Made it!")
 
            Call SetUserDRO(2001, AmountOff)

            AbsoluteAmount = Abs(AmountOff)

            If (AbsoluteAmount > .001) Then
               If (AmountOff > 0) Then
               AmountOff = .001
            End If
            If (AmountOff < 0) Then
               AmountOff = -.001
            End If
         
            NewYGrindPos = OldYGrindPos - AmountOff

            Call SetUserDRO(2011, NewYGrindPos)

            If (AbsoluteAmount > RejectAmount) Then
               Call SetUserDRO(2009, 0)
               rem Code "M1011"
               rem M1011 Shoot off bad tip
               ActivateSignal (output3)
               Sleep 500
               DeActivateSignal (output3)
            Else
               Call SetUserDRO(2009, GrindsBetweenCounter) 'resets counter
               rem Code "M1010"
               rem M1010 Shoot off good tip
               ActivateSignal (output4)
               Sleep 500
               DeActivateSignal (output4)
            End If
         End If
      End If
   End If
End If