JC

ROBO | Servo Motor

Servo Motor

  • converts electrical energy to mechanical energy

  • used for precision control in engineering, robotics, and automation

  • position can be controlled with a controller, as the device is sent signals telling the motor exactly how far to rotate

Closed Loop

  • can only rotate for 180º as there is a pin to stop the motor from rotating further

Open Loop

  • can rotate the full 360º degrees

Weight

  • represents the torque of the motor

    • how much force it can apply to a lever, which rotates the arm around the pivot

    • in kg-cm or oz-in

  • can be found on the side of the motor

    • the farther a point on the arm is from a pivot, the lower the maximum weight it can support

  • higher weight or torque rating leads to higher size as it requires larger gears and electrical motor

Rotation

  • The higher the voltage, the higher the torque, the stronger the motor, and the faster the motor will rotate

  • The motor uses more power when moving

  • measured in seconds per 60º of rotation

Parts

Outside

Main Housing

  • holds the internal components

Electrical Connections

  • red → positive/voltage wire

  • brown → ground wire

  • orange → pulse width modulation signal wire

Splined gear

  • where rotation occurs

  • the various attachments are placed here

Inside

Compound Gear Train

  • has gears and corresponding beairings

  • alternates between small number toothed and large numbered toothed gears to ensure a compact design

  • one side has the output and the other the input

    • the input is connected to a DC motor that drives the gear

  • the motor has a high rotational speed but low torque

  • the gears convert this to an output with low speed but high torque

DC Motor

  • connected to a circuit board in the unit that controls the motor’s rotation and direction

Potentiometer

  • connects to the output gear and is a variable resistor

  • as it rotates, the resistance changes and the circuit board reads this to know the position of the output

Process

  1. The controller sends a signal to the servo motor which determines the position it should rotate to. Pules of voltage are sent down the wire, every 20 miliseconds which vary in length.

    • Wide pules entail that the servo moves to the left.

    • Small pulses entail that it moves to the right.

    • The position is between these two points, and is dependent on the width of the pulse.

  2. The signal enters the circuit board and is converted to a voltage.

  3. It passes through a comparator then to a motor driver, which controls the rotation of the DC motor.

    • An internal H bridge circuit is used to control the direction of the rotation, which causes the gears to rotate.

  4. The potentiometer rotates which divides and adjusts the resistance based on the position.

Potentiometer

  • If the potentiometer is pointed to the left, the voltage is 5V while to the right, it is 0V

  • It is connected to the comparator, which monitors the voltage to provide feedback.

  • As the pontentiometer changes the resistance from a minimum to maximum value, the voltage of the potentiometer and controller signal are compared.

  • The motor will turn until the difference between the two is zero.

Wiring

Breadboard

  1. Connect 5V of Arduino to positive of breadboard.

  2. Connect GND of Arduino to negative of breadboard.

Potentiometer

  1. Connect 5V of breadboard/Arduino to left pin.

  2. Connect GND of breadboard/Arduino to the right pin.

  3. Connect A0 of Arduino to the center pin.

Servomotor

  1. Connect 5V of breadboard/Arduino to red wire.

  2. Connect GND of breadboard/Arduino to the brown wire.

  3. Connect 9 of Arduino to the orange wire.

Code (does not include potentiometer)

#include <Servo.h>
//commands from a premade library will be used.
int pos = 0; //declares starting position
Servo servo_9; //declares name of servo
void setup()
{
  servo_9.attach(9, 500, 2500); //links servo to the needed pins
}

void loop()
{
  // sweep the servo from 0 to 180 degrees in steps
  // of 1 degrees
  for (pos = 0; pos <= 180; pos += 1) {
    // tell servo to go to position in variable 'pos'
    servo_9.write(pos);
    // wait 15 ms for servo to reach the position
    delay(15); // Wait for 15 millisecond(s)
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    // tell servo to go to position in variable 'pos'
    servo_9.write(pos);
    // wait 15 ms for servo to reach the position
    delay(15); // Wait for 15 millisecond(s)
  }
}
#include <Servo.h> 
//commands from a premade library will be used.
int pos = 0; //declares starting position
Servo servo_9; //declares name of servo
int servoPin = 9; //declares connected pin
void setup()
{
  servo_9.attach(servoPin); //links servo to the needed pins
}

void loop()
{
  // sweep the servo from 0 to 180 degrees in steps
  // of 1 degrees
  for (pos = 0; pos <= 180; pos += 1) {
    // tell servo to go to position in variable 'pos'
    servo_9.write(pos);
    // wait 15 ms for servo to reach the position
    delay(15); // Wait for 15 millisecond(s)
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    // tell servo to go to position in variable 'pos'
    servo_9.write(pos);
    // wait 15 ms for servo to reach the position
    delay(15); // Wait for 15 millisecond(s)
  }
}