Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By fsae99
#47560 Would it be possible to add stepper motor control to ESPBasic?

The Accel version would be nice but even the standard arduino version would be fine.

Regards,
Jim
User avatar
By Mark_msn_
#55569 This code working fine with Stepper motor...

Need connect to pin 15,5,4 and 0 or change to other pins and change to code.

button "Paso" ,[paso1]
wait

[paso1]
For x = 1 to 20
io(po,16,1)
io(po,5,0)
io(po,4,0)
io(po,0,0)
io(po,16,0)
io(po,5,1)
io(po,4,0)
io(po,0,0)
io(po,16,0)
io(po,5,0)
io(po,4,1)
io(po,0,0)
io(po,16,0)
io(po,5,0)
io(po,4,0)
io(po,0,1)
io(po,0,0)
next
wait
User avatar
By livetv
#55586 I think this depends heavily on how the stepper motor is interfaced. If there is an agreed upon interface, this might make sense.

The code Mark_msn posted seems to energize coils directly (presumably through transistors). This would be very different code than if one was using a stepper motor driver (like the step stick). On an ESP8266, I'd save on GOPIs by using stepsticks. If I wanted to drive several stepper motors I'd multiplex the direction and step lines (plus an enable signal on another MUX that needs no GPIO). Just off the top of my head, driving 8 stepper motors might hook up this way:

4 - direction
5 - step
12 - MUX bit 0
13 - MUX bit 1
14 - MUX bit 2

Code might look like this:

Code: Select all[moveMotor]
' Variables you meed to set:
'    ID - stepper motor id, 0 to 7
'    DIRECTION - 1 = forward, 0 = reverse
'    STEPS - Number of steps to go
'    STEPDELAY - milliseconds to delay between steps

' Start by setting multiplexers to address the correct stepper motor driver
if id>3 then io(po,14,1) else io(po,14,0)
if (id and 2) >0 then io(po,13,1) else io(po,13,0)
if (id and 1) >0 then io(po,12,1) else io(po,12,0)

' Set direction
io(po,4,direction)

' Perform all requested steps
for stepcount=1 to steps
  io(po,5,1)
  io(po,5,0)
  delay stepdelay
  next stepcounter
return


This is generic code, not taking into account specific requirements of the various dirt cheap stepper motor driver boards out there, but the concept is quite simple and may work with little or no modification. More sophisticated code could move motors simultaneously. How fast would this go? The current speed of the IO() function is about 4ms each. That plus the delay and loop would probably limit you to 100 steps per second at very best. For drivers that do microstepping, this could get a bit slow but It's a fairly easy interface and code for 8 stepper motors!
User avatar
By Oldbod
#55894 Interesting topic. I tend to think of stepper motors and cnc, but tht's obviously only one aspect. I'm wondering what the context of the request is?