Hey guys! welcome to my new tutorial, I Hope you already enjoyed my previous tutorial "Large stepper motor control". Today' I'm posting thsi informative tutorial to teach you the basics of any servomotor control, I already posted a video about controlling speed and direction of DC motors and stepper motors and today we will get started with the servos and this way we are done with most of the important actuators that a maker can use.
During the making of this tutorial, we tried to make sure that this tutorial will be the best guide for you in order to enjoy learning the basics of servomotors controlling because learning the working process of the electronics actuators is so important for projects development. So we hope that this tutorial contains the needed documents.
What you will learn from this tutorial:- Define the servomotors Uses and Needs.
- Take a look inside the servomotor hood.
- Understand the servomotor mechanism.
- Learn the electrical control part.
- Make the appropriate wiring diagram with an Arduino board.
- Test your first servomotor control program.
Servo motors has been around for a long time and are utilized in many applications. They are small in size but pack a big punch and are very energy-efficient, which makes them superior choice for many applications.
Unlike the stepper and DC motors the servo circuitry is built right inside the motor unit and has a positionable shaft, which usually is fitted with a gear. The motor is controlled with an electric signal which determines the amount of movements of the shaft.
So from here we define that in order to understand how the servo works we need to take a look under the hood. Inside the servo (check the above photos), there is a pretty simple set-up:
- Small DC motor
- Potentiometer
- Control circuit.
The motor is attached by gears to the control wheel.
As the motor rotates, the potentiometer's resistance changes, so the control circuit can precisely regulate how much movement there is and in which direction.
So when the shaft of the motor is at the desired position, power supplied to the motor is stopped.
Step 2: How the Servomotor WorksServos are controlled by sending an electrical pulse of variable width, or pulse width modulation (PWM) through the control wire.
Yes, it reminds me the PWM pins of the Arduino!
A servo motor can usually only turn 90° in either direction for a total of 180° movements regarding the frequency and the pulse width received through its control wire.
The servo motor expects to see a pulse every 20 milliseconds (ms) and the length of the pulse will determine how far the motor turns. For example, a 1.5ms pulse will make the motor turn to the 90° position. Shorter than 1.5ms moves it in the counter clockwise direction toward the 0° position, and any longer than 1.5ms will turn the servo in a clockwise direction toward the 180° position.
Step 3: The Circuit Diagram (how to Wire a Servo)I’m using in this tutorial a Carson servo used for racing cars due to its high torque and metal gears, like all servos it has three wires, one wire for the control signal and two wires for power supply which is 6V DC but for testing the movements it is ok the run with 5V DC.
I’m using also an Arduino Nano board which has already PWM pins for signal control.
In order to control to servo movements I will use a potentiometer attached to an analog input of my Arduino and the servo shaft will be exactly as same as the potentiometer rotation.
I moved to EasyEDA to prepare the circuit diagram, it is a pretty simple setup since all what we need is a servo motor powered by an external DC 5V power supply and controlled by an Arduino Nano through the analog signals received from a potentiometer.
Step 4: Codes and TestsAbout the control program, in this tutorial we will use an Arduino Library which is the servo library allowing the creation of a servo instance where you need to set the output control pin for the servo and in this example we are using PWM pin 9, then we are reading the analog signals from the potentiometer through the analogRead function from the analog input A0
In order to control the servo we need to use the write function from the servo object which get a value from 0 to 180 so we convert the analog value which is from 0 to 1024 (size of the ADC) to a value from 0 to 180 using the map fuction. Then we drop the converted value in the write function.
Following this tutorial you are now able to control and test your servo motors and you can develop these knowledge to control more servo in an advanced mechanism like robotic Arms.
That's it for this tutorial.
It was BEE MB from MEGA DAS see you next time.
Comments