Unipolar stepper motor turning problem

Shouldn’t this be:

Code:
for(i=1; i<=1020; i++)

You’re right. I modified my code.

48 steps for one full rotation of the main motor, and a gearratio of 85

that is 4080 steps for one rotation of the geared axle.

It works. I tried the script kitep gave and it worked.

I'm glad someone else spotted the 85:1 gear ratio. Otherwise I wouldn't have had it step so many steps and it would still look like it wasn't working.

Thx again for that! But now I am still wondering on how little I can make the delay value until it harms the motor? Is there anything in the hardware or something I need to look at for this?

It probably won't harm the motor, the motor just might stop turning. Think of it this way:

When you had the longer delay in there, the motor was stepping much slower, right? There was enough time between steps for the rotor to turn and lock into place for each step. As you increase the stepping rate, the motor has less and less time to move to the next position before the next step occurs.

If your code gets ahead of the motor, the motor will likely "cog" where it is at, and just sort of "vibrate" in place, or it will "hitch" along at a much slower pace, maybe even in a semi-random manner (stepping sometimes, and not the next).

If you look on the Velleman site, it gives the specs for the max stepping rates for the motor:

  • max. starting pulse rate: 350pps
  • max. slewing pulse rate: 800pps

Basically, this means to start the motor (from a dead stop), you can send a maximum of 350 pulses-per-second, and it will start; once the motor is turning, you can increase this to 800 pulse-per-second. If you tried to run it from a dead stop at 800 pps, it would probably exhibit that "cogging" issue I was talkiing about; in effect, you need to ramp the speed up from 350 pps to 800 pps - something that real stepper controllers are capable of, and which you can incorporate into your code, if you wish (that, or just keep the delay for what is needed to stay under 350 pps).

:)

Thanks! It works quite well now.