Rotating 28BYJ-48 Stepper Motor below 1 RPM

Hi I am trying to rotate my stepper motor below 1 RPM.
The intent is to use it for tracking the sun for a solar cooking project I am working on.

The motor I am using is 28BYJ-48. It comes with a lot of starter Arduino kits.
It's a 5 volt stepper motor with a 1 to 64 gear ratio.

For the solar tracking I have have taken into account
24 hours of rotation of the earth in 360 degrees.
I've calculated this out to be 15 degrees/hr -->.25 degrees/min-->.004167 degrees/sec
Or .25 degrees/min/360 degrees = .000694 RPM

In my code below I've input the number of steps the motor must take to complete one revolution.
I've been able to successfully use the code with 1 RPM, but anything below that doesn't rotate.

Is there a reason why? Are steppers not good enough for this type of motion?

Thanks! Any input is appreciated.

//28BYJ-48 Stepper Motor

//Half-step mode: 8 step control signal sequence (recommended) 5.625 degrees per step / 64 steps per one revolution of the internal motor shaft
//Arduino Stepper Library runs in 4 step control signal sequence 11.25 degrees per step / 32 steps per one revolution of the internal motor shaft
//Gear reduction ratio: 1 to 63.68395
// Steps per one revolution (internal motor shaft) * Gear reduction ratio = Actual number of steps per revolution = 64 * 63.68395 = 4075.7728 in 8 step control signal sequence
// Steps per one revolution (internal motor shaft) * Gear reduction ratio = Actual number of steps per revolution = 32 * 63.68395 = 2037.8864 in 4 step control signal sequence

//stepper library
#include <Stepper.h>

//ms stands for motor steps
//#define is used to assign a name for a constant value i.e. in this case ms stands for actual number of steps per revolution
#define ms 2037.8864

//mip stands for motor input pin
//output pins 8,9,10,11 on Arduino UNO R3 attach to input pins 1,2,3,4 respectively on stepper motor driver ULN2003A
int mip1 = 8;
int mip2 = 9;
int mip3 = 10;
int mip4 = 11;

//command tells the Arduino stepper library which pins are connected to motor controller
//first parameter in parenthesis is number of actual steps that occur per revolution
Stepper stepper(ms, mip1, mip2, mip3, mip4);

void setup()
{

//outputs Arduino UNO R3 pin outputs into stepper motor inputs
pinMode(mip1, OUTPUT);
pinMode(mip2, OUTPUT);
pinMode(mip3, OUTPUT);
pinMode(mip4, OUTPUT);

//stepper motor value in parenthesis is in RPM
stepper.setSpeed(.000694);
}

//repeats commands written below
void loop()
{
//number of steps the motor takes to complete one revolution
stepper.step(ms);
}

Please use code tags.
stepper.setSpeed takes an integer argument.

Hi knightridar,

you can try a library called AccelStepper, that let you control the stepper really easily.

You need only to set the pin outside the board and set only the maximum acceleration, speed and targhet position, no more informations. If you need I can give you an example of code.

Riccardo

@jremington thanks!

stepper.setSpeed accepts only integer arguments --> okay whole numbers

I think I know what you mean by code tags now.
Do you want me to separate my code from the actual message?

I just don't know how to do it.
I've tried to attach it in this response.

@radicator

thanks I will look into it. I've managed to install the library. I'll try to modify the code to adapt to it.

solar_cooker_sun_tracking.ino (1.72 KB)

86400 seconds per rotation / 4075.7728 steps per rotation = 21198.4338283 seconds per step or about 1 step every 21198 millis . Yikes! That's slow.

If you want to make a motor go very slowly just ask the library to move it a single step and build your own code to determine the interval between steps. Don't bother with the motor speed function.

Very crudely

void loop() {
   stepper.step(1);
   delay(5000);
}

would make it do one step every 5 seconds

...R

Wow thank you all for your help! Your are geniuses! This advice will simplify the code a lot.

