Pages: [1]   Go Down
Author Topic: Stepper library with half-steps  (Read 2550 times)
0 Members and 1 Guest are viewing this topic.
Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I changed the stepper library to accept half steps too.

The old constructors stay, so older sketches keep running with my update. I added a constructor to accept a boolean use_half_step:
Code:
Stepper(
int number_of_steps,
int motor_pin_1,
int motor_pin_2,
int motor_pin_3,
int motor_pin_4,
int use_half_step
);
This new constructor sets a private so the function step() can determine if it should use 4- or 8-steps.

This allow a double-precision of stepper motors.

My question:
Anyone interested in taking this in the standard library? Otherwise, I change the name to be my private stepper lib and publish it like that on my site...

John
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds useful.  Can you post a description and a patch to the Google Code issues list: http://code.google.com/p/arduino/issues/list?
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 180
Arduino does the job
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice addition John_NL, Works well, for anyone else trying this you need to remember when declaring the stepper object to double the original step number otherwise it will 'jump' on certain steps.  so if you usually declare:
Stepper myStepper = Stepper(20,2,3,4,5);

for half stepping it should now be:
stepper MyStepper = Stepper(40,2,3,4,5,1);
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys,
This is really cool. How do I get hold of a stepper.h with this feature in it?

I'm working on a controller for focus on a microscope and I was hoping I could add the feature to allow to change the stepping type between the three options (single coil, two coil, and half step). The single coil is smoother than two coil but with less torque and obviously the half step has a higher resolution. I notice that the stepper.h currently only uses two coil driving. I'd like some advice on how to go about writing in this type of functionality and enabling single coil mode just as you have enabled half step mode with the hack you have written about here.

thanks
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot John!

Seems to be working for me.

For Adrian in your Arduino folder there is sub folders hardware libraries and stepper, back up the two stepper.h and .cpp files and replace them with Johns.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thx a lot John,

@Reggie:I think you are wrong,sry. You have to declare the orignal (physical) step numbers which your stepper is able to move.

Yours
Mathias
Logged

Pages: [1]   Go Up
Jump to: