Rev 4716 Rev 4721
Line 53... Line 53...
53 self.spi.xfer([0x10]) 53 self.spi.xfer([0x10])
54 self.spi.xfer([0x06]) # DEC 54 self.spi.xfer([0x06]) # DEC
55 self.spi.xfer([0x00]) 55 self.spi.xfer([0x00])
56 self.spi.xfer([0x10]) 56 self.spi.xfer([0x10])
57 self.spi.xfer([0x0A]) # KVAL_RUN 57 self.spi.xfer([0x0A]) # KVAL_RUN
58 self.spi.xfer([0x20]) 58 self.spi.xfer([0x05])
59 self.spi.xfer([0x0B]) # KVAL_ACC 59 self.spi.xfer([0x0B]) # KVAL_ACC
60 self.spi.xfer([0x20]) 60 self.spi.xfer([0x05])
61 self.spi.xfer([0x0C]) # KVAL_DEC 61 self.spi.xfer([0x0C]) # KVAL_DEC
62 self.spi.xfer([0x20]) 62 self.spi.xfer([0x05])
63 self.spi.xfer([0x18]) # CONFIG 63 # self.spi.xfer([0x18]) # CONFIG
64 self.spi.xfer([0b00111010]) 64 # self.spi.xfer([0b00111010])
65 self.spi.xfer([0b10001000]) 65 # self.spi.xfer([0b10001000])
66 66
67 def MaxSpeed(self, speed): 67 def MaxSpeed(self, speed):
68 'Setup of maximum speed in steps/s' 68 'Setup of maximum speed in steps/s'
69 speed_value = int(speed / 15.25) 69 speed_value = int(speed / 15.25)
70 if (speed_value == 0): 70 if (speed_value == 0):
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(100.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 running = False
187   187  
-   188 while True:
-   189 pass
-   190  
-   191  
188 print "Waiting for IR command.." 192 print "Waiting for IR command.."
189 while True: # set maximal motor speed 193 while True: # set maximal motor speed
190 key = pylirc.nextcode() ## preccessing the IR remote control commands. 194 key = pylirc.nextcode() ## preccessing the IR remote control commands.
191   195  
192 if key == ['start']: 196 if key == ['start']:
Line 212... Line 216...
212 if running == True: 216 if running == True:
213 real_speed = X.Run(direction, requested_speed) 217 real_speed = X.Run(direction, requested_speed)
214 print "Motor running at: %f steps/s" % real_speed 218 print "Motor running at: %f steps/s" % real_speed
215 else: 219 else:
216 X.Reset() 220 X.Reset()
217 X.Initialize() 221 #X.Initialize()
218 X.Float(hard=False) # release power 222 X.Float(hard=False) # release power
219 print "Stopping the motor." 223 print "Stopping the motor."
220   224  
221 except KeyboardInterrupt: 225 except KeyboardInterrupt:
222 print "stop" 226 print "stop"
223 X.Float(hard=False) # release power 227 X.Float(hard=False) # release power
224 sys.exit(0) 228 sys.exit(0)
225   229  
226 except Exception, e: 230 except Exception, e:
227 X.Float(hard=False) # release power 231 # X.Float(hard=False) # release power
228 print >> sys.stderr, "Exception: %s" % str(e) 232 print >> sys.stderr, "Exception: %s" % str(e)
229 sys.exit(1) 233 sys.exit(1)