Stepper Motor Project


16 posts
by cliffleach01 » Fri Mar 16, 2012 4:36 pm
As soon as I can get hold of a Pi, I'm planning to develop a project for controlling stepper motors plus a simple interface. the objective being to get kids involved in controling physical devices through a simple programatic interface.

I'm keen to collaborate if there is anyione out there that is interested.

Cliff
Posts: 1
Joined: Fri Mar 16, 2012 4:25 pm
by jimmy » Fri Mar 16, 2012 8:23 pm
You'd need to build a 'connector cable', but, there's a shield for the arduino that controls two steppers, two servos and 4 dc motors.  Note, though, that the dc motors and the steppers use the same ports, so you can do say, one stepper and two dc motors or anything in between.  You can find the board here: http://www.adafruit.com/products/81
Posts: 12
Joined: Fri Dec 30, 2011 6:39 pm
by kbalcerek » Fri May 11, 2012 5:41 pm
I am going to buils something similar too :)
Posts: 1
Joined: Fri May 11, 2012 4:36 pm
by Clanzer » Wed Jun 13, 2012 1:51 pm
Yep with you on this one Cliff.

Hopefully I should have my Raspberry Pi by August and should be easy enough to knock up a opto isolated circuit for the I/O lines and run some stepper drivers.

Easy enough to do with Pic Chips and Atmels's to run CNC machines and 3D printers.
Of course these are still being ran by having a PC sending the commands via USB.
Now with the Raspberry Pi we can do away with the PC and have a small all in one dedicated controller.

Writing the Gcode interpreter software for the Raspberry Pi will be the challenge, but looks like access to the I/O ports is easy enough, so should not be too bad.

Cheers

Sean.
******************************
http://www.cncdudez.co.uk
******************************
User avatar
Posts: 3
Joined: Wed Jun 13, 2012 1:42 pm
Location: UK
by pygmy_giant » Thu Jun 21, 2012 9:12 pm
having a crack at this now - got a cheap stepper motor off ebay with controller board - should just be just a case of running a 'mexican wave' across the 4 inputs for 1 step....?
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am
by annodomini2 » Fri Jun 22, 2012 11:13 am
Clanzer wrote:Yep with you on this one Cliff.

Hopefully I should have my Raspberry Pi by August and should be easy enough to knock up a opto isolated circuit for the I/O lines and run some stepper drivers.

Easy enough to do with Pic Chips and Atmels's to run CNC machines and 3D printers.
Of course these are still being ran by having a PC sending the commands via USB.
Now with the Raspberry Pi we can do away with the PC and have a small all in one dedicated controller.

Writing the Gcode interpreter software for the Raspberry Pi will be the challenge, but looks like access to the I/O ports is easy enough, so should not be too bad.

Cheers

Sean.


The main issue will be the real-time element, for which the Pi is not designed.

It's not impossible to simulate, but much harder to do than on something like the Arduino or PIC.

The standard Linux distros will get in the way, you MAY be able to run a real-time linux kernel, but the interrupt controller in the Pi is not designed for RT operation.
Posts: 33
Joined: Sun Feb 05, 2012 12:00 am
by pygmy_giant » Fri Jun 22, 2012 4:42 pm
I'm looking at DEXOS / Puppi / RISCOS to combat that....

... NB - Grumpy Mike's Pi - driven glockenspiel is basically a steppermotor driver board firing solenoids instead of the coils in a stepper motor.
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am
by Patrick Cambria » Mon Jun 25, 2012 12:19 am
I am already stepping stepper motors with my Raspberry Pi using Python
http://youtu.be/5mFdZ9tP6D4?hd=1
Posts: 1
Joined: Mon Jun 25, 2012 12:18 am
by reggie » Mon Jun 25, 2012 7:40 pm
In general, people will put some kind of micro controller between a linux box and their stepper motor controller, this makes it easy to issue some commands to the micro controller via serial, ethernet etc. which is running a realtime system or close enough so that it can do the business of moving the motors smoothly while your linux box stays nice and responsive for you.

I'm interested to see how all these projects pan out, whether it's directly controlling a motor controller with pi gpios or an arduino, pic etc. in between, or just the pi and a rtos running the show :)
Posts: 151
Joined: Fri Aug 26, 2011 11:51 am
by TommyboyNL » Tue Jun 26, 2012 3:00 pm
BitWizard is selling a stepper motor driver with SPI or I2C interface:
I2C: http://www.bitwizard.nl/catalog/product ... ucts_id=83
SPI: http://www.bitwizard.nl/catalog/product ... ucts_id=88

