however for some reason it is not working , the tables i copied from the sequence had
A B A' B'
#p16 orange A'
#p17 brown A
#p18 red B
#p19 yellow B'
, and that is the sequence i used as an input , i also tried changing the delay value , and non of these worked am currently kinda lost not knowing where is the problem am using a wipy 3 as my microcontroller , a l298n driver and a st4118L 1804-a nema 17 stepper
Code: Select all
from machine import Pin
import time
# define code initial values (pin1,oin2,pin3,pin4,delay)
def set_stepper(w1,w2,w3,w4,d) :
global delay
delay=d
a=Pin(w1, mode = Pin.OUT)
b=Pin(w2, mode = Pin.OUT)
c=Pin(w3, mode = Pin.OUT)
d=Pin(w4, mode = Pin.OUT)
global pins
pins=[a,b,c,d]
def sequence(*pattern):
for x in range(4):
pins[x].value(pattern[x])
time.sleep(delay)
def step(steps) :
fullsteps = ((0,1,0,1), (0,1,1,0), (1,0,1,0), (1,0,0,1))
for i in range(0, steps):
#looping the the whole sequence once for each step
for pattern in fullsteps:
sequence(*pattern)
def h_step(steps) :
halfsteps = ((0,1,0,1), (0,1,0,0), (0,1,1,0), (0,0,1,0),(1,0,1,0), (1,0,0,0), (1,0,0,1), (0,0,0,1))
#looping the the whole sequence once for each half step
for i in range(0, steps/4 ):
for pattern in halfsteps:
sequence(*pattern)
#def distance() :
# define the number of steps needed to complete the whole axe
#def callibrate(length,end_pin) :
#def dis_fix() :
#p16 orange A'
#p17 brown A
#p18 red B
#p19 yellow B'
set_stepper("P17","P18","P16","P19",0.05)
step( 800 )