Uno+Easydriver stepper rpm

Hello everybody. My first post.

I'm trying to motorize my diy wooden "star tracker". I did everything just like on this site: http://fstop138.berrange.com/2014/01/building-an-barn-door-mount-part-1-arduino-stepper-motor-control/

It' s working, but I can't fine tune the rpm of the motor.

So now I connected this small 28BYJ-48 stepper with 1:64 gear and i have changed it to run Halfstep. But it didn't change anything.

I still can't fine tune rpm. The motor must turn 4 times every 60 second - to follow the moving stars. I can tune it to run 4 turnes in 59 sec or 61 sec, but not 60 sec.

A few examples:

I'm changing the stepper.setSpeed value with 1 unit but the rpm are not changing every time. From setSpeed 300 to setSpeed 279 the rpm are the same.

stepper.setSpeed - seconds

310 - 53 sec. 300 - 59 sec. 280 - 59 sec. 279 - 59 sec. 278 - 61 sec.

So I need the setSpeed somewhere between 279 and 278 to hit the 60 seconds. 278.5 doesn't work.

Could someone tell me how to fix that?

Thanks

Here is a video of one of the first tests. Everything was shaking, but it runs much smoother now. I was so happy to se it work so I recorded the video :-) I just can't hit the 60 seconds.

The small gear on the motor must rotate 4 times pr. minutte so the large gear is rotating 1 round pr. minutte.

https://www.youtube.com/watch?v=Dvncvk4cke4 - with Nema 17 motor, shaking, vibrating, the steps are to "powerfull".

https://www.youtube.com/watch?v=LKghsEQiRq8 - the small motor with 1:64 gear.

https://www.youtube.com/watch?v=iKdpCSFcwsc - the small motor mounted. It's very quiet now and without vibrations.

As you have not posted your code it is impossible to know what the problem is.

How many steps per second do you require for the desired output speed?

If you write code that can move the motor one step or one half step then you can make those steps happen at any interval you like with precision better than one millisecond.

...R Stepper Motor Basics

Thanks Robin2

The code is on this site. I just copy/past the code and i'm trying to understand it. http://fstop138.berrange.com/2014/01/building-an-barn-door-mount-part-1-arduino-stepper-motor-control/

The motor I'm using is 28BYJ-48. 64 steps pr. turn and 64:1 gearbox. That gives 4096 steps pr. turn. And it runs half step so it's 8192 steps pr. turn. But people are writing that the gearbox is not exactly 64:1.

I think the code is running 200steps motor with 1/8 microsteps of the driver, 1600 steps. That´s what the designer did, with nema 17 motor. And that's what I did the first time, but the motor was to powerfull for this purpose, my camera was shaking, and I couldnt fine tune the rpm.

So I thought, if I add 64:1 gearbox (inside the small stepmotor), it should be possible to finetune, but it's not.

And I have no idea where to change steps of the motor in the code. Is it somewhere in th AccelStepper library? There is 13 different code examples in that library.

I'm used to use Mach3 and it's only asking for motor steps pr. 1 unit of movement of the axis. Nothing there about timing or timing between steps. Then you type how fast you want it to run pr. minutte in the Gcode.

So I'm realy confused about timing with Arduino. I know how many steps the motor and the gearbox is turning with half step on Easydriver, but how fast it's turning pr minutte, I dont know.

I read about it and trying to compare different codes, but it goes very slow to understand it.

Aro1: The code is on this site.

When it appears on this site I will be happy to look at it.

...R

Ok, thanks.

I have been trying different codes all day.
As you suggested many times to controll delay between steps, I have found a code which is working.
I’m still testing, but it’s very close to 1 turn pr. 60 seconds.
It takes 20minuttes and 1 second to turn the large gear 20 times with 444.7 microSec delay.
I hope it will accept some more decimals.

The code is running 1 revolution forth and 1 revolution back. If I can fine-tune the last microseconds maybe I will need some help to remove the “both ways loop” so it’s running only one way. For now I have typed a large number of steps, so it never turnes back.

/*

 Stepper Motor Control - one rev back and forth

 This program is for the SparkFun Easy motor driver board.

 This program drives a bipolar stepper motor.
 The motor is attached to ground plus digital pins 8 and 9 of the Arduino.

 The motor should revolve one revolution in one direction, then
 one revolution in the other direction at a speed determined by 
 the milliseconds in the microSecDelay variable.

 Created by Bill Harper, Feb. 10 2014
 
 */

#include <Stepper.h>
int oneway;                      // counter for steps
int onerev = 32606.182;          // number of steps each direction (edit this for your particular motor)

int microSecDelay = 444.7;         // delay between steps and speed of the motor(about as fast as the system can react,higher number = slower)
int dirPin = 8;                  // output pin for stepper motor direction
int stepPin = 9;                 // output pin for the pin used to step the motor

void setup() {                
  pinMode(dirPin, OUTPUT);       // Assign output mode to pin for direction
  pinMode(stepPin, OUTPUT);      // Assign output mode to pin for setp
  digitalWrite(dirPin, LOW);     // Initialize dir pin 
  digitalWrite(stepPin, LOW);    // Initialize step pin
  oneway = 1;
}

void loop() {
  if (oneway < onerev + 1)            // Still in first revolution?
    {
      digitalWrite(dirPin, LOW);      // Keep direction pin low
    }
  else
    {
      digitalWrite(dirPin, HIGH);    // If not in first revolution change direction pin to High
    }

  digitalWrite(stepPin, HIGH);       // Step motor
  delayMicroseconds(microSecDelay);  // Wait microseconds
  digitalWrite(stepPin, LOW);        // Step motor
  delayMicroseconds(microSecDelay);  // Wait microseconds

  oneway += 1;                       // Increment direction counter

  if (oneway > onerev * 2)           // If we have exceeded two revolutions
    { oneway = 1; }                  // Reset counter to start over again
  
}                                    // EOF

