A few days ago, I use example about 4-phase stepper motor
and see that motor is running.
Next, I wanted to run the 2-phase stepper motor at same way.
So, I modify some code of steps and connect pyboard and 2-phase stepper motor driver.
Code: Select all
import pyb
class Stepper:
steps = [
[1, 2],
[2, 3],
[3, 4],
[1, 4],
[1, 2],
[2, 3],
[3, 4],
[1, 4]
]
step_delay_ms = 1
def __init__(self, pins):
self.pins = [pyb.Pin(pin, pyb.Pin.OUT_PP) for pin in pins]
self.current_step = 0
def do_step(self):
self._low_on_all()
self._high_on_step_pins()
self._record_step()
pyb.delay(self.step_delay_ms)
def _low_on_all(self):
for pin in self.pins:
pin.low()
def _high_on_step_pins(self):
high_pins = self.steps[self.current_step]
for pin_number in high_pins:
self.pins[pin_number - 1].high()
def _record_step(self):
self.current_step += 1
if self.current_step == len(self.steps):
self.current_step = 0
Code: Select all
import pyb
from Stepper_2phase import *
motor = Stepper(['X1', 'X2', 'X3', 'X4'])
for i in range(4000):
motor.do_step()
I think that connecting between pyboard and motor driver is correct(I referred motor driver manual).
I don't understand this situation. I just modified steps code.
Please give me some tips about this problem.
Thanks.