🛠️

Servo Motors Workshop

Jul 12, 2024

Servo Motors Workshop

Introduction

  • Focus: Using servo motors with Arduino
  • Covered Items: Basic operation, PCA 9685 module for controlling multiple servos

Overview of Motors

  • Types of Motors Covered
    • Stepper Motors (previously covered in-depth)
    • DC Motors (used in robot car designs)
    • H-Bridge Modules (L298N for DC motors)
    • Servo Motors (focus of today, both analog and continuous rotation)

Servo Motors Basics

  • Analog Servo Motor
    • Uses: Robotics, IoT projects, moving sensors/cameras
    • General Specs: 3 leads (GND, Power, Control)
    • Common Models: SG90 (plastic gears), HS-422 (higher torque)
  • Continuous Rotation Servo Motor
    • Modded for continuous 360-degree rotation
    • Control: Adjust center point for stopping& rotation speed

Internal Mechanism

  • Components
    • DC Motor internally
    • Potentiometer for shaft position feedback
    • Internal controller board adjusts shaft position using PWM
  • PWM Control
    • Pulse width determines shaft position (e.g., 1.5 ms = 90°, 1 ms = 0°, 2 ms = 180°)
    • Analog servos typically have 180-degree range

Speed and Torque

  • Definitions
    • Speed: Time to move shaft by 60° (e.g., 0.25 sec/60°)
    • Torque: Force applied to lever (e.g., 5 kg-cm)
  • Specifications
    • Stall Torque: Torque that causes motor to stall
    • Peak Torque: Max torque for short periods
    • Rated Torque: Max torque at rated speed

Testing Servo Motors

  • Tester Device
    • Connect servo to tester device to control shaft position
    • Various modes: manual control, 90-degree centering, sweep mode

Arduino Experiments

First Experiment: Servo Sweep Sketch

  • Setup
    • Use separate power supply for servo (avoid using Arduino 5V)
    • Connect servo ground to Arduino ground, servo power to power supply, and servo control to Arduino pin 9
  • Code (Sweep Sketch)
    • Libraries: Servo library included in Arduino IDE
    • Functions: Attach servo to pin, for loop to sweep from 0° to 180° and back

Second Experiment: Servo Control with Potentiometer (Knob Sketch)

  • Additional Component: 10K+ potentiometer
  • Setup
    • Connect potentiometer ends to Arduino 5V and ground, wiper to analog pin A0
  • Code (Knob Sketch)
    • Functions: Analog read potentiometer, map value to servo angle, use servo.write() to position servo

Experiment: Multiple Servo Motors with PCA 9685

  • Module Overview
    • Controls 16 PWM devices (servo or LEDs)
    • Uses I2C bus (clock and data lines)
    • Configurable via solder pads
    • Separate power supply for servos/LEDs
  • Setup
    • Connect multiple servos, use I2C to control all via Arduino
    • Power PCA 9685 with separate supply, connect servos, and potentiometers
  • Code
    • Library: Adafruit PWM Servo Driver Library
    • Functions: Map potentiometer read values to servo control signals

Key Recommendations

  • Use separate power supply for servo motors to prevent noise and power spikes affecting Arduino
  • Utilize external PWM control boards like PCA 9685 for multiple servo motor projects

Additional Resources

  • Complete code and details available on the corresponding article on the workshop website
  • Subscribe to the workshop newsletter for updates and project ideas

Conclusion

  • Encouragement to utilize servo motors in projects
  • Invitation to share project ideas
  • Instructions to subscribe to YouTube channel and newsletter