The motor I'm using is 28BYJ-48. 64 steps pr. turn and 64:1 gearbox. That gives 4096 steps pr. turn. And it runs half step so it's 8192 steps pr. turn.

That motor is a unipolar motor, and should not be used with the Easydriver, which is for bipolar motors. A unipolar motor can't be used for microstepping with the Easydriver.

If you buy those motors on eBay they come with a very simple unipolar motor driver that works well with Arduino. You can set any time you like for one step, up to a maximum speed, and it should be perfect for a camera drive.

The gear ratio of that motor is not 64:1, and in fact the number of steps per revolution is not an integer. See that link for code.

int microSecDelay = 444.7;

An int cannot take a decimal. That will be treated as 444. Also, delayMicroseconds() cannot take a decimal.

You might need to run N steps with an interval of 445 and an occasional step with an interval of 444 to correct any accumulated error.

And using delay() cannot take account of the time to run the rest of the code in loop() whereas if you use micros() to manage the timing (as illustrated in the second example in this Simple Stepper Code) you can take account of the entire time between steps. Just be aware that micros() increments in steps of 4 µsecs.

...R

Thanks jremington and Robin2

I have allready order the byi motor with driver 2 weeks ago, but I don't think it will work with the 63.xxx :1 gearbox.

So I was hunting integers today :-)

I was looking at the small, cute Nema 8 motors with planetary gears, like 5:1. But if you read the specification, it's 4 + 3/4 :1 All the planetary gears are "+ decimals".

Now I'm lookin at the worm gear. Does anybody know the gear ratio? It looks like 50:1

http://www.ebay.com/itm/NEW-Metal-Worm-Wheel-Plastic-Gear-Reducer-Reduction-Gear-set-for-DIY-Accessories-/151627985149?hash=item234dbb70fd:g:TpcAAOSwqu9VEB3M

With 200 steps motor, half step, 50:1 worm gear, my plywood 4:1 gear it's 80.000 steps per revolution. And with 60 seconds/revolution, the time between steps will be 750 microseconds. Are my calculations right?

80.000 steps/min is 1333 steps/sec - that's about 3 motor revolutions per second, so it's ok.

I have allready order the byi motor with driver 2 weeks ago, but I don't think it will work with the 63.xxx :1 gearbox.

It will work perfectly. There is no reason to have integer gear ratios.

The [u]only[/u] things that matter are the movement per step that the drive screw for your star tracker causes, and the time between steps.

Ok, I will try the motor with driver when I receive it.

But as I see it, when I use a program where I choose the number of steps, the timing is wrong. And when I use a program where I control the timing, the steps are wrong. That's a bad loop :-)

when I use a program where I choose the number of steps, the timing is wrong. And when I use a program where I control the timing, the steps are wrong.

Write a different program, where you control both the number of steps and the timing. Very simple.

jremington: Write a different program, where you control both the number of steps and the timing. Very simple.

Which is what the Simple Stepper Code (that I recommended to the OP in Reply #7) does.

...R

I recieved the 28BYJ-48 stepper with ULN2003 driver.

Robin2 - your codes are for bipolar motor and driver, and I have unipolar motor and driver now, as jremington sugested. I don't know how to mix your code with unipolar driver code.

So I have found a code for unipolar driver to control delay between steps. It didn't help. I don't know how to fine-tune the rpm without decimals.

Here is the code I'm trying now and delay time must be somewhere between 7 and 8.

/* Stepper Copal
 * -------------
 *
 * Program to drive a stepper motor coming from a 5'25 disk drive
 * according to the documentation I found, this stepper: "[...] motor 
 * made by Copal Electronics, with 1.8 degrees per step and 96 ohms 
 * per winding, with center taps brought out to separate leads [...]"
 * [http://www.cs.uiowa.edu/~jones/step/example.html]
 *
 * It is a unipolar stepper motor with 5 wires:
 * 
 * - red: power connector, I have it at 5V and works fine
 * - orange and black: coil 1
 * - brown and yellow: coil 2
 *
 * (cleft) 2005 DojoDave for K3
 * http://www.0j0.org | http://arduino.berlios.de
 *
 * @author: David Cuartielles
 * @date: 20 Oct. 2005
 */

int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
int delayTime = 7;

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
}

void loop() {
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delayTime);
}

Which Arduino board are you using? Does it get its timing from a quartz crystal or a ceramic resonator?

Aro1: Robin2 - your codes are for bipolar motor and driver, and I have unipolar motor and driver now, as jremington sugested. I don't know how to mix your code with unipolar driver code.

You need to create a small function that makes your motor move 1 step everytime it is called. This is very easy with the Stepper library or the more comprehensive AccelStepper library.

Then your code just needs to figure out how often to move each step to get you the required speed.

...R

MarkT: Which Arduino board are you using? Does it get its timing from a quartz crystal or a ceramic resonator?

I'm using Arduino Uno. There is a 16Mhz crystal on the board.

Will Arduino or the code never accept decimals? There is so many pulses and the motor must rotate 64 times to turn the gearbox shaft 1 time. I don't understand why the available codes can't turn the gearbox shaft 4 times per 60 second. Or 240 times per hour, to check if it's still ok after 1 hour.

Aro1: I don't understand why the available codes can't turn the gearbox shaft 4 times per 60 second. Or 240 times per hour, to check if it's still ok after 1 hour.

Then there would be nothing left for you to do. :)

...R