Talk about cheap stepping motors and there’s a good chance someone will mention the “28BYJ-48”. Or maybe he or she will not remember the part number and say something along the lines of “That 3 dollar stepper used in air conditioners! You know! B28 something!” Truth be told, it doesn’t get much cheaper than 3 dollars. The 28BYJ-48 is the queen of ultra-low-cost steppers.

But is there good in the cheap? Can this 3 dollar stepper motor achieve greatness against all odds? No. But hey, it’s only 3 bucks, so you might as well get a dozen and see what you can come up with. I decided to throw the steppers at a simple robot arm project.

Driving the 28BYJ-48 with a A4988

So what are some of the more interesting aspects of this robot arm? The first thing that comes to mind is the way the stepper motors are driven. I am using A4988 drivers on them. But it is only after you apply a small modification to the stepper motors inner wirings that you are able to do so. The 28BYJ-48’s are unipolar steppers. They need to be made into bipolar steppers for the A4988 to work. Basically, you just cut a connection.

But here’s a more informative blog post on how this is done.

Above you can see the complete schematics of this project. Note how the red wire of the stepper motors isn’t connected to anything. That’s because after the above-mentioned procedure to turn the stepper from unipolar to bipolar there is no more use in this wire. The stepper turns from a 5-wire stepper into a 4-wire stepper.

But Why No Arduino?

Another interesting thing is this: I initially tried to get this robot arm to move with an Arduino. One goal was to make the movements as smooth as possible. So I was programming a library which was supposed to produce stepper pulses in such a way that the motors started and stopped very smoothly. I wanted the velocity curve to be sine shaped. So I implemented it, obviously, by using the sin() function. But the sin() function isn’t exactly a computational lightweight. It is quite the opposite in fact. The function uses a mathematical series to approximate a fairly accurate value of sin(x) for any input x that gets thrown at it. And it is all doubles. floating point operations are notorious for requiring many cycles on most Microprocessors. And the double, being the more accurate float, doesn’t make matters any better.

I wasn’t getting the performance I needed in order to move the steppers both smoothly and swiftly. So I did what seemed to be the most cost-effective solution: Switch to a faster microcontroller (the ESP32). Whilst the clock rate of most Arduinos is set to a rather modest 16 Mhz, the ESP32 boasts a 160MHz dual-core microprocessor.

After this switch, I was able to finish my smooth stepper-pulse-generator library without any further problems. I called it “SineStepper” and it is on Github, along with all the other code needed to run this robot arm:

Github: ESP32-MicroRobotArm

Solving The IK Equations

I also decided to implement the Inverse Kinematics calculations by myself. A fitting IK algorithm allows you to tell the robot arm where (in 3D space) you want its tip to point and the robot arm figures out all the details of how much to rotate which joint by itself. Here’s a sketch I made while thinking about how to solve them. The code solving the IK equations is in the RobotArmIK.ccp file on Github.

Because this robot arm is very simple (only 4 joints), the Inverse Kinematics can be solved analytically. This means that there’s a way to derive equations for how much each joint needs to rotate just by using trigonometry and analyzing how everything is connected. Here are some of the calculations.

This can get way more complicated with more joints. Explaining the IK of this robot arm thoroughly and in such a way that it is easy to understand is a challenging task. It is something I’d like to try but I’d need more time to do it right. There might be another post in the future.

CAD Data

Another thing I challenged myself to do was the creation of 3D data. I used DesignSpark Mechanical 2.0 to create all the parts needed. I did that only after I actually finished the robot arm. But now that I got used to the software, I can see how it really should’ve been the other way around.

I uploaded the DesignSpark files here.

And since there’s an option to export the 3D models as .obj files, I just had to put them in Unity (a Game Engine I use at work). That’s how I ended up making a small assembly animation. The full animation is in the YouTube video I posted somewhere above.

Testing the precision

What are some good tests to apply to this robot arm? We want to figure out whether or not the thing is working the way we think it is working. For example, we think there are no missed steps, but is this really true? The robot arm operates open loop. There are no rotary encoders involved. The microcontroller keeps track of the current positions of all the joints by counting the pulses that are getting sent to the stepper driver chips. The motors might slip and lose a step. And even if the motors are moving reliably, is the microcontroller counting the steps correctly? There might be a bug in the software.

We need data. So let’s check how precise the robot arm is able to move. In the video below, the robot arm moves in a fixed manner. We mark 2 positions; One to check mainly for errors along the Y-Axis, another position for errors along the X-Axis.

The results show that the position used to check deviations along the Y-Axis got lower over time (the robot arm was moving for 5 minutes in total), while the error along the X-Axis seemed small. Since the error is in the same direction as the earth’s gravitational pull, this might indicate that there indeed were some missed steps. But one could also argue that the precision is within margins considering the gears backlash is about 2.5°. It also seemed like the error was converging to some certain amount.

More time had to be invested to pin down the cause/causes of the error seen in this video. Since it is moving fairly accurate I call it a day. The next project’s waiting!

Building the ESP32 Micro Robot Arm

Here are some pictures I took while building the robot arm.

Mechanical Parts

Here are all the parts you need to produce in order to assemble this Robot Arm.

Link1 (2 pieces)



Link1 Spacer (1 piece)



Link2 (2 pieces)



Link2 Spacer (3 pieces)



Link3 (2 pieces)



Link3 Spacer (1 piece)



Link4 (2 pieces)

Link4 Spacer (1 piece)



Tip (1 piece)

I wrote an instructable about this project. Check it out here!