| gclib 1.34.15 Communications API for Galil controllers and PLCs |

vector_mode.cs
Go to the documentation of this file.
1
10 using System.IO;
11 using System.Threading;
12
13 namespace examples
14 {
15 public static partial class Examples
16 {
44
45 public static int Vector_Mode(gclib gclib, string file)
46 {
47 gclib.GCommand("ST"); // Stop all motors
48 gclib.GCommand("SH AB"); // Set servo here
49 gclib.GCommand("DP 0,0"); // Start position at absolute zero
50
51 gclib.GCommand("CAS"); // Defines S as active coordinate system
52 gclib.GCommand("VS 20000"); // Defines vector speed
53 gclib.GCommand("VA 200000"); // Defines vector acceleration
54 gclib.GCommand("VD 200000"); // Defines vector decelerlation
55 gclib.GCommand("VM AB"); // Begin vector segment
56
57 using (StreamReader reader = new StreamReader(file))
58 {
59 //Stores the available space of the vector buffer in the capacity variable
60 int capacity = gclib.GCmdI("MG _LMS");
61 Load_Buffer(gclib, reader, capacity);
62
63 gclib.GCommand("BG S");
64
65 do // Load buffer with more commands
66 {
67 Thread.Sleep(100);
68
69 //Stores the available space of the vector buffer in the capacity variable
70 capacity = gclib.GCmdI("MG _LMS");
71 } while (Load_Buffer(gclib, reader, capacity));
72 }
73
74 gclib.GCommand("VE"); // Segment End
75 gclib.GMotionComplete("S");
76
77 return GALIL_EXAMPLE_OK;
78 }
79
80 private static bool Load_Buffer(gclib gclib, StreamReader reader, int capacity)
81 {
82 string s_cmd;
83 // Fully load the vector buffer leaving room for one VE command
84 for (; capacity > 1; capacity--)
85 {
86 // If there is another line of the text file
87 if ((s_cmd = reader.ReadLine()) != null)
88 {
89 // Run the command on each line of the text file
90 gclib.GCommand(s_cmd);
91 }
92 else
93 return false;
94 }
95
96 return true;
97 }
99 }
100 }
examples.Examples.GALIL_EXAMPLE_OK
const int GALIL_EXAMPLE_OK
Examples success code.
Definition: examples.cs:29
examples.Examples.Vector_Mode
static int Vector_Mode(gclib gclib, string file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition: vector_mode.cs:45
examples
Definition: commands.cs:14