Rev 4449 Rev 4450
Line 26... Line 26...
26 elif len(sys.argv) == 2: 26 elif len(sys.argv) == 2:
27 PORT = eval(sys.argv[1]) 27 PORT = eval(sys.argv[1])
28 SPEED = 5 28 SPEED = 5
29 DISTANCE = 50 29 DISTANCE = 50
30   30  
31 elif len(sys.argv) > 2: 31 elif len(sys.argv) == 3:
32 SPEED = eval(sys.argv[2]) 32 SPEED = eval(sys.argv[2])
33 DISTANCE = 100 33 DISTANCE = 100
34   34  
35 elif len(sys.argv) > 3: 35 elif len(sys.argv) == 4:
36 SPEED = eval(sys.argv[2]) 36 SPEED = eval(sys.argv[2])
37 DISTANCE = eval(sys.argv[3]) 37 DISTANCE = eval(sys.argv[3])
38   38  
39 else: 39 else:
40 PORT = 0 40 PORT = 0
41 SPEED = 10 41 SPEED = 10
42 DISTANCE = 100 42 DISTANCE = 50
43   43  
44   44  
45 class axis: 45 class axis:
46 def __init__(self, SPI_CS, Direction, StepsPerUnit): 46 def __init__(self, SPI_CS, Direction, StepsPerUnit):
47 ' One axis of robot ' 47 ' One axis of robot '
Line 166... Line 166...
166   166  
167   167  
168 cfg.initialize() 168 cfg.initialize()
169   169  
170 print "Stepper motor control test started. \r\n" 170 print "Stepper motor control test started. \r\n"
-   171 print "Max motor speed: %d " % SPEED
-   172 print "Distance to run: %d " % DISTANCE
171   173  
172 spi = cfg.get_device("spi") 174 spi = cfg.get_device("spi")
173   175  
174 spi.route() 176 spi.route()
175   177  
Line 183... Line 185...
183 X.MaxSpeed(SPEED) # set maximal motor speed 185 X.MaxSpeed(SPEED) # set maximal motor speed
184   186  
185 print "Axis is running" 187 print "Axis is running"
186   188  
187 for i in range(5): 189 for i in range(5):
-   190 print i
188 X.MoveWait(DISTANCE) # move forward and wait for motor stop 191 X.MoveWait(DISTANCE) # move forward and wait for motor stop
-   192 print "Changing direction of rotation.."
189 X.MoveWait(-DISTANCE) # move backward and wait for motor stop 193 X.MoveWait(-DISTANCE) # move backward and wait for motor stop
-   194 print "Changing direction of rotation.."
190   195  
191 X.Float() # release power 196 X.Float() # release power
192   197  
193   198  
194 finally: 199 finally: