Plugin-Delay required after commanding motion for IsMoving?
Posted: Thu Sep 22, 2016 1:55 am
I was just starting to play with how to command probe moves from a plugin written in VB.net. I got a small test routine to run, and report back the variable stored in #5061 variable (x touch point), however I have a question about a delay being required after issuing the UC.Code command to initiate the probe event, and the while IsMoving loop.
Code sample, initiated by a button press on a form as I finally got it to work:
What I am struggling with was trying to get the 'while UC.IsMoving' loop to work and prevent the sub from finishing before movement even started. it seems unless I added a delay after issuing the code command, movement wouldn't even be started before the IsMoving loop was skipped and the final msgbox popped up, and it took between a 150-200 msec delay to make it finally work. I don't believe a delay was needed in macros written in C# between the code command and the IsMoving loop. I'm probably making a simple error... Any thoughts? Is there a delay between a plugin providing a code command to UCCNC and the initiation of movement that is different than a macro being executed?
regards,
Eric Brust
Code sample, initiated by a button press on a form as I finally got it to work:
- Code: Select all
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim x
Dim feed As Integer
Dim readX
x = UC.GetXpos
x = x + 1
feed = TrackBar1.Value
MsgBox("GO TO X = " & x & " Feed = " & feed)
UC.Code("G31 x" & x & " f" & feed) ' command a G31 probe move
UC.Wait(200) ' THIS DELAY REQUIRED, OR THE 'IsMoving' loop was skipped before movement actually started. WHY?
Do While UC.IsMoving
MsgBox(" in loop") ' Added as test to see if this loop was skipped or not
Loop
readX = UC.Getvar(5061)
MsgBox("X = " & readX)
End Sub
What I am struggling with was trying to get the 'while UC.IsMoving' loop to work and prevent the sub from finishing before movement even started. it seems unless I added a delay after issuing the code command, movement wouldn't even be started before the IsMoving loop was skipped and the final msgbox popped up, and it took between a 150-200 msec delay to make it finally work. I don't believe a delay was needed in macros written in C# between the code command and the IsMoving loop. I'm probably making a simple error... Any thoughts? Is there a delay between a plugin providing a code command to UCCNC and the initiation of movement that is different than a macro being executed?
regards,
Eric Brust