Line 84... |
Line 84... |
84 |
""" switch H-bridge to High impedance state """ |
84 |
""" switch H-bridge to High impedance state """ |
85 |
spi.SPI_write(self.CS, [0xA0]) |
85 |
spi.SPI_write(self.CS, [0xA0]) |
86 |
|
86 |
|
87 |
def ReadStatusBit(self, bit): |
87 |
def ReadStatusBit(self, bit): |
88 |
""" Report given status bit """ |
88 |
""" Report given status bit """ |
- |
|
89 |
try: |
89 |
spi.SPI_write(self.CS, [0x39]) # Read from address 0x19 (STATUS) |
90 |
spi.SPI_write(self.CS, [0x39]) # Read from address 0x19 (STATUS) |
90 |
time.sleep(0.2) |
91 |
spi.SPI_write(self.CS, [0x00]) |
- |
|
92 |
data = spi.SPI_read(1) # 1st byte |
91 |
spi.SPI_write(self.CS, [0x00]) |
93 |
spi.SPI_write(self.CS, [0x00]) |
92 |
data = spi.SPI_read(1) # 1st byte |
94 |
data.extend(spi.SPI_read(1)) # 2nd byte |
- |
|
95 |
if bit > 7: # extract requested bit |
- |
|
96 |
OutputBit = (data[0] >> (bit - 8)) & 1 |
93 |
time.sleep(0.2) |
97 |
else: |
- |
|
98 |
OutputBit = (data[1] >> bit) & 1 |
- |
|
99 |
return OutputBit |
- |
|
100 |
except IOError(): ### TODO |
- |
|
101 |
spi.SPI_write(self.CS, [0x39]) # Read from address 0x19 (STATUS) |
94 |
spi.SPI_write(self.CS, [0x00]) |
102 |
spi.SPI_write(self.CS, [0x00]) |
95 |
data.extend(spi.SPI_read(1)) # 2nd byte |
103 |
data = spi.SPI_read(1) # 1st byte |
96 |
time.sleep(0.2) |
104 |
spi.SPI_write(self.CS, [0x00]) |
- |
|
105 |
data.extend(spi.SPI_read(1)) # 2nd byte |
97 |
if bit > 7: # extract requested bit |
106 |
if bit > 7: # extract requested bit |
98 |
OutputBit = (data[0] >> (bit - 8)) & 1 |
107 |
OutputBit = (data[0] >> (bit - 8)) & 1 |
99 |
else: |
108 |
else: |
100 |
OutputBit = (data[1] >> bit) & 1 |
109 |
OutputBit = (data[1] >> bit) & 1 |
101 |
return OutputBit |
110 |
return OutputBit |
- |
|
111 |
finally: |
- |
|
112 |
pass |
102 |
|
113 |
|
- |
|
114 |
|
103 |
def IsBusy(self): |
115 |
def IsBusy(self): |
104 |
""" Return True if tehre are motion """ |
116 |
""" Return True if tehre are motion """ |
105 |
if self.ReadStatusBit(1) == 1: |
117 |
if self.ReadStatusBit(1) == 1: |
106 |
return False |
118 |
return False |
107 |
else: |
119 |
else: |
Line 145... |
Line 157... |
145 |
X.GoZero(20) |
157 |
X.GoZero(20) |
146 |
Y.GoZero(20) |
158 |
Y.GoZero(20) |
147 |
|
159 |
|
148 |
time.sleep(1) |
160 |
time.sleep(1) |
149 |
|
161 |
|
150 |
X.Move(50*XSMM) |
162 |
X.Move(30*XSMM) |
151 |
Y.Move(50*YSMM) |
163 |
Y.Move(50*YSMM) |
152 |
Z.MoveWait(50*ZSMM) |
164 |
Z.MoveWait(58*ZSMM) |
- |
|
165 |
X.Move(50*XSMM) |
153 |
|
166 |
|
154 |
print "Robot is running" |
167 |
print "Robot is running" |
155 |
|
168 |
|
156 |
for y in range(5): |
169 |
for y in range(5): |
157 |
for x in range(5): |
170 |
for x in range(5): |
158 |
Z.MoveWait(8*ZSMM) |
171 |
Z.MoveWait(5*ZSMM) |
159 |
time.sleep(1) |
172 |
time.sleep(1) |
160 |
Z.MoveWait(-8*ZSMM) |
173 |
Z.MoveWait(-5*ZSMM) |
- |
|
174 |
if x < 4: |
161 |
X.MoveWait(8*XSMM) |
175 |
X.MoveWait(8*XSMM) |
162 |
Y.MoveWait(8*YSMM) |
176 |
Y.MoveWait(8*YSMM) |
163 |
for x in range(5): |
177 |
for x in range(5): |
164 |
Z.MoveWait(8*ZSMM) |
178 |
Z.MoveWait(5*ZSMM) |
165 |
time.sleep(1) |
179 |
time.sleep(1) |
166 |
Z.MoveWait(-8*ZSMM) |
180 |
Z.MoveWait(-5*ZSMM) |
- |
|
181 |
if x < 4: |
167 |
X.MoveWait(-8*XSMM) |
182 |
X.MoveWait(-8*XSMM) |
168 |
Y.MoveWait(8*YSMM) |
183 |
Y.MoveWait(8*YSMM) |
169 |
|
184 |
|
- |
|
185 |
X.MoveWait(-20*XSMM) |
170 |
Z.MoveWait(-30*ZSMM) |
186 |
Z.MoveWait(-30*ZSMM) |
171 |
X.Float() |
187 |
X.Float() |
172 |
Y.Float() |
188 |
Y.Float() |
173 |
Z.Float() |
189 |
Z.Float() |
174 |
|
190 |
|