Hi Zerodivide,
I think the API has a few/several methods to send jogs. The method(s) I like to use in my plugins (Xbox controller w/ proportional speed) is to call JogOnSpeed from the API for continuous jog. I use it to both start jog at a velocity, and to stop. For step jog, I use AddLinearMoveRel.
Here is the code I use on a jog button press (or a xbox stick movement) to make Y axis 'go' + movement, there is a check for if to make a continuous or step jog, then send the command:
- Code: Select all
'Y Up
Private Sub btnJogUp_Click_1(sender As Object, e As EventArgs) Handles btnJogUp.MouseDown
If rbJogCont.Checked Then
UC100.JogOnSpeed(1, False, yvelPCT(nudJogVel.Value)) ' Start axis in + direction and speed commanded by nudJogVel.value.....
End If
If rbJogStep.Checked Then
UC100.AddLinearMoveRel(1, nudJogStep.Value, 1, yvelPCT(nudJogVel.Value), False) 'start axis in + direction for step distance in nudJogStep.value, and move at speed per nudJogVel.value..... you don't need to stop the axis from this
End If
End Sub
And for the 'STOP' action on button release, all I do is send velocity =0 to that axis :
- Code: Select all
Private Sub btnJogUp_Click_1a(sender As Object, e As EventArgs) Handles btnJogUp.MouseUp
If rbJogCont.Checked Then
UC100.JogOnSpeed(1, False, 0) ' stop the axis, just set velocity to 0......
End If
End Sub
The last bit of info is that the jog speed command to set in the JogOnSpeed call is a percentage of the axis maximum feedrate the user has set in their settings, so you have to back out the percentage by what speed you want to command. I put that as function call (separate function for each axis in my code, so only y axis is here):
- Code: Select all
Private Function yvelPCT(ByVal yvel As Double) As Double
'Convert speed in 'unit/min' to 'Jog %'
If xmaxVel = 0 And ymaxVel = 0 Then
xmaxVel = UC.Getfielddouble(True, 9)
ymaxVel = UC.Getfielddouble(True, 24)
zmaxVel = UC.Getfielddouble(True, 39)
End If
yvelPCT = yvel / ymaxVel * 100 ' Define velocity as a % of max axis velocity, as input to JogOnSpeed command.
Return yvelPCT
End Function
Note that button press code is repeated for opposite direction (change the 'false' to 'true' in above calls), and then each axis gets the same blocks of code.
Hope this helps, I'm a vb hack user, so you'll have to clean it up to C#.
Note: if you use VB, I put a vb version of the API here for ref:
http://www.forum.cncdrive.com/viewtopic.php?f=4&t=2229&p=18012#p18012. It isn't 100% complete, but it is mostly there.
regards
Eric