| gclib 1.34.15 Communications API for Galil controllers and PLCs |

Jog.vb
1 Partial Public Module Examples
2 Public Function Jog(gclib As Gclib) As Integer
3 gclib.GCommand("ST") ' Stop all motors
4 gclib.GMotionComplete("A") ' Wait For motion To complete
5 gclib.GCommand("SHA") ' Set servo here
6 gclib.GCommand("DPA=0") ' Start position at absolute zero
7 gclib.GCommand("JGA=0") ' Start jogging With 0 speed
8 gclib.GCommand("BGA") ' Begin motion On A Axis
9
10 Dim isJogging As Boolean = True
11 Dim speed As Integer = 0
12
13 Console.WriteLine("Enter a character on the keyboard to change the" +
14 " motor's speed:" + Environment.NewLine +
15 "<q> Quit" + Environment.NewLine +
16 "<a> -2000 counts/s" + Environment.NewLine +
17 "<s> -500 counts/s" + Environment.NewLine +
18 "<d> +500 counts/s" + Environment.NewLine +
19 "<f> +2000 counts/s" + Environment.NewLine +
20 "<r> Direction Reversal" + Environment.NewLine)
21
22 While isJogging
23 gclib.GCommand("JGA=" + speed.ToString())
24 Console.WriteLine("Jog Speed: " + speed.ToString())
25
26 Select Case Console.ReadKey(True).Key
27 Case ConsoleKey.Q
28 isJogging = False
29 Case ConsoleKey.A
30 speed -= 2000
31 Case ConsoleKey.S
32 speed -= 500
33 Case ConsoleKey.D
34 speed += 500
35 Case ConsoleKey.F
36 speed += 2000
37 Case ConsoleKey.R
38 speed *= -1
39 End Select
40 End While
41
42 gclib.GCommand("ST")
43 gclib.GMotionComplete("A")
44
45 Return GALIL_EXAMPLE_OK
46 End Function
47 End Module