 Today, we're going to learn about stepper motors. Unlike brushed or brushless motors, stepper motors have a high degree of rotational accuracy. This makes them perfect for applications such as 3D printers, CNC's or even industrial machinery. Turning apart this common stepper motor found in 3D printers, we can see that there are two main parts to a stepper motor. There's the rotor and there's the stator. The stator in this motor contains multiple electromagnets while the rotor in this motor is a permanent magnet itself. If you look even closer at the rotor, we can see these U-shaped cutouts. What these do is help channel magnetic force and later we will discuss them in more detail. Next, each motor can be wired one of two ways, either using a bipolar wiring or a unipolar wiring. So first let's talk about unipolar motors. I'm going to represent a stepper motor rotor like this with a diagram that looks like this. So now, as you can see there are three electrical contacts. There's one over here, there's a positive contact in the middle and there's another blank one here. Depending on which side we connect ground to, so if we connect ground here or here, we can create a magnetic force, electromagnetic force around this coil. So let's do one of that. Let's add one of these and what I've done is I've connected the middle to positive and I've connected the right side here to negative and as you can see, it's charged. Now what's going to happen is the magnet in the middle will react to an electromagnet and appropriately turn. Like so. Now if you wanted to switch this rotor around and make it turn the other direction, what we could do is simply reverse the polarity. So instead of ground being connected here, now ground is connected to this side of the coil which induces electromagnetic force in the opposite direction. So now what's going to happen is it's going to rotate in the other direction. It's simple as that but as you might have noticed, only half of the coil is active at one time. If you were to charge the other side, only that half will be active. If you were to charge this side of the coil, only this side is active. So wasting a lot of coil space. That's where bipolar motors here come into play. As you can see bipolar motors here only have two electrical contacts. They don't have the third central electrical contact like you need polar motors. So how this works is if you provide a voltage that means connect the positive terminal to one side and a negative terminal to the other side, we can induce a current or electromagnetic force along this coil. So in this case, what's going to happen is it will rotate in this direction like so and if you decide to flip the polarity like so, the electromagnetic force will also be switched. In a nutshell, unipolar motors are much easier motors to drive but the cost of twice the wiring in the coils as bipolar motors. Adding these two coils here allows us to rotate the rotor a full 360 degrees rather than just randomly flipping the rotor 180 degrees. So I've created a much simpler version of the stepper motor diagram in the center here so it's easier to follow along. So if you energize the motors and the rotors are aligned appropriately, now what if you wanted to move the motor in a clockwise direction? For to do that, we're going to energize coil two. So here the motor is turned 45 degrees clockwise. Now what if you wanted to continue to turn it clockwise? Now I've energized coil two and as you can see the rotor will turn in this direction. Fantastic, now you get the gist. Now we're going to continue to do this motion and then just coil one and coil two to keep rotating this motor another 45 degrees, another 45 degrees and like so we've moved the center rotor a whole 360 degrees. Now as you saw when you rotated our rotor 360 degrees we were moving in increments of 90 degrees. But what if you wanted to move in increments of 45 degrees? Let's start with energizing one coil. Now while this coil is energized what if we energize the other coil like so? What's going to happen is our rotor will turn in 45 degrees like so. If you wanted to move it another 45 degrees counterclockwise what we could do is simply turn off this coil. And now what's going to happen is this motor will continue to turn like so. Now what if you wanted to move it another 45 degrees counterclockwise? Well we can activate coil one again. The motor will continue to turn 45 degrees. Now this technique is called half stepping and it falls under a technique called microstepping. By using microstepping we can get a lot more rotational resolution but it comes at the cost of torque. Now unlike traditional motors, stepper motors are rated at something called steps. This refers to the distinct position that a stepper motor can make in one 360 degree rotation that means a 200 step motor such as the one I'm holding here can make 200 individual increments of movement within a 360 degree turn. Before we move on let's quickly talk about the three types of stepper motors. The first is the permanent magnet stepper motor. This motor features a magnetic rotor. The second type of stepper motor is a variable reluctance stepper motor. This doesn't have a magnetic rotor like the last motor but it features those U-shaped cutouts that I showed you earlier. Thirdly we have the hybrid synchronous motor which kind of mashes both of those motors together hence the name hybrid motor and features both a magnetic core and those U-shaped cutouts. Lastly let's do a quick little demo using this NEMA 17 slash 40 stepper motor. It's very commonly used in DIY or hobby grade applications such as building your own 3D printers, CNC's or even homemade robots. Now this is a hybrid synchronous motor with bipolar wiring and we'll be driving it using the common A4988 stepper motor driver. We can now use both the Raspberry Pi or the Arduino. Using the stepper driver is very simple the only two pins that we need to worry about the step pin and the direction pin. The step pin will basically tell the motor to move and the direction pin will tell the motor in which direction to move. This is the circuit that I've used and this is the code that I've used. The code I've written here is for the Arduino but the code can be compiled for the Raspberry Pi as well and it'll work in the same way. As you can see the stepper motor spins. Before we end this video let's quickly talk about some of the drawbacks or the cons of the stepper motor. Now although stepper motors have been often reniturized, most stepper motors are big and bulky. Stepper motors require a lot of power to operate and can often get hot under operation. Next, based on how these stepper motors are driven or what driver's circuit you're using, stepper motors like these can get quite noisy. This is because we require a specific driver's circuit just to control this motor. The wiring and electronics for stepper motors can get a little bit complicated for beginners. Next, using microstepping to increase the resolution of your stepper motor will decrease the amount of torque your stepper motor can produce. Now this video barely scratches the surface of what stepper motors are and how you can use them in your next project. If you want to watch more tutorials like this, do subscribe and if you have any questions or comments you can leave them down in the comments section below. Thanks for watching.