[ Log In ]
Tumbnail: 62 oz-in NEMA 17 Stepping motors (also called stepper motor)

NEMA 17 Stepping Motor (62 oz-in 5mm single shaft)

$19.95
Qty:
Image of the Atmega324p

Atmega324P

$8.50
Qty:

10K timmer potentiometer

10K Trimmer Potentiometer (Through Hole)

$0.85
Qty:
16x2 LCD (Liquid Crystal Display)

16x2 LCD (Liquid Crystal Display)

$12.50
Qty:
White prototyping breadboard with 30 tie strips and two power rails on each side.

White Prototyping Breadboard (2x30 columns of tie strips and 2x2 rows of power strips)

$7.95
Qty:
Clear Semi Transparent Breadboard

Clear Prototyping Breadboard (2x30 columns of tie strips and 2x2 rows of power strips)

$8.50
Qty:
Red Through Hole LED (Light emitting diode)

Single Red Through Hole LED (Light Emitting Diode)

$0.34
Qty:
Green through hole LED (light emitting diode)

Single Green Through Hole LED (Light Emitting Diode)

$0.34
Qty:
Yellow through hole LED (light emitting diode)

Single Yellow Through Hole LED (Light Emitting Diode)

$0.34
Qty:
Skip Navigation Links

Microcontroller - A Beginners Guide - Introduction to Servos and Understanding Torque

There are so many types of servomechanisms (or servo for short) and the way they must be interfaced to microcontrollers. But before we get into the details of programming and connecting the servo to the microcontroller, let's delve into how they work and the various types of servos.

Closed Loop Control

Ok, so you know what a loop is, right? Closed loop control is not too far off of this concept. There are actually two main types of control: open loop control and closed loop control. Open loop control is where you tell a "thing" to do a specific task and hoping that the "thing" did what you told it. You are blind to what the "thing" actually did.

Closed loop control is where you tell a "thing" to do a specific task and after the "thing" did the task, the "thing" informs you of the status of the task. If the status is exactly what you specified that the "thing" should have done, then the "thing" is ready for the next task. If the status is not correct and the task did not complete, then you tell the "thing" a new task in order for it to complete the previous task. This happens as many times as it takes to complete the initial task.

In terms (or function) of servos, closed loop control happens like this: for hobby servos, the microcontroller will give the command to the servo on the degree of rotation (where to position the shaft of the servo). This degree of rotation is actually in the form of a PWM signal (we get into much more detail on PWM here: ****). The PWM (Pulse width Modulation) is output to the servo. The width of the pulse in the PWM signal defines the position of the servo shaft position. Frankly, the microcontroller really doesn't care if the servo gets to the commanded position, but fortunately for us, the servo does care and the motor inside the servo is informed by it's own circuitry if the position is correct or not. If the position is not correct, then the servo keeps commanding, backward (if the motor overshot the target) and forward (if the motor didn't quite get to the comanded position).

So, inside the servo, there is a motor, and a potentiometer. These two devices are mechanically linked. The output shaft of the motor is mechanically linked to the shaft of the potentiometer, and if you read/watched my tutorial on potentiometers, you will know that it can be used to show a varying voltage (or resistance) and that very device will inform the circuitry if the motor is in the correct position. Knowing that the servo uses a potentiometer, then you also know that most potentiometers can only be turned to a certain range of degrees. This limits the overall rotation of the servo and most hobby servos can only hit a range of 180 degrees. There is, however, a way to modify these servos for continuous rotation and one method can be seen here: www.acroname.com/robotics/info/ideas/continuous/continuous.html

Other types of servos function slightly different. In many cases, the microcontroller that you are programming will be involved with the operations of the closed loop control. That is to say, the microcontroller will output a signal (or train of signals) and it will expect a report back from the servo. Typically, the report will be a pulse back from a device called an encoder. An encoder is a device that gives an on and off signal as it turns (or slides with linear encoders). Encoders are very much different from potentiometers found in hobby servos. An encoder typically use light and a component that senses light and a wheel with slits (or plastic dics with marks) to determine position. When the wheel (or disc) turns (turns with the motor shaft), the light will be on one side of the wheel and the light sensor will be on the other. When the light sensor can see the light, then the encoder sends a pulse. As the wheel spins, multiple pulses will be output from the encoder. This is very similar to a button press, or multiple button presses.

So, if the microcontroller outputs a signal to the servo, it will expect a signal back from the servo. If no signal is returned, the microcontroller keeps trying until the signal is returned. You're probably wondering... well, what if the signal is never returned. This could be where the servo just doesn't have enough torque to get to the position that is commanded by the microcontroller.

Torque

Torque is the amount of force that the motor can turn the shaft and is measured by a weight and length. There are a couple of ways to think about torque. One of these is how much weight it would take to turn a shaft, which is, sort of, the common way to explain torque. However, I want to focus on how much motor power it would take to move a weight, rather than how much weight it would take to turn the motor shaft. If I didn't completely confuse you with that, then you are doing well.

So, imagine you have a motor and this motor has a shaft. The shaft will have a center point (the center of the diameter of the shaft looking at the shaft from one end). The torque is measured from this center point. Remember, I said that torque is a measurement of a force and length. The length dimension is a length measured from the centerpoint of the shaft and out, perpendicular to the shaft. The length would typically be a single unit, like one foot, one inch, one centimeter, etc. An example of a torque measurement would be something like foot-pounds, by which a car engine might be measured. The foot represents the measurement from the center of the shaft to one foot. The torque units can be any unit of weight and any unit of length put together like: oz-in (ounce inch), ft-lb (foot pound), kg-m (kilogram-meter), Nm (Newton Meter), etc.

The weight would be a specific amount hanging at that one foot measurement away from the center of the shaft. This weight could be so large that when the motor is at full power, the weight makes the engine turn in the reverse direction. For instance, say, we have a brand new Tesla Electric Vehicle, and let's pretend that the electric motor has 500 foot-pounds of torque. If we were to hang a 600 pound weight exactly one foot from the center of the motor shaft, say, using a metal bar, or something like that, then the motor will not be able to carry the weight and the shaft will turn in the opposite direction. If we hung a 400 pound weight at the one foot mark, then the motor would turn in the correct direction, but it would struggle. If a 500 pound weight is placed at the one foot mark, then the motor would not turn at all. This is sometimes called the holding torque.

We can also address this weight at different locations on the length measurement coming from the center of the shaft. Say, we have the same 500 pounds on this bar that is bolted onto the center of the shaft, but you place the 500 pounds at half (1/2) of a foot instead of at the one foot mark, then the motor will have no problem turning in the correct direction as this would essentiallycut your weight in half. As the weight gets closer to the center of the shaft, the weight is proportionally reduced. That is to say, if the 500 pounds is pressing against this bar at the 1/2 foot mark, then from the motors perspective, it's like there is only 250 pounds pressing at the one foot mark. Ok, so lets referse this idea and place the 500 pounds of force at the 2 foot mark, then from the motors perspective, there will seem like there is 1000 pounds at the one foot mark.

It may sound like this torque discussion is not that important with respect to these microcontroller tutorials, but when it comes to understanding servos, torque will be crutial in the development of your overall project. Imagine you need this servo to raise an object that has a weight of 100 ounces, and this servo is rated at 200 ounce-inch of torque, you would know that the 100 ounce object will need to be placed somewhere within the length of 2 inches.