gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
jog.cs
Go to the documentation of this file.
1
10using System;
11
12namespace examples
13{
14 public static partial class Examples
15 {
34
35 public static int Jog(gclib gclib)
36 {
37 gclib.GCommand("ST"); // Stop all motors
38 gclib.GMotionComplete("A"); // Wait for motion to complete
39 gclib.GCommand("SHA"); // Set servo here
40 gclib.GCommand("DPA=0"); // Start position at absolute zero
41 gclib.GCommand("JGA=0"); // Start jogging with 0 speed
42 gclib.GCommand("BGA"); // Begin motion on A Axis
43
44 bool isJogging = true;
45 int speed = 0;
46
47 Console.WriteLine("Enter a character on the keyboard to change the" +
48 " motor's speed:\n<q> Quit\n<a> -2000 counts/s\n" +
49 "<s> -500 counts/s\n<d> +500 counts/s\n<f> " +
50 "+2000 counts/s\n<r> Direction Reversal\n");
51
52 while (isJogging)
53 {
54 gclib.GCommand("JGA=" + speed);
55
56 Console.WriteLine("Jog Speed: " + speed);
57
58 switch (Console.ReadKey(true).Key)
59 {
60 case ConsoleKey.Q:
61 isJogging = false;
62 break;
63 case ConsoleKey.A:
64 speed -= 2000;
65 break;
66 case ConsoleKey.S:
67 speed -= 500;
68 break;
69 case ConsoleKey.D:
70 speed += 500;
71 break;
72 case ConsoleKey.F:
73 speed += 2000;
74 break;
75 case ConsoleKey.R:
76 speed *= -1;
77 break;
78 }
79 }
80
81 gclib.GCommand("ST");
83
84 return GALIL_EXAMPLE_OK;
85 }
87 }
88}
const int GALIL_EXAMPLE_OK
Examples success code.
Definition examples.cs:29
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 vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition vector.cpp:36
static int Jog(gclib gclib)
Puts controller into Jog Mode and accepts user input to adjust the speed.
Definition jog.cs:35
partial Module Examples
Definition Commands.vb:4