Servo motors are generally an assembly of four things: a DC motor, a gearing set, a control circuit and a position-sensor (usually a potentiometer).
The position of servo motors can be controlled more precisely than those of standard DC motors, and they usually have three wires (power, ground & control). Power to servo motors is constantly applied, with the servo control circuit regulating the draw to drive the motor. Servo motors are designed for more specific tasks where position needs to be defined accurately such as controlling the rudder on a boat or moving a robotic arm or robot leg within a certain range.
Servo motors do not rotate freely like a standard DC motor. Instead the angle of rotation is limited to 180 Degrees (or so) back and forth. Servo motors receive a control signal that represents an output position and applies power to the DC motor until the shaft turns to the correct position, determined by the position sensor.
PWM is used for the control signal of servo motors. However, unlike DC motors it’s the duration of the positive pulse that determines the position, rather than speed, of the servo shaft. A neutral pulse value dependant on the servo (usually around 1.5ms) keeps the servo shaft in the centre position. Increasing that pulse value will make the servo turn clockwise, and a shorter pulse will turn the shaft anticlockwise. The servo control pulse is usually repeated every 20 milliseconds, essentially telling the servo where to go, even if that means remaining in the same position.
When a servo is commanded to move, it will move to the position and hold that position, even if external force pushes against it. The servo will resist from moving out of that position, with the maximum amount of resistive force the servo can exert being the torque rating of that servo.
A stepper motor is essentially a servo motor that uses a different method of motorisation. Where a servo motor uses a continuous rotation DC motor and integrated controller circuit, stepper motors utilise multiple toothed electromagnets arranged around a central gear to define position.
Stepper motors require an external control circuit or micro controller (e.g. a Raspberry Pi or Arduino) to individually energise each electromagnet and make the motor shaft turn. When electromagnet ‘A’ is powered it attracts the gear’s teeth and aligns them, slightly offset from the next electromagnet ‘B’. When ‘A’ is switch off, and ‘B’ switched on, the gear rotates slightly to align with ‘B’, and so on around the circle, with each electromagnet around the gear energising and de-energising in turn to create rotation. Each rotation from one electromagnet to the next is called a "step"
and thus the motor can be turned by precise pre-defined step angles through a full 360 Degree rotation.
Stepper motors are available in two varieties; unipolar or bipolar. Bipolar motors are the strongest type of stepper motor and usually have four or eight leads. They have two sets of electromagnetic coils internally, and stepping is achieved by changing the direction of current within those coils. Unipolar motors, identifiable by having 5,6 or even 8 wires, also have two coils, but each one has a centre tap. Unipolar motors can step without having to reverse the direction of current in the coils, making the electronics simpler. However, because the centre tap is used to energise only half of each coil at a time they typically have less torque than bipolar.
The design of the stepper motor provides a constant holding torque without the need for the motor to be powered and, provided that the motor is used within its limits, positioning errors don't occur, since stepper motors have physically pre-defined stations.