It is working now. The stepper motor is warm but I can see the driver board lighting up and I can feel the motor moving. Now I'll just leave it still for a few hours and see if it's actually moving (I've got a pulley attached to the shaft of the motor with a pen mark on it).

@Robin2 --> I've input correct time delay between each step
@klubfingers --> thanks for pointing out the relation between motor steps and time per revolution

Hope this code tag works

//28BYJ-48 Stepper Motor

//Half-step mode: 8 step control signal sequence (recommended) 5.625 degrees per step / 64 steps per one revolution of the internal motor shaft
//Arduino Stepper Library runs in 4 step control signal sequence 11.25 degrees per step / 32 steps per one revolution of the internal motor shaft
//Gear reduction ratio: 1 to 63.68395
// Steps per one revolution (internal motor shaft) * Gear reduction ratio = Actual number of steps per revolution = 64 * 63.68395 = 4075.7728 in 8 step control signal sequence
// Steps per one revolution (internal motor shaft) * Gear reduction ratio = Actual number of steps per revolution = 32 * 63.68395 = 2037.8864 in 4 step control signal sequence

//steps per degree = 2037.8864/360= 5.660795555555556
//rotation of earth = 0.4166666666666667 degrees/sec 
//steps motor needs to take per sec = 5.660795555555556 * 0.4166666666666667 = 2.358664814814815
//24 hours in day --> 60 sec/min * 60 min/hr * 24 hrs = 86400 seconds in a day
//Time earth takes to rotate 360 degrees/number of steps motor takes to rotate 360 degrees = 86400/4075.7728 = 21.19843382830368 seconds/step


//stepper library
#include <Stepper.h>

//ms stands for motor steps
//#define is used to assign a name for a constant value i.e. in this case mspr stands for actual number of motor steps per revolution
#define mspr 2037.8864

//mip stands for motor input pin
//output pins 8,9,10,11 on Arduino UNO R3 attach to input pins 1,2,3,4 respectively on stepper motor driver ULN2003A (Part No. ZC-A0591)
int mip1 = 8;
int mip2 = 9;
int mip3 = 10;
int mip4 = 11;

//command tells the Arduino stepper library which pins are connected to motor controller
//first parameter in parenthesis is number of actual steps that occur per revolution
Stepper stepper(mspr, mip1, mip2, mip3, mip4);  

void setup()
{
  
//outputs Arduino UNO R3 pin outputs into stepper motor inputs
  pinMode(mip1, OUTPUT);
  pinMode(mip2, OUTPUT);
  pinMode(mip3, OUTPUT);
  pinMode(mip4, OUTPUT);

}

//repeats commands written below
void loop()
{ 
//number of steps motor takes and time delay between next step. 
//time delay and step simulate earth rotating 360 degrees in 24 hours which is simulated by the number of steps the motor takes to rotate 360 degrees in 24 hours. 
   stepper.step(1);
   delay(21198.43382830368);
}

also thanks to this site I was able to modify my code accordingly

You could use millis() to have an adjustable time delay. See BlinkWithoutDelay.

Could you write this out full, complete - if it is to continuously rotate the steppermotor and control it with a pot meter, please.

I downloaded some attachment but that only makes my steppermotor go one rotation forth and back.
I'm making a slow turning display

Tiriaq:
I downloaded some attachment but that only makes my steppermotor go one rotation forth and back.
I'm making a slow turning display

As you have not posted your code or provided a link to "some attachment" it is a bit hard to offer advice.

The very basic code in Reply #5 will make the motor move continuously. You can use a potentiomenter to vary the value of the interval between steps. Something like

void loop() {
   potVal = analogRead(potentiometerPin);
   intervalBetweenSteps = basicInterval + potVal;
   stepper.step(1);
   delay(intervalBetweenSteps);
}

However using the delay() function is very crude and you should really use millis() to manage timing as illustrated in several things at a time

...R

Knightrider, if your stepper is warm it has power applied continuously.
To move 1 step at a time then pause, you only need a pulse, not continuous power.

RussC:
Knightrider, if your stepper is warm it has power applied continuously.

Stepper motors always have power applied continuously and they are always warm - possibly even too hot to touch.

If they don't have power they cannot hold their position.

...R
Stepper Motor Basics