gclib  2.0.8
Communications API for Galil controllers and PLCs
Vector_Mode.vb
Go to the documentation of this file.
1 Partial Public Module Examples
2  Public Function Vector_Mode(gclib As Gclib, file As String) As Integer
3  gclib.GCommand("ST") 'Stop all motors
4  gclib.GCommand("SH AB") 'Set servo here
5  gclib.GCommand("DP 0,0") 'Start position at absolute zero
6 
7  gclib.GCommand("CAS") 'Defines S As active coordinate system
8  gclib.GCommand("VS 20000") 'Defines vector speed
9  gclib.GCommand("VA 200000") 'Defines vector acceleration
10  gclib.GCommand("VD 200000") 'Defines vector decelerlation
11  gclib.GCommand("VM AB") 'Begin vector segment
12 
13  Using reader As System.IO.StreamReader = New System.IO.StreamReader(file)
14  'Stores the available space of the vector buffer in the capacity variable
15  Dim capacity = gclib.GCmdI("MG _LMS")
16  Load_Buffer(gclib, reader, capacity)
17 
18  Console.WriteLine("Begin Motion")
19  gclib.GCommand("BG S")
20 
21  Do 'Load buffer with more commands
22  System.Threading.Thread.Sleep(100)
23 
24  'Stores the available space of the vector buffer in the capacity variable
25  capacity = gclib.GCmdI("MG _LMS")
26  Loop While Load_Buffer(gclib, reader, capacity)
27 
28  gclib.GCommand("VE") 'Segment End
30  Console.WriteLine("Motion Complete")
31 
32  Return GALIL_EXAMPLE_OK
33  End Using
34  End Function
35 
36  Private Function Load_Buffer(gclib As Gclib, reader As System.IO.StreamReader, capacity As Integer) As Boolean
37  Dim s_cmd As String = ""
38  'Fully load the vector buffer leaving room for one VE command
39  For i = capacity To 1 Step -1
40  'If there Is another line of the text file
41  If reader.Peek() >= 0 Then
42  s_cmd = reader.ReadLine()
43  'Run the command on each line of the text file
44  gclib.GCommand(s_cmd)
45  Else
46  Return False
47  End If
48  Next
49 
50  Return True
51  End Function
52 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
GReturn commands(GCon g)
Demonstrates various uses of GCommand() and GUtility().
Definition: commands.cpp:16
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition: vector.cpp:36
partial Module Examples
Definition: Commands.vb:4