/Designs/ROBOTS/IRRAD01A/SW/irrad.py
86,20 → 86,32
 
def ReadStatusBit(self, bit):
""" Report given status bit """
spi.SPI_write(self.CS, [0x39]) # Read from address 0x19 (STATUS)
time.sleep(0.2)
spi.SPI_write(self.CS, [0x00])
data = spi.SPI_read(1) # 1st byte
time.sleep(0.2)
spi.SPI_write(self.CS, [0x00])
data.extend(spi.SPI_read(1)) # 2nd byte
time.sleep(0.2)
if bit > 7: # extract requested bit
OutputBit = (data[0] >> (bit - 8)) & 1
else:
OutputBit = (data[1] >> bit) & 1
return OutputBit
try:
spi.SPI_write(self.CS, [0x39]) # Read from address 0x19 (STATUS)
spi.SPI_write(self.CS, [0x00])
data = spi.SPI_read(1) # 1st byte
spi.SPI_write(self.CS, [0x00])
data.extend(spi.SPI_read(1)) # 2nd byte
if bit > 7: # extract requested bit
OutputBit = (data[0] >> (bit - 8)) & 1
else:
OutputBit = (data[1] >> bit) & 1
return OutputBit
except IOError(): ### TODO
spi.SPI_write(self.CS, [0x39]) # Read from address 0x19 (STATUS)
spi.SPI_write(self.CS, [0x00])
data = spi.SPI_read(1) # 1st byte
spi.SPI_write(self.CS, [0x00])
data.extend(spi.SPI_read(1)) # 2nd byte
if bit > 7: # extract requested bit
OutputBit = (data[0] >> (bit - 8)) & 1
else:
OutputBit = (data[1] >> bit) & 1
return OutputBit
finally:
pass
 
def IsBusy(self):
""" Return True if tehre are motion """
if self.ReadStatusBit(1) == 1:
147,26 → 159,30
 
time.sleep(1)
 
X.Move(30*XSMM)
Y.Move(50*YSMM)
Z.MoveWait(58*ZSMM)
X.Move(50*XSMM)
Y.Move(50*YSMM)
Z.MoveWait(50*ZSMM)
print "Robot is running"
 
for y in range(5):
for x in range(5):
Z.MoveWait(8*ZSMM)
Z.MoveWait(5*ZSMM)
time.sleep(1)
Z.MoveWait(-8*ZSMM)
X.MoveWait(8*XSMM)
Z.MoveWait(-5*ZSMM)
if x < 4:
X.MoveWait(8*XSMM)
Y.MoveWait(8*YSMM)
for x in range(5):
Z.MoveWait(8*ZSMM)
Z.MoveWait(5*ZSMM)
time.sleep(1)
Z.MoveWait(-8*ZSMM)
X.MoveWait(-8*XSMM)
Z.MoveWait(-5*ZSMM)
if x < 4:
X.MoveWait(-8*XSMM)
Y.MoveWait(8*YSMM)
 
X.MoveWait(-20*XSMM)
Z.MoveWait(-30*ZSMM)
X.Float()
Y.Float()