-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomMotor.py
45 lines (34 loc) · 1021 Bytes
/
RandomMotor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import time,random, sys
import InstrumentControl
def timeCheck(goalTime):
global startTime
endTime = time.time()
if(endTime - startTime > goalTime):
endTime = startTime
return True
return False
def randomMotor(moveControl):
global StepperControl
global goalTime
StepperControl.SetPosition(1,1.8, moveControl)
timeControl = timeCheck(goalTime)
while (not (timeControl)):
timeControl = timeCheck(goalTime)
StepperControl.setPosition(1, 1.8, 0)
timeControl = timeCheck(goalTime)
while (not (timeControl)):
timeControl = timeCheck(goalTime)
if __name__ == "__main__":
import time, random, InstrumentControl, sys
arr = [-725, 725]
COMId = 6
StepperControl =InstrumentControl.StepperMotor('COM%d' %COMId)
startTime = time.time()
systemStartTime = time.time()
defaultTime = 900
if(len(sys.argv) > 1):
defaultTime = int(sys.argv[1]) * 60
while (time.time() - systemStartTime < defaultTime):
goalTime = random.randint(5,90)
randomMotor(arr[random.randint(0,1)])
sys.exit(0)