28BJY-48 Stepper motor angle printing to time

I need a help to my project. I use stepper motor which bjy48 and I need to see angle value when it turnging and I need data about the angles of each turn per second or milisecond etc.
Pls help me!

Show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

the code that You think is unimportant, not posting it...

I'm only thinking, control the stepper easy but I couldn't figure out how to write the angle, as I wrote before, I need an angle graph against time.

I believe you want to know the gear ratio of this device, and the stepper pitch.

In other words, how many degrees per step.

(I do not recall offhand. :upside_down_face:)

1 Like


5V, 100 steps per second

64 steps per revolution (5.625° steps) and 1:64 gearing gives 4096 steps per output shaft revolution (0.087890625° steps).

Note: Gearing is not always exactly 1:64 but should be within a percent or two.

1 Like

Thank you John,
I found from datasheet 11.25 degree each step and I wrote something like that, but if it is 0.087890625 I need to change, perhaps I can check with gyro. Also I use PLX-DAX it was so usefull to transfer the data to excel date-angle format.

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0; // number of steps the motor has taken

void setup() {
// initialize the serial port:
Serial.println("LABEL, Time, Started Time, Date, Angle,");

void loop() {
// step one step:
Serial.print("DATA, TIME, TIMER, DATE,");

Try running the stepper 4096 steps and see how far it actually moves. A piece of tape on the output shaft will make it easier to count revolutions.

#include <Stepper.h>

// change this to fit the number of steps per revolution
// for your motor
const int stepsPerRevolution = 4096;

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup()
  myStepper.setSpeed(2);  // 2 RPM

void loop() {}
1 Like

As far as I know, 28BYJ-48 motor is 32 step per rev with 64 to 1 gear reduction gives 2048 steps per rev or 0.17578125 degrees per step.
Max RPM that I can get without acceleration is less than 13 at no load without missing steps.

1 Like

Oh come on!

How can it not be "always exactly" 1:64?

Is it actually gears, or are you saying it is a friction drive?

11.25° per step is 32 steps per revolution - of the stepper itself, clearly not the output shaft.

But exactly what is defined as a "step"? This can variously refer to one, two or four state changes.

okose3, please read the instructions for posting and edit your #7 to post the code correctly.

1 Like

Sorry I was not clear. Some stepper motors sold under the name 28BYJ-48 have a 64:1 gear train but others have a 63.68395:1gear train. The model number does not guarantee an integer gear ratio.

1 Like

That sounds inaccurate! :face_with_raised_eyebrow:

Can you give the actual integral ratio? A:B?

Firstly, I would recommend you not blink to much, because serial.print() function will slow motor down.
Secondly. if you use AccelStepper library, there is stepper.currentPosition() function, which returns the current position. You can learn more detail on Control 28BYJ-48 Stepper Motor using ULN2003 Driver

OK. 567424:8910 (which reduces to 25792:405)

See: Geared Stepper Motor

These little motors are terrific, but were designed for applications like moving air-conditioning vents etc. They have 2 main challenges.

  1. They don't have a exact number of steps per 360 degrees as stated above
    If you want that, then NEMA steppers do that - typically 200 steps per rev.
  2. Because of the gearing, they exhibit backlash. So the same number of steps forward then backward does not always return to the same mechanical shaft position.

We developed a simple positioning indicator. It means that you can determine the position of the output shaft on either 360 or 90 degree basis. It is basically a cam and a switch.
The trick is to make sure that the shaft always approaches the switch in the same direction when taking a switch reading.
No guarantees on accuracy in terms of degrees (a precision optical encoder would be better for that). But we use these to determine a startup position or a reset position, which is what they are intended for. It won't give you angular feedback as it's turning. But you should be able to start at a set position and then count the steps (but bear in mind point 1 above).
You could design your own version of this cam/switch depending upon the mechanical construction of your project.
As I say, if you need precise angular measurements, you can buy precision shaft encoders, although even some might not give the movement granularity you need.

Hope this helps.