Line 5... |
Line 5... |
5 |
# |
5 |
# |
6 |
# Program uses MLAB Python modules library from https://github.com/MLAB-project/pymlab |
6 |
# Program uses MLAB Python modules library from https://github.com/MLAB-project/pymlab |
7 |
|
7 |
|
8 |
|
8 |
|
9 |
#uncomment for debbug purposes |
9 |
#uncomment for debbug purposes |
10 |
import logging |
10 |
#import logging |
11 |
logging.basicConfig(level=logging.DEBUG) |
11 |
#logging.basicConfig(level=logging.DEBUG) |
12 |
|
12 |
|
13 |
import sys |
13 |
import sys |
14 |
import time |
14 |
import time |
15 |
from pymlab import config |
15 |
from pymlab import config |
16 |
import pylirc # infrared receiver binding |
16 |
import pylirc # infrared receiver binding |
Line 85... |
Line 85... |
85 |
spi.SPI_write_byte(self.CS, 0x10) |
85 |
spi.SPI_write_byte(self.CS, 0x10) |
86 |
spi.SPI_write_byte(self.CS, 0x06) # DEC |
86 |
spi.SPI_write_byte(self.CS, 0x06) # DEC |
87 |
spi.SPI_write_byte(self.CS, 0x00) |
87 |
spi.SPI_write_byte(self.CS, 0x00) |
88 |
spi.SPI_write_byte(self.CS, 0x10) |
88 |
spi.SPI_write_byte(self.CS, 0x10) |
89 |
spi.SPI_write_byte(self.CS, self.L6470_KVAL_RUN) # KVAL_RUN |
89 |
spi.SPI_write_byte(self.CS, self.L6470_KVAL_RUN) # KVAL_RUN |
90 |
spi.SPI_write_byte(self.CS, 0x58) |
90 |
spi.SPI_write_byte(self.CS, 0xF8) |
91 |
spi.SPI_write_byte(self.CS, self.L6470_KVAL_ACC) # KVAL_ACC |
91 |
spi.SPI_write_byte(self.CS, self.L6470_KVAL_ACC) # KVAL_ACC |
92 |
spi.SPI_write_byte(self.CS, 0x58) |
92 |
spi.SPI_write_byte(self.CS, 0xF8) |
93 |
spi.SPI_write_byte(self.CS, self.L6470_KVAL_DEC) # KVAL_DEC |
93 |
spi.SPI_write_byte(self.CS, self.L6470_KVAL_DEC) # KVAL_DEC |
94 |
spi.SPI_write_byte(self.CS, 0x58) |
94 |
spi.SPI_write_byte(self.CS, 0xF8) |
95 |
# spi.SPI_write_byte(self.CS, 0x18) # CONFIG |
95 |
spi.SPI_write_byte(self.CS, 0x18) # CONFIG |
96 |
# spi.SPI_write_byte(self.CS, 0b00111000) |
96 |
spi.SPI_write_byte(self.CS, 0b00101110) |
97 |
# spi.SPI_write_byte(self.CS, 0b00000000) |
97 |
spi.SPI_write_byte(self.CS, 0b10001000) |
98 |
self.MaxSpeed(self.maxspeed) |
98 |
self.MaxSpeed(self.maxspeed) |
99 |
|
99 |
|
100 |
def setKVAL(self, hold = 0.5, run = 0.5, acc = 0.5, dec = 0.5): |
100 |
def setKVAL(self, hold = 0.5, run = 0.5, acc = 0.5, dec = 0.5): |
101 |
""" The available range is from 0 to 0.996 x VS with a resolution of 0.004 x VS """ |
101 |
""" The available range is from 0 to 0.996 x VS with a resolution of 0.004 x VS """ |
102 |
|
102 |
|
Line 273... |
Line 273... |
273 |
requested_speed = SPEED * 1.2 # runnig the motor at 120% of the base motor speed |
273 |
requested_speed = SPEED * 1.2 # runnig the motor at 120% of the base motor speed |
274 |
|
274 |
|
275 |
if key == ['slower']: |
275 |
if key == ['slower']: |
276 |
running = True |
276 |
running = True |
277 |
direction = False |
277 |
direction = False |
278 |
requested_speed = SPEED * 0.2 |
278 |
requested_speed = SPEED * 0.8 |
279 |
|
279 |
|
280 |
if key == ['stop']: |
280 |
if key == ['stop']: |
281 |
running = False |
281 |
running = False |
282 |
|
282 |
|
283 |
time.sleep(0.1) |
283 |
time.sleep(0.1) |