Loonhaunt
Posts: 73
Joined: Sat Nov 16, 2013 5:13 am

Re: Controlling a stepper motor with Piface and python

Sat Dec 07, 2013 3:34 am

So this code runs. Is it written in 2.7 python. I get a few syntax errors.

bulletmark
Posts: 121
Joined: Wed Oct 17, 2012 10:10 pm
Location: Brisbane Australia

Re: Controlling a stepper motor with Piface and python

Sat Dec 07, 2013 10:36 pm

Get rid of the semi-colons also, that is not python.

User avatar
wymand
Posts: 48
Joined: Thu Nov 28, 2013 2:06 am
Location: relocating to hiddenridge
Contact: Website Facebook

Re: Controlling a stepper motor with Piface and python

Tue Dec 17, 2013 9:59 pm

I have some 24BYJ48 motors with red, black, yellow, brown, blue wires. any idea how these colors correspond to yours?
Never stop learning
Never stop evolving

User avatar
wymand
Posts: 48
Joined: Thu Nov 28, 2013 2:06 am
Location: relocating to hiddenridge
Contact: Website Facebook

Re: Controlling a stepper motor with Piface and python

Tue Dec 17, 2013 10:36 pm

wymand wrote:I have some 24BYJ48 motors with red, black, yellow, brown, blue wires. any idea how these colors correspond to yours?
DUH... I just looked at your photo of the motor and my motors. It would seem logical to @$$ume that the left to right
leads exiting the motor would correspond . If so, on mine the red (middle wire) would be the common and Blue/Brown
one winding and black/yellow the other. So black would be the same as orange, yellow=yellow, blue=blue and pink=brown.

Gee... I hope I am right :lol:
Never stop learning
Never stop evolving

sesam
Posts: 16
Joined: Sun Apr 28, 2013 7:45 pm

Re: Controlling a stepper motor with Piface and python

Tue Dec 31, 2013 9:21 am

Nice tutorial.

I want to try this with a 4-wire stepper motor from an old optical drive.
This is a bipolar motor, instead of 5 or 6-wire motors with common wire(s).

I read here for bipolar motors:
...the motor itself is simpler but the drive circuitry needed to reverse the polarity of each pair of motor poles is more complex...The drive circuitry for such a motor requires an H-bridge control circuit for each winding
I understand polarity must be changed at the coils for the steps of the rotor.
Most projects I found online use an IC ULN2003 for this.
I also figured that this should be possible with Piface...

Has anyone of you tried this before ?
I would be thankful for responses.

edit:
This topic is strongly correlated to this topic in the forum.
Answers are welcome in both topics, however ;)

sesam
Posts: 16
Joined: Sun Apr 28, 2013 7:45 pm

Re: Controlling a stepper motor with Piface and python

Tue Dec 31, 2013 6:39 pm

Thank you for sharing ideas!
I understand the code in the first post, you can find similar code examples doing a quick Google search.

Maybe it is even possible to adapt this code for bipolar motors, if you adapt the wiring.
Why not introduce the missing common wires on the bipolar motor for yourself with the help of some extra connections and a breadboard.
Do you think this can be done?

I will try to make some sketches in the next days to explain my thoughts.

sesam
Posts: 16
Joined: Sun Apr 28, 2013 7:45 pm

Re: Controlling a stepper motor with Piface and python

Wed Jan 01, 2014 6:00 pm

Please see the attached photo.
It is a 4 wire motor for rotating the shaft where the laser is mounted on. It looks like it expects 5V.

So basically, my problem can be reduced to the following:
How do I construct an H-bridge with Piface ? When I am able to do this, with some slight modifications,
I should be able to use the Python-code.

Basically, the H-bridge should look like this (please see page 17).
And this should be possible to do with the Piface, this has motivated me that it is possible using the relays on the Piface.

This is also shown here.

Unfortunately, I am a really bloody beginner in electronics,
so if you find a principle mistake in my thinking please correct me if I'm wrong.
Attachments
IMG_20140101_183847.jpg
IMG_20140101_183847.jpg (38.47 KiB) Viewed 19144 times

dwarmuth
Posts: 2
Joined: Fri May 23, 2014 10:03 am

Re: Controlling a stepper motor with Piface and python

Fri May 23, 2014 10:08 am

I am new to piface.

I was able to get the code your provided (Instructables was my source) -I no longer have syntax errors and the motor is connected. When I ran the program I entered the values and nothing happens. I expected that the GPIOs would at least light.

What is the next step to see my error?

dwarmuth
Posts: 2
Joined: Fri May 23, 2014 10:03 am

Re: Controlling a stepper motor with Piface and python

Mon May 26, 2014 5:17 pm

Thank you for writing.

I had a bad connection - so I fixed that.

It works now. I am learning with a student who wants to know about the pi and piface - with summer break upon us I hope to have time this summer for pi and piface projects.

kv36
Posts: 6
Joined: Mon Mar 02, 2015 6:39 am

Re: Controlling a stepper motor with Piface and python

Mon Mar 02, 2015 7:02 am

Can 2 stepper motors be controlled using 1 piface?

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Controlling a stepper motor with Piface and python

Mon Mar 02, 2015 7:40 am

No, get yourself a Gertbot. :-)

Well you might be. You have 8 OC outputs but that allows you only to pull lines low.
You can only run stepper motors which have a central tap and then
you get only at half power.
For a most stepper motor you need a H-bridges.
In fact for one stepper motor you need TWO H-bridges.

The Gertbot manual has an appendix which tells a bit about stepper motors.

kv36
Posts: 6
Joined: Mon Mar 02, 2015 6:39 am

Re: Controlling a stepper motor with Piface and python

Mon Mar 02, 2015 8:13 am

i want to control 2 stepper motors with 2 ULN2003. My project is about doing image processing and moving the motor either in clockwise or anticlockwise direction according to the result. I only want to control the number of revolutions in the clockwise or anticlockwise direction. A maximum of 2 revolutions of the motor in both the direction is enough for my project. I don't want to control the speed of the motor nor the angle movement, Please help,I'm new to raspberry pi .

kv36
Posts: 6
Joined: Mon Mar 02, 2015 6:39 am

Re: Controlling a stepper motor with Piface and python

Mon Mar 02, 2015 5:51 pm

It will be nice if you could edit the code for 2 stepper motors and give

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Controlling a stepper motor with Piface and python

Mon Mar 02, 2015 9:49 pm

kv36 wrote:It will be nice if you could edit the code for 2 stepper motors and give
We encourage people NOT to supply full code.
Hints, tips, guidance all that is OK bit not complete ready-made answers.
That is for several reasons:
Writing en finding out yourself is the right way as it allows you to solve
similar bot not 100% identical problems. Also if anything breaks you will be able
to solve it yourself.
Secondly, we see regular requests for answers to problems which or obvious
(or sometimes not so obvious) school assignments or school projects.
It would be totally inappropriate to supply the answers.

asm7100
Posts: 1
Joined: Wed Nov 19, 2014 8:36 am

Re: Controlling a stepper motor with Piface and python

Thu May 14, 2015 2:13 pm

That you are trying to connect is a bipolar stepper motor and you shot use a h-drive to controlle it

:-)

Return to “Automation, sensing and robotics”