Line 189... |
Line 189... |
189 |
while True: # set maximal motor speed |
189 |
while True: # set maximal motor speed |
190 |
key = pylirc.nextcode() ## preccessing the IR remote control commands. |
190 |
key = pylirc.nextcode() ## preccessing the IR remote control commands. |
191 |
|
191 |
|
192 |
if key == ['start']: |
192 |
if key == ['start']: |
193 |
running = True |
193 |
running = True |
- |
|
194 |
direction = True |
194 |
requested_speed = SPEED |
195 |
requested_speed = SPEED |
195 |
|
196 |
|
196 |
if key == ['faster']: |
197 |
if key == ['faster']: |
197 |
running = True |
198 |
running = True |
- |
|
199 |
direction = True |
198 |
requested_speed = SPEED * 1.2 # runnig the motor at 120% of the base motor speed |
200 |
requested_speed = SPEED * 1.2 # runnig the motor at 120% of the base motor speed |
199 |
|
201 |
|
200 |
if key == ['slower']: |
202 |
if key == ['slower']: |
201 |
running = True |
203 |
running = True |
- |
|
204 |
direction = False |
202 |
requested_speed = SPEED * -1.2 |
205 |
requested_speed = SPEED * 0.2 |
203 |
|
206 |
|
204 |
if key == ['stop']: |
207 |
if key == ['stop']: |
205 |
running = False |
208 |
running = False |
206 |
|
209 |
|
207 |
time.sleep(0.1) |
210 |
time.sleep(0.1) |
208 |
|
211 |
|
209 |
if running == True: |
212 |
if running == True: |
210 |
real_speed = X.Run(1, requested_speed) |
213 |
real_speed = X.Run(direction, requested_speed) |
211 |
print "Motor running at: %f steps/s" % real_speed |
214 |
print "Motor running at: %f steps/s" % real_speed |
212 |
else: |
215 |
else: |
213 |
X.Reset() |
216 |
X.Reset() |
214 |
X.Initialize() |
217 |
X.Initialize() |
215 |
X.Float(hard=False) # release power |
218 |
X.Float(hard=False) # release power |