This driver has an on-board controller, which takes all of the timing requirements away from the Pi.
Posts: 48
Joined: Mon Jun 18, 2012 4:37 pm
by pygmy_giant » Tue Jun 26, 2012 10:57 pm
or you can do it via gpio pins. Here is a bash script to demonstrate 28BYJ-48 stepper control. No components are required other than the motor, oft bundled ULN2003 controller board and 6 female to female dupont jumper wires. Total cost off ebay approx £3.00.

Code: Select all
#! /bin/bash

cd

echo # newline
echo "28BYJ-48 Servo test"

# set up SOC GPIO 25, 24, 23, 22 to output
echo "25" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio25/direction
echo "24" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio24/direction
echo "23" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio23/direction
echo "22" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio22/direction

# set timing and no. cycles
delay=0.001
cycles=512

# ripple across pins in 3s
for (( i=1; i<=$cycles; i++ ))
do
echo "0" > /sys/class/gpio/gpio24/value
echo "1" > /sys/class/gpio/gpio25/value
sleep $delay
echo "0" > /sys/class/gpio/gpio23/value
echo "1" > /sys/class/gpio/gpio24/value
sleep $delay
echo "0" > /sys/class/gpio/gpio22/value
echo "1" > /sys/class/gpio/gpio23/value
sleep $delay
echo "0" > /sys/class/gpio/gpio25/value
echo "1" > /sys/class/gpio/gpio22/value
sleep $delay
done

# clean up
echo "0" > /sys/class/gpio/gpio25/value
echo "0" > /sys/class/gpio/gpio24/value
echo "0" > /sys/class/gpio/gpio23/value
echo "0" > /sys/class/gpio/gpio22/value
echo "25" > /sys/class/gpio/unexport
echo "24" > /sys/class/gpio/unexport
echo "23" > /sys/class/gpio/unexport
echo "22" > /sys/class/gpio/unexport


script is slow - probably better off using python, but it demonstrates the principle. motor is also slow - but cheap. By not taking the control away from the pi it demonstrates the priniples of stepper motor operation. I intend to use I2C for an ultrasonic ranger to couple with this to make sonar...

If you want (near) real-time control then I would suggest waiting for beta versions of RISCOS/DexOS/Puppi which are on the horizon or look at altering latency in linux
Last edited by pygmy_giant on Tue Jun 26, 2012 11:13 pm, edited 2 times in total.
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am
by TommyboyNL » Tue Jun 26, 2012 11:03 pm
That solution only works for low-powered (0,5A max per coil) unipolar stepper motors. The BitWizard PCB can handle upto 5A per coil, and can also drive bipolar steppers, and takes control of all the timing. You just tell the unit how many steps to, euh, step, and you're done.
Posts: 48
Joined: Mon Jun 18, 2012 4:37 pm
by pygmy_giant » Tue Jun 26, 2012 11:10 pm
that board maybe ideal for someone else - all I need to do is turn a bit, ping some ultrasound, turn a bit more... no torque required.

I'm a control freak so avoid labour saving devices where possible - would use it if it could pwm / hbridge 2 drive motors though, but not the cheapest solution I've seen - probably superior in some ways - you get what you pay for...
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am
by TommyboyNL » Tue Jun 26, 2012 11:48 pm
The BitWizard board has PWM implemented, so you can control the drive intensity. It can drive one stepper, or two regular motors, but not two steppers (unless they both need to do the same, then they can be connected in parallel). Anyway, for some uses it's an ideal board, and for some, just to fancy :) Good luck with your project!
Posts: 48
Joined: Mon Jun 18, 2012 4:37 pm
by annodomini2 » Wed Jun 27, 2012 9:44 am
TommyboyNL wrote:The BitWizard board has PWM implemented, so you can control the drive intensity. It can drive one stepper, or two regular motors, but not two steppers (unless they both need to do the same, then they can be connected in parallel). Anyway, for some uses it's an ideal board, and for some, just to fancy :) Good luck with your project!


Stepper motors have 2 Coils working together, hence only one stepper per dual H-bridge driver.

You could design software to do microstepping etc, but there are many chips available off the shelf that can do this and use only digital input signals.

E.g. :

http://www.pololu.com/catalog/product/1183
Posts: 33
Joined: Sun Feb 05, 2012 12:00 am
by pygmy_giant » Wed Jul 04, 2012 4:27 pm
A nice gentleman who goes by the name of mkopack seems to be porting ROS: http://www.ros.org/wiki/ viewtopic.php?f=37&t=6552&p=115764&hilit=ROS#p115764

could be good...
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am