Line 156... |
Line 156... |
156 |
|
156 |
|
157 |
def GetStatus(self): |
157 |
def GetStatus(self): |
158 |
#self.spi.xfer([0b11010000]) # Get status command from datasheet - does not work for uknown rasons |
158 |
#self.spi.xfer([0b11010000]) # Get status command from datasheet - does not work for uknown rasons |
159 |
spi.SPI_write_byte(self.CS, 0x39) # Gotparam command on status register |
159 |
spi.SPI_write_byte(self.CS, 0x39) # Gotparam command on status register |
160 |
spi.SPI_write_byte(self.CS, 0x00) |
160 |
spi.SPI_write_byte(self.CS, 0x00) |
161 |
data = spi.SPI_read_byte() |
161 |
data = [spi.SPI_read_byte()] |
162 |
spi.SPI_write_byte(self.CS, 0x00) |
162 |
spi.SPI_write_byte(self.CS, 0x00) |
163 |
data = data + spi.SPI_read_byte() |
163 |
data = data + [spi.SPI_read_byte()] |
164 |
|
164 |
|
165 |
status = dict([('SCK_MOD',data[0] & 0x80 == 0x80), #The SCK_MOD bit is an active high flag indicating that the device is working in Step-clock mode. In this case the step-clock signal should be provided through the STCK input pin. The DIR bit indicates the current motor direction |
165 |
status = dict([('SCK_MOD',data[0] & 0x80 == 0x80), #The SCK_MOD bit is an active high flag indicating that the device is working in Step-clock mode. In this case the step-clock signal should be provided through the STCK input pin. The DIR bit indicates the current motor direction |
166 |
('STEP_LOSS_B',data[0] & 0x40 == 0x40), |
166 |
('STEP_LOSS_B',data[0] & 0x40 == 0x40), |
167 |
('STEP_LOSS_A',data[0] & 0x20 == 0x20), |
167 |
('STEP_LOSS_A',data[0] & 0x20 == 0x20), |
168 |
('OCD',data[0] & 0x10 == 0x10), |
168 |
('OCD',data[0] & 0x10 == 0x10), |
Line 183... |
Line 183... |
183 |
# self.spi.xfer([0x29]) # Gotparam command on status register |
183 |
# self.spi.xfer([0x29]) # Gotparam command on status register |
184 |
spi.SPI_write_byte(self.CS, self.L6470_ACC + 0x20) # TODO check register read address seting |
184 |
spi.SPI_write_byte(self.CS, self.L6470_ACC + 0x20) # TODO check register read address seting |
185 |
spi.SPI_write_byte(self.CS, 0x00) |
185 |
spi.SPI_write_byte(self.CS, 0x00) |
186 |
data = spi.SPI_read_byte() |
186 |
data = spi.SPI_read_byte() |
187 |
spi.SPI_write_byte(self.CS, 0x00) |
187 |
spi.SPI_write_byte(self.CS, 0x00) |
188 |
data = data + self.spi.readbytes(1) |
188 |
data = data + [spi.SPI_read_byte()] |
189 |
print data # return speed in real units |
189 |
print data # return speed in real units |
190 |
|
190 |
|
191 |
|
191 |
|
192 |
def Move(self, units): |
192 |
def Move(self, units): |
193 |
' Move some distance units from current position ' |
193 |
' Move some distance units from current position ' |