PySigmaKoki 2.0.0__tar.gz → 2.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.1
2
+ Name: PySigmaKoki
3
+ Version: 2.1.3
4
+ Summary: Python Interface for Instruments by Sigma Koki
5
+ Author-email: Akira Okumura <oxon@mac.com>
6
+ License: BSD License
7
+ Project-URL: Repository, https://github.com/akira-okumura/PySigmaKoki.git
8
+ Project-URL: Issues, https://github.com/akira-okumura/PySigmaKoki/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Operating System :: OS Independent
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: pyserial
14
+
15
+ # PySigmaKoki
16
+ Python module to control Sigma Koki stages
17
+
18
+ # Install
19
+ $ pip install -i https://pypi.anaconda.org/oxon/simple pysigmakoki
20
+
21
+ # Example
22
+ >>> import sigma_koki
23
+ >>> gsc02 = sigma_koki.GSC02()
24
+ >>> gsc02.open('/dev/tty.usbserial-FTT75V89A')
25
+ >>> gsc02.setSpeed(1, 50, 20000, 1000, 50, 20000, 1000)
26
+ >>> gsc02.returnToMechanicalOrigin('+', '+')
27
+ >>> gsc02.move(-50000, -50000)
28
+ >>> gsc02.getStatus()
29
+ '- 50000,- 50000,K,K,R'
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.1
2
+ Name: PySigmaKoki
3
+ Version: 2.1.3
4
+ Summary: Python Interface for Instruments by Sigma Koki
5
+ Author-email: Akira Okumura <oxon@mac.com>
6
+ License: BSD License
7
+ Project-URL: Repository, https://github.com/akira-okumura/PySigmaKoki.git
8
+ Project-URL: Issues, https://github.com/akira-okumura/PySigmaKoki/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Operating System :: OS Independent
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: pyserial
14
+
15
+ # PySigmaKoki
16
+ Python module to control Sigma Koki stages
17
+
18
+ # Install
19
+ $ pip install -i https://pypi.anaconda.org/oxon/simple pysigmakoki
20
+
21
+ # Example
22
+ >>> import sigma_koki
23
+ >>> gsc02 = sigma_koki.GSC02()
24
+ >>> gsc02.open('/dev/tty.usbserial-FTT75V89A')
25
+ >>> gsc02.setSpeed(1, 50, 20000, 1000, 50, 20000, 1000)
26
+ >>> gsc02.returnToMechanicalOrigin('+', '+')
27
+ >>> gsc02.move(-50000, -50000)
28
+ >>> gsc02.getStatus()
29
+ '- 50000,- 50000,K,K,R'
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ sigma_koki.py
4
+ PySigmaKoki.egg-info/PKG-INFO
5
+ PySigmaKoki.egg-info/SOURCES.txt
6
+ PySigmaKoki.egg-info/dependency_links.txt
7
+ PySigmaKoki.egg-info/requires.txt
8
+ PySigmaKoki.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pyserial
@@ -0,0 +1 @@
1
+ sigma_koki
@@ -0,0 +1,15 @@
1
+ # PySigmaKoki
2
+ Python module to control Sigma Koki stages
3
+
4
+ # Install
5
+ $ pip install -i https://pypi.anaconda.org/oxon/simple pysigmakoki
6
+
7
+ # Example
8
+ >>> import sigma_koki
9
+ >>> gsc02 = sigma_koki.GSC02()
10
+ >>> gsc02.open('/dev/tty.usbserial-FTT75V89A')
11
+ >>> gsc02.setSpeed(1, 50, 20000, 1000, 50, 20000, 1000)
12
+ >>> gsc02.returnToMechanicalOrigin('+', '+')
13
+ >>> gsc02.move(-50000, -50000)
14
+ >>> gsc02.getStatus()
15
+ '- 50000,- 50000,K,K,R'
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0", "wheel", "pyserial"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "PySigmaKoki"
7
+ version = "2.1.3"
8
+ description = "Python Interface for Instruments by Sigma Koki"
9
+ authors = [
10
+ { name = "Akira Okumura", email = "oxon@mac.com" }
11
+ ]
12
+ readme = {file = "README.md", content-type = "text/markdown"}
13
+ license = {text = "BSD License"}
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: BSD License",
17
+ "Operating System :: OS Independent"
18
+ ]
19
+ dependencies = [
20
+ "pyserial"
21
+ ]
22
+
23
+ [project.urls]
24
+ Repository = "https://github.com/akira-okumura/PySigmaKoki.git"
25
+ Issues = "https://github.com/akira-okumura/PySigmaKoki/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,315 @@
1
+ """
2
+ This is an interface module for instruments produced by Sigma Koki
3
+ """
4
+
5
+ try:
6
+ # It is not needed to import ValueError in newer Python versions
7
+ from exceptions import ValueError
8
+ except:
9
+ pass
10
+ import serial
11
+ import sys
12
+
13
+ class BaseStageController(object):
14
+ """
15
+ Stage controller class commonly used for Sigma Koki GSC02 and SHOT702
16
+ """
17
+ def __init__(self, baudrate, product):
18
+ self.__baudRate = baudrate
19
+ self.__parityBit = 'N' # None
20
+ self.__dataBit = 8
21
+ self.__stopBit = 1
22
+ self.__rtscts = True
23
+ self.__product = product
24
+ self.__acknowledge = True
25
+
26
+ def setBaudRate(self, rate):
27
+ rates = {'GSC-02': (2400, 4800, 9600, 19200),
28
+ 'SHOT-702' : (38400,),
29
+ 'SHOT-702H' : (38400,)}
30
+ if rate in rates[self.__product]:
31
+ self.__baudRate = rate
32
+ else:
33
+ raise ValueError('Attempting to set an invalid buard rate of %d to %s. The rate must be chosen from %s.' % (rate, self.__product, rates[self.__product]))
34
+
35
+ def disableAcknowledge(self):
36
+ self.__acknowledge = False
37
+
38
+ def write(self, command, acknowledge=True):
39
+ # 'str' class needs be converted into 'bytes'
40
+ # e.g., 'command' -> b'command'
41
+ self.serial.write((command + '\r\n').encode())
42
+
43
+ if not self.__acknowledge or not acknowledge:
44
+ return
45
+
46
+ ack = self.readline()
47
+ if ack == 'OK':
48
+ return
49
+ else:
50
+ raise RuntimeError('%s returned bad acknowledge "%s"' % (self.__product, ack))
51
+
52
+ def query(self, command):
53
+ self.write(command, False)
54
+ return self.readline()
55
+
56
+ def readline(self):
57
+ # convert 'bytes' to 'str'
58
+ result = str(self.serial.readline())
59
+ if result[:2] == "b'" and result[-1:] == "'":
60
+ result = result[2:-1] # drop byte code prefix and suffix
61
+ if result[-4:] == '\\r\\n':
62
+ result = result[:-4] # drop delimeter
63
+
64
+ return result
65
+
66
+ def open(self, port, readTimeOut = 1, writeTimeOut = 1):
67
+ self.serial = serial.Serial(port = port,
68
+ baudrate = self.__baudRate,
69
+ bytesize = self.__dataBit,
70
+ parity = self.__parityBit,
71
+ stopbits = self.__stopBit,
72
+ timeout = readTimeOut,
73
+ writeTimeout = writeTimeOut,
74
+ rtscts = self.__rtscts)
75
+
76
+ def close(self):
77
+ self.serial.close()
78
+
79
+ def returnToMechanicalOrigin(self, stage1, stage2):
80
+ """
81
+ Moves the stages to the +/- end points and reset the coordinate values
82
+ to zero.
83
+ """
84
+ if self.__product == 'GSC-02':
85
+ if stage1 == '+' and stage2 == '+':
86
+ self.write('H:W++')
87
+ elif stage1 == '+' and stage2 == '-':
88
+ self.write('H:W+-')
89
+ elif stage1 == '-' and stage2 == '+':
90
+ self.write('H:W-+')
91
+ elif stage1 == '-' and stage2 == '-':
92
+ self.write('H:W--')
93
+ elif stage1 == '+':
94
+ self.write('H:1+')
95
+ elif stage1 == '-':
96
+ self.write('H:1-')
97
+ elif stage2 == '+':
98
+ self.write('H:2+')
99
+ elif stage2 == '-':
100
+ self.write('H:2-')
101
+ else:
102
+ return
103
+ elif self.__product == 'SHOT-702':
104
+ if stage1 == True and stage2 == True:
105
+ self.write('H:W')
106
+ elif stage1 == True:
107
+ self.write('H:1')
108
+ elif stage2 == True:
109
+ self.write('H:2')
110
+ else:
111
+ return
112
+
113
+ def move(self, stage1, stage2):
114
+ """
115
+ Moves the stages with the specified values. Since GSC-02 is a half-step
116
+ stepping driver, 1 pulse corresponds to "half-step movement" in the
117
+ stage catalogues.
118
+ """
119
+ if self.__product == 'GSC-02':
120
+ limit = 16777214
121
+ elif self.__product == 'SHOT-702':
122
+ limit = 268435455
123
+
124
+ if not (-limit <= stage1 <= limit):
125
+ raise ValueError('stage1 must be between -%d and %d.' % (limit, limit))
126
+
127
+ if not (-limit <= stage2 <= limit):
128
+ raise ValueError('stage2 must be between -%d and %d.' % (limit, limit))
129
+
130
+ command = 'M:W'
131
+ if stage1 >= 0:
132
+ command += '+P%d' % stage1
133
+ else:
134
+ command += '-P%d' % -stage1
135
+
136
+ if stage2 >= 0:
137
+ command += '+P%d' % stage2
138
+ else:
139
+ command += '-P%d' % -stage2
140
+
141
+ self.write(command)
142
+ self.go()
143
+
144
+ def jog(self, stage1, stage2):
145
+ """
146
+ Moves the stages continuously at the minimum speed.
147
+ stage1: '+' positive direction, '-' negative direction
148
+ stage2: '+' positive direction, '-' negative direction
149
+ If other values are given, stages will not move.
150
+ """
151
+ if stage1 == '+' and stage2 == '+':
152
+ self.write('J:W++')
153
+ elif stage1 == '+' and stage2 == '-':
154
+ self.write('J:W+-')
155
+ elif stage1 == '-' and stage2 == '+':
156
+ self.write('J:W-+')
157
+ elif stage1 == '-' and stage2 == '-':
158
+ self.write('J:W--')
159
+ elif stage1 == '+':
160
+ self.write('J:1+')
161
+ elif stage1 == '-':
162
+ self.write('J:1-')
163
+ elif stage2 == '+':
164
+ self.write('J:2+')
165
+ elif stage2 == '-':
166
+ self.write('J:2-')
167
+ else:
168
+ return
169
+
170
+ self.go()
171
+
172
+ def go(self):
173
+ """
174
+ Moves the stages. To be used internally.
175
+ """
176
+ self.write('G')
177
+
178
+ def decelerate(self, stage1, stage2):
179
+ """
180
+ Decelerates and stop the stages.
181
+ """
182
+ if stage1 and stage2:
183
+ self.write('L:W')
184
+ elif stage1:
185
+ self.write('L:1')
186
+ elif stage2:
187
+ self.write('L:2')
188
+
189
+ def stop(self):
190
+ """
191
+ Stops the stages immediately.
192
+ """
193
+ self.write('L:E')
194
+
195
+ def initializeOrigin(self, stage1, stage2):
196
+ """
197
+ Sets the origin to the current position.
198
+ stage1: If true, set the origin of the stage 1 to the current position
199
+ stage2: If true, set the origin of the stage 1 to the current position
200
+ """
201
+ if stage1:
202
+ self.write('R:1')
203
+
204
+ if stage2:
205
+ self.write('R:2')
206
+
207
+ def enableMotorExcitation(self, stage1 = True, stage2 = False):
208
+ """
209
+ Enables motor excitation
210
+ """
211
+ if stage1 in (True, False):
212
+ self.write('C:1%d' % stage1)
213
+
214
+ if stage2 in (True, False):
215
+ self.write('C:2%d' % stage2)
216
+
217
+ def getStatus(self):
218
+ """
219
+ Returns the status of the controller
220
+ """
221
+ return self.query('Q:')
222
+
223
+ def getACK3(self):
224
+ """
225
+ Returns the status of ACK3
226
+ """
227
+ return self.query('!:')
228
+
229
+ def getVersion(self):
230
+ """
231
+ Returns the ROM version
232
+ """
233
+ return self.query('?:V')
234
+
235
+ class GSC02(BaseStageController):
236
+ """
237
+ Stage controller GSC-02
238
+ """
239
+ def __init__(self):
240
+ # 9600 bps the initial factory setting
241
+ BaseStageController.__init__(self, 9600, 'GSC-02')
242
+ self.disableAcknowledge()
243
+
244
+ def setSpeed(self, highspeed, minSpeed1, maxSpeed1, accelerationTime1,
245
+ minSpeed2, maxSpeed2, accelerationTime2):
246
+ """
247
+ Sets the movement speeds of the stages
248
+ highspeed: If true, speed range is 50-20000, else 1-200
249
+ minSpeed1/2: Minimum speed (PPS)
250
+ maxSpeed1/2: Maximum speed (PPS)
251
+ accelerationTime1/2: Acceleration time to be taken from min to max (ms)
252
+
253
+ | _________ ... maximum speed (PPS)
254
+ | / \
255
+ | / \
256
+ | / \ ... minimum speed (PPS)
257
+ | | |
258
+ | | |
259
+ |__|______________|________
260
+ <-> acceleration time (ms)
261
+ <-> deceleration time (ms)
262
+ """
263
+ if not highspeed:
264
+ if not (1 <= minSpeed1 <= maxSpeed1 <= 200):
265
+ raise ValueError('Must be 1 <= minSpeed1 <= maxSpeed1 <= 200 in low speed range.')
266
+ if not (1 <= minSpeed2 <= maxSpeed2 <= 200):
267
+ raise ValueError('Must be 1 <= minSpeed2 <= maxSpeed2 <= 200 in low speed range.')
268
+ else:
269
+ if not (50 <= minSpeed1 <= maxSpeed1 <= 20000):
270
+ raise ValueError('Must be 50 <= minSpeed1 <= maxSpeed1 <= 20000 in high speed range.')
271
+ if not (50 <= minSpeed2 <= maxSpeed2 <= 20000):
272
+ raise ValueError('Must be 50 <= minSpeed2 <= maxSpeed2 <= 20000 in high speed range.')
273
+
274
+ if not (0 <= accelerationTime1 <= 1000):
275
+ raise ValueError('Must be 0 <= accelerationTime1 <= 1000.')
276
+
277
+ if not (0 <= accelerationTime2 <= 1000):
278
+ raise ValueError('Must be 0 <= accelerationTime2 <= 1000.')
279
+
280
+ if highspeed:
281
+ self.write('D:2S%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2))
282
+ else:
283
+ self.write('D:1S%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2))
284
+
285
+ class SHOT702(BaseStageController):
286
+ """
287
+ Stage controller SHOT-702
288
+ """
289
+ def __init__(self):
290
+ # 9600 bps the initial factory setting
291
+ BaseStageController.__init__(self, 38400, 'SHOT-702')
292
+
293
+ def setSpeed(self, minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2):
294
+ """
295
+ Sets the movement speeds of the stages
296
+ minSpeed1/2: Minimum speed (PPS)
297
+ maxSpeed1/2: Maximum speed (PPS)
298
+ accelerationTime1/2: Acceleration time to be taken from min to max (ms)
299
+ """
300
+ if not (1 <= minSpeed1 <= maxSpeed1 <= 500000):
301
+ raise ValueError('Must be 1 <= minSpeed1 <= maxSpeed1 <= 500000.')
302
+
303
+ if not (1 <= minSpeed2 <= maxSpeed2 <= 500000):
304
+ raise ValueError('Must be 1 <= minSpeed2 <= maxSpeed2 <= 500000.')
305
+
306
+ if not (0 <= accelerationTime1 <= 1000):
307
+ raise ValueError('Must be 0 <= accelerationTime <= 1000.')
308
+
309
+ if not (0 <= accelerationTime2 <= 1000):
310
+ raise ValueError('Must be 0 <= accelerationTime <= 1000.')
311
+
312
+ self.write('D:WS%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2))
313
+
314
+ # Some query commands, ?:P, ?:S, ?:D, and ?:B, are not implemented yet
315
+
@@ -1,17 +0,0 @@
1
- Metadata-Version: 1.1
2
- Name: PySigmaKoki
3
- Version: 2.0.0
4
- Summary: Python Interface for Instruments by Sigma Koki
5
- Home-page: https://github.com/akira-okumura/PySigmaKoki
6
- Author: Akira Okumura
7
- Author-email: oxon@mac.com
8
- License: BSD License
9
- Description:
10
- This is an interface module for instruments produced by Sigma Koki
11
-
12
- Platform: MacOS :: MacOS X
13
- Platform: POSIX
14
- Platform: Windows
15
- Classifier: Topic :: Terminals :: Serial
16
- Classifier: Development Status :: 5 - Production/Stable
17
- Classifier: Programming Language :: Python
@@ -1,19 +0,0 @@
1
- from distutils.core import setup
2
- import sigma_koki
3
-
4
- setup(name='PySigmaKoki',
5
- version='2.0.0',
6
- description='Python Interface for Instruments by Sigma Koki',
7
- author='Akira Okumura',
8
- author_email='oxon@mac.com',
9
- license='BSD License',
10
- platforms=['MacOS :: MacOS X', 'POSIX', 'Windows'],
11
- url='https://github.com/akira-okumura/PySigmaKoki',
12
- py_modules=['sigma_koki'],
13
- install_requires=['pyserial'],
14
- classifiers=['Topic :: Terminals :: Serial',
15
- 'Development Status :: 5 - Production/Stable',
16
- 'Programming Language :: Python',
17
- ],
18
- long_description=sigma_koki.__doc__
19
- )
@@ -1,228 +0,0 @@
1
- """
2
- This is an interface module for instruments produced by Sigma Koki
3
- """
4
-
5
- try:
6
- from exceptions import ValueError
7
- except:
8
- pass
9
- import serial
10
- import sys
11
-
12
- class GSC02(object):
13
- """
14
- Stage controller GSC-02
15
- """
16
- def __init__(self):
17
- self.__baudRate = 9600 # 9600 bps
18
- self.__parityBit = 'N' # None
19
- self.__dataBit = 8
20
- self.__stopBit = 1
21
- self.__rtscts = True
22
-
23
- def setBaudRate(self, rate):
24
- if rate in (2400, 4800, 9600, 19200):
25
- self.__baudRate = rate
26
- else:
27
- raise ValueError('Invalid buard rate %d was given. Must be chosen from 2400/4800/9600/19200.' % rate)
28
-
29
- def open(self, port, readTimeOut = 1, writeTimeOut = 1):
30
- self.serial = serial.Serial(port = port,
31
- baudrate = self.__baudRate,
32
- bytesize = self.__dataBit,
33
- parity = self.__parityBit,
34
- stopbits = self.__stopBit,
35
- timeout = readTimeOut,
36
- writeTimeout = writeTimeOut,
37
- rtscts = self.__rtscts)
38
-
39
- def write(self, command):
40
- self.serial.write(command + b'\r\n')
41
-
42
- def readline(self):
43
- return self.serial.readline()[:-2]
44
-
45
- def returnToMechanicalOrigin(self, stage1, stage2):
46
- """
47
- Moves the stages to the +/- end points and reset the coordinate values
48
- to zero.
49
- """
50
- if stage1 == b'+' and stage2 == b'+':
51
- self.write(b'H:W++')
52
- elif stage1 == b'+' and stage2 == b'-':
53
- self.write(b'H:W+-')
54
- elif stage1 == b'-' and stage2 == b'+':
55
- self.write(b'H:W-+')
56
- elif stage1 == b'-' and stage2 == b'-':
57
- self.write(b'H:W--')
58
- elif stage1 == b'+':
59
- self.write(b'H:1+')
60
- elif stage1 == b'-':
61
- self.write(b'H:1-')
62
- elif stage2 == b'+':
63
- self.write(b'H:2+')
64
- elif stage2 == b'-':
65
- self.write(b'H:2-')
66
- else:
67
- return
68
-
69
- def move(self, stage1, stage2):
70
- """
71
- Moves the stages with the specified values. Since GSC-02 is a half-step
72
- stepping driver, 1 pulse corresponds to "half-step movement" in the
73
- stage catalogues.
74
- """
75
- if not (-16777214 <= stage1 <= 16777214):
76
- raise ValueError('stage1 must be between -16777214 and 16777214.')
77
-
78
- if not (-16777214 <= stage2 <= 16777214):
79
- raise ValueError('stage2 must be between -16777214 and 16777214.')
80
-
81
- command = b'M:W'
82
- if stage1 >= 0:
83
- command += b'+P%d' % stage1
84
- else:
85
- command += b'-P%d' % -stage1
86
-
87
- if stage2 >= 0:
88
- command += b'+P%d' % stage2
89
- else:
90
- command += b'-P%d' % -stage2
91
-
92
- self.write(command)
93
- self.go()
94
-
95
- def jog(self, stage1, stage2):
96
- """
97
- Moves the stages continuously at the minimum speed.
98
- stage1: '+' positive direction, '-' negative direction
99
- stage2: '+' positive direction, '-' negative direction
100
- If other values are given, stages will not move.
101
- """
102
- if stage1 == b'+' and stage2 == b'+':
103
- self.write(b'J:W++')
104
- elif stage1 == b'+' and stage2 == b'-':
105
- self.write(b'J:W+-')
106
- elif stage1 == b'-' and stage2 == b'+':
107
- self.write(b'J:W-+')
108
- elif stage1 == b'-' and stage2 == b'-':
109
- self.write(b'J:W--')
110
- elif stage1 == b'+':
111
- self.write(b'J:1+')
112
- elif stage1 == b'-':
113
- self.write(b'J:1-')
114
- elif stage2 == b'+':
115
- self.write(b'J:2+')
116
- elif stage2 == b'-':
117
- self.write(b'J:2-')
118
- else:
119
- return
120
-
121
- self.go()
122
-
123
- def go(self):
124
- """
125
- Moves the stages. To be used internally.
126
- """
127
- self.write(b'G')
128
-
129
- def decelerate(self, stage1, stage2):
130
- """
131
- Decelerates and stop the stages.
132
- """
133
- if stage1 and stage2:
134
- self.write(b'L:W')
135
- elif stage1:
136
- self.write(b'L:1')
137
- elif stage2:
138
- self.write(b'L:2')
139
-
140
- def stop(self):
141
- """
142
- Stops the stages immediately.
143
- """
144
- self.write(b'L:E')
145
-
146
- def initializeOrigin(self, stage1, stage2):
147
- """
148
- Sets the origin to the current position.
149
- stage1: If true, set the origin of the stage 1 to the current position
150
- stage2: If true, set the origin of the stage 1 to the current position
151
- """
152
- if stage1:
153
- self.write(b'R:1')
154
-
155
- if stage2:
156
- self.write(b'R:2')
157
-
158
- def setSpeed(self, highspeed, minSpeed1, maxSpeed1, accelerationTime1,
159
- minSpeed2, maxSpeed2, accelerationTime2):
160
- """
161
- Sets the movement speeds of the stages
162
- highspeed: If true, speed range is 50-20000, else 1-200
163
- minSpeed1/2: Minimum speed (PPS)
164
- maxSpeed1/2: Maximum speed (PPS)
165
- accelerationTime1/2: Acceleration time to be taken from min to max (ms)
166
-
167
- | _________ ... maximum speed (PPS)
168
- | / \
169
- | / \
170
- | / \ ... minimum speed (PPS)
171
- | | |
172
- | | |
173
- |__|______________|________
174
- <-> acceleration time (ms)
175
- <-> deceleration time (ms)
176
- """
177
- if not highspeed:
178
- if not (1 <= minSpeed1 <= maxSpeed1 <= 200):
179
- raise ValueError('Must be 1 <= minSpeed1 <= maxSpeed1 <= 200 in low speed range.')
180
- if not (1 <= minSpeed2 <= maxSpeed2 <= 200):
181
- raise ValueError('Must be 1 <= minSpeed2 <= maxSpeed2 <= 200 in low speed range.')
182
- else:
183
- if not (50 <= minSpeed1 <= maxSpeed1 <= 20000):
184
- raise ValueError('Must be 50 <= minSpeed1 <= maxSpeed1 <= 20000 in high speed range.')
185
- if not (50 <= minSpeed2 <= maxSpeed2 <= 20000):
186
- raise ValueError('Must be 50 <= minSpeed2 <= maxSpeed2 <= 20000 in high speed range.')
187
-
188
- if not (0 <= accelerationTime1 <= 1000):
189
- raise ValueError('Must be 00 <= accelerationTime1 <= 1000.')
190
-
191
- if not (0 <= accelerationTime2 <= 1000):
192
- raise ValueError('Must be 00 <= accelerationTime2 <= 1000.')
193
-
194
- if highspeed:
195
- self.write(b'D:2S%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2))
196
- else:
197
- self.write(b'D:1S%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2))
198
-
199
- def enableMotorExcitation(self, stage1 = True, stage2 = False):
200
- """
201
- Enables motor excitation
202
- """
203
- if stage1 in (True, False):
204
- self.write(b'C:1%d' % stage1)
205
-
206
- if stage2 in (True, False):
207
- self.write(b'C:2%d' % stage2)
208
-
209
- def getStatus(self):
210
- """
211
- Returns the status of the controller
212
- """
213
- self.write(b'Q:')
214
- return self.readline()
215
-
216
- def getACK3(self):
217
- """
218
- Returns the status of ACK3
219
- """
220
- self.write(b'!:')
221
- return self.readline()
222
-
223
- def getVersion(self):
224
- """
225
- Returns the ROM version
226
- """
227
- self.write(b'?:V')
228
- return self.readline()