Page 1 of 1

Python + EasyDriver + Stepper motor?

Posted: Sun Dec 15, 2013 4:38 pm
by TimmR
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!

Re: Python + EasyDriver + Stepper motor?

Posted: Sun Dec 15, 2013 5:36 pm
by DougieLawson
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.

Re: Python + EasyDriver + Stepper motor?

Posted: Sun Dec 15, 2013 8:36 pm
by TimmR
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?

Re: Python + EasyDriver + Stepper motor?

Posted: Sun Dec 15, 2013 8:43 pm
by DougieLawson
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.

Re: Python + EasyDriver + Stepper motor?

Posted: Tue Dec 17, 2013 1:00 pm
by davef21370
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.

Re: Python + EasyDriver + Stepper motor?

Posted: Fri Jan 03, 2014 3:34 am
by nonlinearmind
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.

Re: Python + EasyDriver + Stepper motor?

Posted: Sun Feb 02, 2014 12:56 pm
by kowetas
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.

Re: Python + EasyDriver + Stepper motor?

Posted: Sun Feb 02, 2014 1:48 pm
by davef21370
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.

Re: Python + EasyDriver + Stepper motor?

Posted: Thu May 22, 2014 5:46 pm
by eheadj
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..

Re: Python + EasyDriver + Stepper motor?

Posted: Fri May 23, 2014 7:27 pm
by goofyahead
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

Re: Python + EasyDriver + Stepper motor?

Posted: Fri Jan 02, 2015 6:08 pm
by MorePiPlease
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()
#------------------------------------------------------------------------
#------------------------------------------------------------------------

Re: Python + EasyDriver + Stepper motor?

Posted: Wed Jun 20, 2018 5:39 am
by j3patel
This might help

Control stepper motor with mobile | RaspberryPi | EasyDriver

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