gclib  2.0.8
Communications API for Galil controllers and PLCs
Position_Tracking.vb
Go to the documentation of this file.
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
4 
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
10 
11  gclib.GCommand("SPA=" + speed.ToString()) 'Set speed
12  gclib.GCommand("ACA=" + acc.ToString()) 'Set acceleration
13  gclib.GCommand("DCA=" + acc.ToString()) 'Set deceleration
14 
15  Console.WriteLine("Begin Position Tracking with speed " + speed.ToString() +
16  ". Enter a non-number to exit.\n")
17 
18  Dim position As Integer
19 
20  'Loop asking user for New position. End loop when user enters a non-number
21  While True
22  Console.WriteLine("Enter a new position:")
23  Dim ok = Integer.TryParse(Console.ReadLine(), position)
24 
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")
29  Exit While
30  End If
31  End While
32  gclib.GCommand("STA") 'Stop motor
33  gclib.GMotionComplete("A") 'Wait For motion To complete
34 
35  Return GALIL_EXAMPLE_OK
36  End Function
37 End Module
string GCommand(string Command, bool Trim=true)
Used for command-and-response transactions.
Definition: gclib.cs:257
void GMotionComplete(string axes)
Blocking call that returns once all axes specified have completed their motion.
Definition: gclib.cs:428
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
Definition: gclib.cs:68
partial Module Examples
Definition: Commands.vb:4