1 Partial Public Module Examples
2 Public Function Motion_Complete(gclib As Gclib)
3 Console.WriteLine("*************************************************************")
4 Console.WriteLine("Example GInterrupt() usage")
5 Console.WriteLine("*************************************************************")
7 'Simple check for appropriate communication bus
8 'EI will fail below if interrupts are Not supported at all
11 If gclib.GCommand("WH").Contains("IH") Then
15 If Not ei_support Then
16 Console.WriteLine("No support on this bus")
17 Return GALIL_EXAMPLE_ERROR
21 gclib.GCommand("EI0,0") 'Turn off interrupts
22 gclib.GTimeout(0) 'Zero timeout
24 'Flush interrupts, status will be zero when queue Is empty
25 While (gclib.GInterrupt() > 0)
28 gclib.GTimeout(-1) 'Restore timeout
31 gclib.GCommand("DP 0,0") 'define position zero On A And B
32 Console.WriteLine("Position: " + gclib.GCommand("RP")) 'Print reference position
34 gclib.GCommand("SP 4000,4000") 'Set up speed
35 gclib.GCommand("AC 1280000, 1280000") 'acceleration
36 gclib.GCommand("DC 1280000, 1280000") 'deceleration
37 gclib.GCommand("PR 8000, 10000") 'Position Relative. B will take longer To make its move.
38 gclib.GCommand("SH AB") 'Servo Here
40 Console.WriteLine("Beginning independent motion...")
41 gclib.GCommand("BG AB") 'Begin motion
42 Check_Interrupts(gclib, "AB") 'Block until motion Is complete On axes A And B
43 Console.WriteLine("Motion Complete on A and B")
44 Console.WriteLine("Position: " + gclib.GCommand("RP")) 'Print reference position
46 Return GALIL_EXAMPLE_OK
49 Private Sub Check_Interrupts(gclib As Gclib, axes As String)
50 'bit mask of running axes, axes arg Is trusted to provide running axes.
51 'Low bit indicates running.
52 Dim axis_mask As Byte = &HFF
54 'iterate through all chars in axes to make the axis mask
55 For i = 0 To axes.Length - 1
60 axis_mask = axis_mask And &HFE
63 axis_mask = axis_mask And &HFD
66 axis_mask = axis_mask And &HFB
69 axis_mask = axis_mask And &HF7
72 axis_mask = axis_mask And &HEF
75 axis_mask = axis_mask And &HDF
78 axis_mask = axis_mask And &HBF
81 axis_mask = axis_mask And &H7F
86 'send EI axis mask to set up interrupt events.
87 gclib.GCommand("EI " + (Not axis_mask).ToString())
91 While (axis_mask <> &HFF) 'wait for all interrupts to come in
92 status = gclib.GInterrupt()
94 Case &HD0 'Axis A complete
95 axis_mask = axis_mask Or &H1
97 Case &HD1 'Axis B complete
98 axis_mask = axis_mask Or &H2
100 Case &HD2 'Axis C complete
101 axis_mask = axis_mask Or &H4
103 Case &HD3 'Axis D complete
104 axis_mask = axis_mask Or &H8
106 Case &HD4 'Axis E complete
107 axis_mask = axis_mask Or &H10
109 Case &HD5 'Axis F complete
110 axis_mask = axis_mask Or &H20
112 Case &HD6 'Axis G complete
113 axis_mask = axis_mask Or &H40
115 Case &HD7 'Axis H complete
116 axis_mask = axis_mask Or &H80