1 Partial Public Module Examples
2 Public Function Position_Tracking(gclib As Gclib, speed As Integer)
3 Dim acc = 100 * speed ' Set acceleration/deceleration to 100 times speed
5 gclib.GCommand("STA") 'Stop motor
6 gclib.GMotionComplete("A") 'Wait For motion To complete
7 gclib.GCommand("SHA") 'Set servo here
8 gclib.GCommand("DPA=0") 'Start position at absolute zero
9 gclib.GCommand("PTA=1") 'Start position tracking mode On A axis
11 gclib.GCommand("SPA=" + speed.ToString()) 'Set speed
12 gclib.GCommand("ACA=" + acc.ToString()) 'Set acceleration
13 gclib.GCommand("DCA=" + acc.ToString()) 'Set deceleration
15 Console.WriteLine("Begin Position Tracking with speed " + speed.ToString() +
16 ". Enter a non-number to exit.\n")
18 Dim position As Integer
20 'Loop asking user for New position. End loop when user enters a non-number
22 Console.WriteLine("Enter a new position:")
23 Dim ok = Integer.TryParse(Console.ReadLine(), position)
25 If ok Then ' A Then valid position was provided
26 gclib.GCommand("PAA=" + position.ToString()) ' Go To New position
27 Else 'A non-number was entered
28 Console.WriteLine("Position Tracking has exited")
32 gclib.GCommand("STA") 'Stop motor
33 gclib.GMotionComplete("A") 'Wait For motion To complete
35 Return GALIL_EXAMPLE_OK