TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

Python + EasyDriver + Stepper motor?

Sun Dec 15, 2013 4:38 pm

Hi all,

I could really use your help guys!
I've looked all day on the internet for the following.

I have a EasyDriver 4.4 and I want to drive a stepper motor
with it on 12v. But I can't find any tutorials on how to operate
it though python.

Any help / links / directions are welcome!

Cheers!

User avatar
DougieLawson
Posts: 35364
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Python + EasyDriver + Stepper motor?

Sun Dec 15, 2013 5:36 pm

Install wiringPi or pigpio or RPi.GPIO (search on here for those).

That gives you a python library that let's you set the GPIO pins high or low.

Then you should be able to do stuff following the Sparkfun instructions.

You will need to connect SJ2 to get it running at 3V3.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

Re: Python + EasyDriver + Stepper motor?

Sun Dec 15, 2013 8:36 pm

Thanks, will look at it!
Is it correct that the jumpers to the RPi GPIO have to have a resistor of 1K Ohm to ground?
Image

I don't see it anywhere but in this example.
Also, don't I need to connect the ground of the RPi to the ground of the motor input?

User avatar
DougieLawson
Posts: 35364
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Python + EasyDriver + Stepper motor?

Sun Dec 15, 2013 8:43 pm

In general all grounds should be connected together. That avoids getting stray voltage differentials.

Whether you need to pull down resistor on your Easydriver depends on the chips used on that board and what happens if you let the signals float. Read the datasheet for it.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Python + EasyDriver + Stepper motor?

Tue Dec 17, 2013 1:00 pm

I've written a module to control the easydriver here https://github.com/davef21370/EasyDriver it's not quite complete but could be useful.

Dave.
Apple say... Monkey do !!

nonlinearmind
Posts: 19
Joined: Thu Dec 13, 2012 3:44 am

Re: Python + EasyDriver + Stepper motor?

Fri Jan 03, 2014 3:34 am

davef21370 wrote:I've written a module to control the easydriver here https://github.com/davef21370/EasyDriver it's not quite complete but could be useful.

Dave.
Could you describe the pin assignments for your easy driver module?
Thanks.

kowetas
Posts: 6
Joined: Mon Dec 02, 2013 11:43 am

Re: Python + EasyDriver + Stepper motor?

Sun Feb 02, 2014 12:56 pm

I don't really know Python that well so I am unsure as to what that script is doing when.

With a stepper motor should I be able to just set the pin to 'on' and that operate the motor provided it is all wired up correctly? I am just trying to test to see if it works how I have set it up at the moment.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Python + EasyDriver + Stepper motor?

Sun Feb 02, 2014 1:48 pm

The motor will take a single step for each pulse on the step pin. To test the board you only need ground and step connected but do make sure the easydriver is set to 3.3V.

Dave.
Apple say... Monkey do !!

eheadj
Posts: 5
Joined: Thu May 22, 2014 5:36 pm

Re: Python + EasyDriver + Stepper motor?

Thu May 22, 2014 5:46 pm

Ok guys, noob here.

I am confused as to where is the SJ2 located on the Easy Driver v4.4 board, for making it compatible with 3V3 RPi logic.

It has MS1, MS2, sleep, gnd and a bunch of other stuff all over but no SJ2.

In this picture:
http://schmalzhaus.com/EasyDriver/EasyD ... er_v44.png

Is it on the lower left corner where it says 3/5V?? That is the only place I figure it is but dont want to fry either the Pi or the Easy Driver
So I ask.

If it is there how and what should I solder??

Thanks..

goofyahead
Posts: 1
Joined: Fri May 23, 2014 7:21 pm

Re: Python + EasyDriver + Stepper motor?

Fri May 23, 2014 7:27 pm

Yep those are the ones that I soldered and at least it didn't explode my version is 4.4 of the easy driver.

I'm putting all together again cause I did not got the same results with arduino at 5v than with the pi on 3.3v and I want to check if its related with that (the steps where not exactly the same to get a loop)

I'll write it down later when I got it working again.

Regards,
Alex

MorePiPlease
Posts: 21
Joined: Mon Nov 05, 2012 1:59 pm

Re: Python + EasyDriver + Stepper motor?

Fri Jan 02, 2015 6:08 pm

Ok so I found an unacceptable amount of help returned from the google query "raspberry pi easy stepper python"

Therefore I bestow unto you (on behalf of rowboboat.com) the following python which will turn your stepper left and right very simply. :o :D :idea: 8-)

Code: Select all

#Step 0: Preamble
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#Code Written by: Salty Scott
#Current Project: www.rowboboat.com
#This code is a very basic example of using python to control a spark fun
# easy driver.  The spark fun easy driver that I am using in this example
# is connected to a 42HS4013A4 stepper motor and my raspberry pi.  Pin 23
# is the direction control and pin 24 is the step control.  I am using
# these components in the www.rowboboat.com project version 2.0 and I
# hope someone finds this a useful and simple example.
#------------------------------------------------------------------------
#------------------------------------------------------------------------

#Step 1: Import necessary libraries 
#------------------------------------------------------------------------
#------------------------------------------------------------------------
import sys
import RPi.GPIO as gpio #https://pypi.python.org/pypi/RPi.GPIO more info
import time
#------------------------------------------------------------------------
#------------------------------------------------------------------------

#Step 2: Read arguements https://www.youtube.com/watch?v=kQFKtI6gn9Y
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#read the direction and number of steps; if steps are 0 exit 
try: 
    direction = sys.argv[1]
    steps = int(float(sys.argv[2]))
except:
    steps = 0

#print which direction and how many steps 
print("You told me to turn %s %s steps.") % (direction, steps)
#------------------------------------------------------------------------
#------------------------------------------------------------------------


#Step 3: Setup the raspberry pi's GPIOs
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#use the broadcom layout for the gpio
gpio.setmode(gpio.BCM)
#GPIO23 = Direction
#GPIO24 = Step
gpio.setup(23, gpio.OUT)
gpio.setup(24, gpio.OUT)
#------------------------------------------------------------------------
#------------------------------------------------------------------------


#Step 4: Set direction of rotation
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#set the direction equal to the appropriate gpio pin
if direction == 'left':
    gpio.output(23, True)
elif direction == 'right':
    gpio.output(23, False)
#------------------------------------------------------------------------
#------------------------------------------------------------------------


#Step 5: Setup step counter and speed control variables
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#track the numebr of steps taken
StepCounter = 0

#waittime controls speed
WaitTime = 0.000001
#------------------------------------------------------------------------
#------------------------------------------------------------------------


#Step 6: Let the magic happen
#------------------------------------------------------------------------
#------------------------------------------------------------------------
# Start main loop
while StepCounter < steps:

    #turning the gpio on and off tells the easy driver to take one step
    gpio.output(24, True)
    gpio.output(24, False)
    StepCounter += 1

    #Wait before taking the next step...this controls rotation speed
    time.sleep(WaitTime)
#------------------------------------------------------------------------
#------------------------------------------------------------------------


#Step 7: Clear the GPIOs so that some other program might enjoy them
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#relase the GPIO
gpio.cleanup()
#------------------------------------------------------------------------
#------------------------------------------------------------------------

j3patel
Posts: 1
Joined: Wed Jun 20, 2018 5:37 am

Re: Python + EasyDriver + Stepper motor?

Wed Jun 20, 2018 5:39 am

This might help

Control stepper motor with mobile | RaspberryPi | EasyDriver

https://www.youtube.com/watch?v=pVSgOyK ... 97Dr0zH5lk

Return to “Python”