Rev 4575 Rev 4640
Line 177... Line 177...
177 #spi.SPI_config(spi.I2CSPI_MSB_FIRST| spi.I2CSPI_MODE_CLK_IDLE_HIGH_DATA_EDGE_TRAILING| spi.I2CSPI_CLK_461kHz) 177 #spi.SPI_config(spi.I2CSPI_MSB_FIRST| spi.I2CSPI_MODE_CLK_IDLE_HIGH_DATA_EDGE_TRAILING| spi.I2CSPI_CLK_461kHz)
178 time.sleep(1) 178 time.sleep(1)
179   179  
180 print "Configuring stepper motor.." 180 print "Configuring stepper motor.."
181 X = axis(spi, 0, 1) # set Number of Steps per axis Unit and set Direction of Rotation 181 X = axis(spi, 0, 1) # set Number of Steps per axis Unit and set Direction of Rotation
182 maximum_speed = X.MaxSpeed(200.0) 182 maximum_speed = X.MaxSpeed(100.0)
183 X.GetStatus() 183 X.GetStatus()
184   184  
185 print "Motor speed limit is: %f steps/s" % maximum_speed 185 print "Motor speed limit is: %f steps/s" % maximum_speed
-   186 running = False
186   187  
187 print "Waiting for IR command.." 188 print "Waiting for IR command.."
188 while True: # set maximal motor speed 189 while True: # set maximal motor speed
189 key = pylirc.nextcode() ## preccessing the IR remote control commands. 190 key = pylirc.nextcode() ## preccessing the IR remote control commands.
190   191  
191 if key == ['start']: 192 if key == ['start']:
192 real_speed = X.Run(1, SPEED) 193 running = True
193 print "Motor running at: %f steps/s" % real_speed 194 requested_speed = SPEED
194   195  
195 if key == ['faster']: 196 if key == ['faster']:
-   197 running = True
196 real_speed = X.Run(1, SPEED * 1.2) # runnig the motor at 120% of the base motor speed 198 requested_speed = SPEED * 1.2 # runnig the motor at 120% of the base motor speed
197 print "Motor running at: %f steps/s" % real_speed -  
198   199  
199 if key == ['slower']: 200 if key == ['slower']:
200 real_speed = X.Run(1, SPEED * 0.8) 201 running = True
201 print "Motor running at: %f steps/s" % real_speed 202 requested_speed = SPEED * 0.8
202   203  
203 if key == ['stop']: 204 if key == ['stop']:
-   205 running = False
-   206  
-   207 time.sleep(0.1)
-   208  
-   209 if running == True:
-   210 real_speed = X.Run(1, requested_speed)
-   211 print "Motor running at: %f steps/s" % real_speed
-   212 else:
204 X.Float(hard=False) # release power 213 X.Float(hard=False) # release power
205 print "Stopping the motor." 214 print "Stopping the motor."
206   215  
207 except KeyboardInterrupt: 216 except KeyboardInterrupt:
208 print "stop" 217 print "stop"