Stepper motor vibrates instead of turns :(

tonto2k

Member
Hi,

I have a stepper motor from rs spares which I cant get to turn:

http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=3514647

I have searched all over the forums but have had no luck, the code I have been using is:

' RED +5V
' GREEN +5V
' YELLOW output7
' ORANGE output6
' BROWN output5
' BLACK output4
main:

let pins = %11000000
pause 10
let pins = %01010000
pause 10
let pins = %00110000
pause 10
let pins = %10100000
pause 10

goto main

I changed the wires for what I understand are my wires from the pdf diagram for the stepper motor. When the program is the motor just vibrates? ?

The stepper motor is driven by a 18x power board with L293D driver and 18x chip with 6v input, in the 18 pin board manual it states that the power drops 1.5v would this have anything to do with the stepper not turning?

Any help is much appriciated :)
 

Attachments

alpacaman

Member
I had the same problem with a project I had. It turned out that my pause commands weren't long enough. Change your pause commands to 300. If the motors turn then you can start tweaking the value.
 

ramasule

Member
I dont know much about stepper motors but I will assume by your code it has 4 steps per turn??

if so you should do something like this

150 rpm (googled stepper motor rpm) / 60 spm = 30 rps

2.5 rps * 4 steps per rotation = 10 steps per second

1 / 10 sps = 0.1 seconds per step = pause 100


I have no freakin idea if this is right so dont quote me on it.

but I belive this is the right direction.

Either that or your phasing is wrong. But from just googling i see there is a lot to stepper motors then meets the eye :)

GL have fun.
 

tonto2k

Member
Thanks for the replies,

I changed the pause command to 300, then 100, then everything in between but still no luck.

I then changed the yellow and the black wires around (output 7 and 4) and it started rotating slowly ! :) I reduced the pause between each turn and it sped up.

The code I used to get it going was:

pause 100

step1:
for b0=1 to 100 'CW rotation

high 4 '1
low 5
low 6
low 7
pause 4

high 4 '2
high 5
low 6
low 7
pause 4

low 4 '3
high 5
low 6
low 7
pause 4

low 4 '4
high 5
high 6
low 7
pause 4

low 4 '5
low 5
high 6
low 7
pause 4

low 4 '6
low 5
high 6
high 7
pause 4

low 4 '7
low 5
low 6
high 7
pause 4

high 4 '8
low 5
low 6
high 7
pause 4

next b0

goto step1


Not the neatest of code haha but it is easier to read than %1100 etc. My only problem now is the speed the stepper is not as fast as I imagined.

The stepper motor is connected to a 50-1 ratio gearbox and at what I assume is full speed the output shaft hardly turns at all. Probably my fault for choosing a stepper motor with a high ratio gearbox!

I don't think I will be able to use the stepper for its intended purpose as a drive for a dual stepper drive robot but I have some dc motors with encoders on order so finger crossed :)
 

tonto2k

Member
Actually just looked at the data-sheet and its 2400 steps per revolution at output shaft !

That will be why then haha
 

manuka

Senior Member
Steppers can be pretty confusing for beginners-all those wires! You may get some mileage,both hard & software,from the Electronic Goldmine stepper workout shown => www.picaxe.orconhosting.net.nz/stepdemo.jpg

I can pleasingly verify that many bewildered stepper users have had "Aha" moments after using this.

Of course check the stepper's V & I ratings- some are real power hogs, & won't perform with feeble power supplies. Stan
 
Last edited:

westaust55

Moderator
Actually just looked at the data-sheet and its 2400 steps per revolution at output shaft !

That will be why then haha
Wow - thats some number of steps! I guess that is after the 50:1 gearbox.

Those stepper motors I have seen, are around 1.8 degrees per step so 200 steps per rotation. Virtual no need for a gearbox.

Your numbers suggest 48 steps per motor revolution or 7.5 degree per step. Thats not too bad in terms of the motor.


While your new code is easier for you to read each program step takes around 1ms (average) so reverting to the previous method, with less program steps, now it is all sorted out can help speed up the program and thus the stepper motor speed.

EDIT:
looking at the datasheet you reference though, the 48 step per rev motors draw about one-third of the current of the 200 step per rev motors. A worthwhile saving in terms of power if you do not have a great output torque demand
 
Last edited:

tiscando

Senior Member
commutation:

to get the stepper motor spinning very fast, try this code:
(why is there no pauseus command on others than x1 and x2, yet there is a pulsout command with 10us increments? :confused: )
the pulsout command inverts an output state for a short time (shorter than a pause command)

let w0=1000
for w2=1 to 1000 'CW rotation

low 4,5,6,7 '1
pulsout 4,w0 'high 4 for a short time

low 4,6,7 '2
high 5
pulsout 4,w0

low 4,5,6,7 '3
pulsout 5,w0

low 4,5,7 '4
high 6
pulsout 5,w0

low 4,5,6,7 '5
pulsout 6,w0

low 4,5,6 '6
high 7
pulsout 6,w0

low 4,5,6,7 '7
pulsout 7,w0

low 5,6,7 '8
high 4

if w0>20 then

pulsout 7,w1 'minus the proessing time of the next calculation

let w0=w0*5/6 'decrease the wait time to speed up the motor
let w1=w0-3 'update' the -3 variable

elseif w0>7 then

pulsout 7,w1

let w0=w0*10/11 'decrease the speed-up rate
let w1=w0-3

else
pulsout 7,w0 'if w0 is now <7

endif

next w2

for faster speed use the setfreq m8 at the start of the program.
at 4mhz clock, this should rotate the 200 step per revolution motor at around 25 revolutions per second
 
Last edited:
I'm not entirely sure if this would help you but i think you should take a look at the SAA1027. It's designed to control steppers so the current output should be adaquate (was quite hard to track down a decent datasheet so dont know the exact figure)
But basically you just pulse one of the pins and it will 'step' each time you do so. This makes it pretty easy to control and with the pulsout command you could give it 10us pulses, making it rotate pretty quickly. There is also a pin to control the direction of rotation, depending on it's logic level.

::edit:: here's a datasheet here but the quality isnt great.
 

papaof2

Senior Member
If you click on the reduced size datasheet or the "Click here to view" link, you'll get a readable version.

The SAA1027 is rated at 350ma per output.

John
 
Top