Arduino Robotics

Book description

This book will show you how to use your Arduino to control a variety of different robots, while providing step-by-step instructions on the entire robot building process. You'll learn Arduino basics as well as the characteristics of different types of motors used in robotics. You also discover controller methods and failsafe methods, and learn how to apply them to your project. The book starts with basic robots and moves into more complex projects, including a GPS-enabled robot, a robotic lawn mower, a fighting bot, and even a DIY Segway-clone.

  • Introduction to the Arduino and other components needed for robotics

  • Learn how to build motor controllers

  • Build bots from simple line-following and bump-sensor bots to more complex robots that can mow your lawn, do battle, or even take you for a ride

What you'll learn

  • Basics of motor-control

  • Basics of PCB design and fabrication

  • R/C control and decoding

  • Autonomous sensor guidance

  • Frame building from various materials

  • Instructions for a variety of robot designs

Who this book is for

Electronics and robotics hobbyists and DIY builders.

Table of contents

  1. Copyright
  2. About the Authors
  3. About the Technical Reviewers
  4. Acknowledgments
  5. Introduction
    1. Prerequisites
  6. 1. The Basics
    1. 1.1. Electricity
      1. 1.1.1. Electrical Analogy
      2. 1.1.2. Electrical Basics
      3. 1.1.3. Circuits
      4. 1.1.4. Measuring Electricity
      5. 1.1.5. Multi-Meters
      6. 1.1.6. Measuring Voltage
      7. 1.1.7. Measuring Amperage
      8. 1.1.8. Measuring Capacitance
      9. 1.1.9. Measuring Resistance
      10. 1.1.10. Calculating Resistor Power Using Ohm's Law
      11. 1.1.11. Oscilloscope
      12. 1.1.12. Loads
        1. 1.1.12.1. Inductive Loads
        2. 1.1.12.2. Resistive Loads
      13. 1.1.13. Electrical Connections
        1. 1.1.13.1. Series Connections
        2. 1.1.13.2. Parallel Connections
        3. 1.1.13.3. Series and Parallel Connection
    2. 1.2. Electronics
      1. 1.2.1. Semi-Conductors
      2. 1.2.2. Datasheets
      3. 1.2.3. Integrated Circuits
        1. 1.2.3.1. Packages
      4. 1.2.4. Through-Hole Components
        1. 1.2.4.1. IC Sockets
        2. 1.2.4.2. Surface-Mount Components (SMT or SMD)
    3. 1.3. Arduino Primer
      1. 1.3.1. Arduino Variants
        1. 1.3.1.1. Standard Arduino
        2. 1.3.1.2. Arduino Mega
        3. 1.3.1.3. Clones
      2. 1.3.2. Arduino IDE
      3. 1.3.3. The Sketch
        1. 1.3.3.1. Variable Declaration
        2. 1.3.3.2. The Setup Function
        3. 1.3.3.3. The Loop Function
      4. 1.3.4. Signals
        1. 1.3.4.1. Digital Signals
          1. 1.3.4.1.1. Digital Inputs
          2. 1.3.4.1.2. Digital Outputs
          3. 1.3.4.1.3. Special Case: External Interrupts
        2. 1.3.4.2. Analog Signals
          1. 1.3.4.2.1. Analog Inputs
          2. 1.3.4.2.2. Analog Outputs (PWM)
          3. 1.3.4.2.3. Duty-Cycle
          4. 1.3.4.2.4. Frequency
          5. 1.3.4.2.5. Homemade PWM Example
    4. 1.4. Building Circuits
      1. 1.4.1. Circuit Design
      2. 1.4.2. Schematics
      3. 1.4.3. Prototyping
        1. 1.4.3.1. Breadboard
        2. 1.4.3.2. Perforated Prototyping Board (Perf-Board)
        3. 1.4.3.3. Printed Circuit Boards
        4. 1.4.3.4. Soldering
          1. 1.4.3.4.1. Soldering Shortcuts
    5. 1.5. Building a Robot
      1. 1.5.1. Hardware
        1. 1.5.1.1. Basic Building Tools
      2. 1.5.2. Materials
      3. 1.5.3. Work Area
    6. 1.6. Summary
  7. 2. Arduino for Robotics
    1. 2.1. Interfacing Arduino
      1. 2.1.1. Relays
        1. 2.1.1.1. Types of Relays
        2. 2.1.1.2. Relay Configurations
        3. 2.1.1.3. Uses
        4. 2.1.1.4. Calculating Current Draw
        5. 2.1.1.5. Back-EMF Considerations
        6. 2.1.1.6. Solid-State switches
      2. 2.1.2. Transistors
        1. 2.1.2.1. Bipolar Junction Transistor (BJT)
        2. 2.1.2.2. Mosfets
          1. 2.1.2.2.1. Logic-Level vs. Standard
          2. 2.1.2.2.2. Mosfet Capacitance
          3. 2.1.2.2.3. On-State Resistance—Rds(On)
          4. 2.1.2.2.4. Calculating heat using Rds(On) and amperage of DC motor:
          5. 2.1.2.2.5. Parallel Mosfets
        3. 2.1.2.3. Photo-Transistors
      3. 2.1.3. Interfacing a Motor-Controller
        1. 2.1.3.1. Motor-controller ICs
          1. 2.1.3.1.1. Electronic Speed Controllers (ESCs)
    2. 2.2. User Control
      1. 2.2.1. Tethered (Wired) Control
      2. 2.2.2. Infrared Control (IR)
      3. 2.2.3. Radio Control Systems
        1. 2.2.3.1. Amplitude Modulation (AM)
        2. 2.2.3.2. Frequency Modulation (FM)
        3. 2.2.3.3. Spread Spectrum 2.4gHz
        4. 2.2.3.4. Xbee
    3. 2.3. Sensor Navigation
      1. 2.3.1. Contact Sensing
        1. 2.3.1.1. Bump Switch
      2. 2.3.2. Distance and Reflection Sensing
        1. 2.3.2.1. IR Sensor
        2. 2.3.2.2. Ultrasonic Range Finder
        3. 2.3.2.3. Laser Range Finder
      3. 2.3.3. Orientation (Positioning)
        1. 2.3.3.1. Accelerometer
        2. 2.3.3.2. Gyroscope
        3. 2.3.3.3. Inertial Measurement Unit (IMU)
        4. 2.3.3.4. Global Positioning Satellite (GPS)
          1. 2.3.3.4.1. Real Time Kinetic (RTK) GPS
      4. 2.3.4. Non-Autonomous Sensors
        1. 2.3.4.1. Camera
        2. 2.3.4.2. Current Sensor
    4. 2.4. Summary
  8. 3. Let's Get Moving
    1. 3.1. Electric Motors
      1. 3.1.1. Brushed DC Motor (Permanent Magnet Type)
      2. 3.1.2. Brushless Motors
      3. 3.1.3. Stepper Motors
      4. 3.1.4. Gear Motors
      5. 3.1.5. Servo Motors
        1. 3.1.5.1. Continuous Rotation
      6. 3.1.6. Linear Actuators
      7. 3.1.7. Calculating Power
      8. 3.1.8. Driving
      9. 3.1.9. Finding the Right Motor
    2. 3.2. The H-Bridge
      1. 3.2.1. Generating a Brake
      2. 3.2.2. Implementation
        1. 3.2.2.1. Method 1: Simple Switches
        2. 3.2.2.2. Method 2: DPDT Relay with Simple
        3. 3.2.2.3. Method 3: P-Channel and N-Channel Mosfets
        4. 3.2.2.4. Method 4: N-Channel H-Bridge
      3. 3.2.3. H-Bridge ICs
      4. 3.2.4. Changing PWM Frequencies
      5. 3.2.5. Back EMF
      6. 3.2.6. Current Sensing
      7. 3.2.7. Commercial H-Bridges (Motor-Controllers)
        1. 3.2.7.1. Small (Up to 3amps)
        2. 3.2.7.2. Medium (Up to 10amps)
        3. 3.2.7.3. Large (Over 10amps)
          1. 3.2.7.3.1. The Open Source Motor Controller (OSMC)
    3. 3.3. Batteries
      1. 3.3.1. Nickel Cadmium (NiCad)
      2. 3.3.2. Nickel Metal Hydride (NiMH)
      3. 3.3.3. Lithium Polymer (LiPo)
      4. 3.3.4. Lead-Acid
      5. 3.3.5. Charging
    4. 3.4. Materials
      1. 3.4.1. Wood
      2. 3.4.2. Metals
      3. 3.4.3. Nuts and Bolts
      4. 3.4.4. Plastics
      5. 3.4.5. Chain and Sprockets
      6. 3.4.6. Wheels
    5. 3.5. Summary
  9. 4. Linus the Line-Bot
    1. 4.1. Parts List for Linus
    2. 4.2. How Linus Works
      1. 4.2.1. The Track
    3. 4.3. Building the IR Sensor Board
    4. 4.4. Modifying a Servo for Continuous Rotation
      1. 4.4.1. Method 1: Direct DC Drive with External Speed Controller
      2. 4.4.2. Method 2: Servo Pulse Drive with Internal Motor Driving Circuitry
    5. 4.5. Fitting the Drive wheels
    6. 4.6. Making a Frame
    7. 4.7. Making Connections
    8. 4.8. Installing Batteries
      1. 4.8.1. Install Power Switch
    9. 4.9. Loading the Code
    10. 4.10. Making the Track
    11. 4.11. Testing
    12. 4.12. Add-ons
      1. 4.12.1. LED Lights
      2. 4.12.2. Painting
      3. 4.12.3. Adding Speed Regulator (Potentiometer)
    13. 4.13. Summary
  10. 5. Wally the Wall-Bot
    1. 5.1. How Wally Works
    2. 5.2. Parts List for Wally
    3. 5.3. The Motor-Controller
      1. 5.3.1. The High-Side Switches
      2. 5.3.2. The Low-Side Switches
      3. 5.3.3. Building the Circuit
    4. 5.4. Building the Frame
    5. 5.5. Installing the Sensors
    6. 5.6. Installing the Battery and Power Switch
      1. 5.6.1. Installing a Power Switch
    7. 5.7. The Code
      1. 5.7.1. Code Objectives
    8. 5.8. Summary
  11. 6. Making PCBs
    1. 6.1. PCB Basics
    2. 6.2. What You Need to Get Started
    3. 6.3. Circuit Design
      1. 6.3.1. Searching for Open-Source Designs
      2. 6.3.2. Making Your Own Designs
        1. 6.3.2.1. Schematics
        2. 6.3.2.2. Board Layouts
      3. 6.3.3. Working with the Schematic Editor
      4. 6.3.4. Working with the Board Editor
    4. 6.4. Transferring the Design
      1. 6.4.1. Let's Make an Arduino Clone: the Jduino
      2. 6.4.2. Making the Transfer
    5. 6.5. Etching
      1. 6.5.1. Measuring the Solution
      2. 6.5.2. Etching: Method 1
      3. 6.5.3. Etching: Method 2
      4. 6.5.4. Removing the Toner
    6. 6.6. Drilling
    7. 6.7. Soldering
      1. 6.7.1. Building the Arduino Clone
      2. 6.7.2. Building the BJT H-Bridge
    8. 6.8. Testing
    9. 6.9. Summary
  12. 7. The Bug-Bot
    1. 7.1. Reading a Switch with Arduino
    2. 7.2. How the Bug-bot Works
      1. 7.2.1. Antennae Sensors
      2. 7.2.2. Bumper Sensors
    3. 7.3. Parts List for the Bug-bot
    4. 7.4. The Motors
      1. 7.4.1. Modifying the Servo Motors
      2. 7.4.2. Controlling the Servo Motors
      3. 7.4.3. Converting the Pulse Value to Degrees
      4. 7.4.4. Mounting the Wheels to the Servos
    5. 7.5. Building the Frame
      1. 7.5.1. Marking the PlexiGlass
      2. 7.5.2. Cutting the PlexiGlass
      3. 7.5.3. Mounting the Motors
      4. 7.5.4. Mounting the Caster Wheels
      5. 7.5.5. Mounting the Arduino
      6. 7.5.6. Installing the Battery
    6. 7.6. Making the Sensors
      1. 7.6.1. The Front Antennae Sensors
      2. 7.6.2. The Rear Bump Sensors
    7. 7.7. Making Wire Connections
    8. 7.8. Loading the Code
      1. 7.8.1. Creating a Delay
      2. 7.8.2. Variables
      3. 7.8.3. The Code
    9. 7.9. Making a Top Hat
    10. 7.10. Summary
  13. 8. Explorer-Bot
    1. 8.1. How the Explorer-Bot Works
      1. 8.1.1. R/C Control
      2. 8.1.2. Powerful Motors
      3. 8.1.3. Current Sensing
      4. 8.1.4. Video-Enabled
      5. 8.1.5. Xbee-Enabled
    2. 8.2. Parts List for the Explorer-Bot
    3. 8.3. Building the Frame
      1. 8.3.1. Specs
      2. 8.3.2. Adding Battery Bracket
      3. 8.3.3. Cut Top Frame Brackets
      4. 8.3.4. Cut Top Frame Braces
      5. 8.3.5. Cut and Bend Main Frame Piece
      6. 8.3.6. Add Crossbar and Mount Caster Wheel
        1. 8.3.6.1. Plexiglass Deck (Optional)
    4. 8.4. Building the Motor Controller
      1. 8.4.1. Current Sensing and Limiting
      2. 8.4.2. H-bridge Design
    5. 8.5. Setting Up the Arduino
      1. 8.5.1. Connecting the H-Bridges
    6. 8.6. Setting Up Xbee
      1. 8.6.1. Testing the Xbees
    7. 8.7. Adding a Camera
      1. 8.7.1. Pan and Tilt
      2. 8.7.2. Make First Bracket
      3. 8.7.3. Make Second Bracket
    8. 8.8. Loading the Code
    9. 8.9. Summary
  14. 9. RoboBoat
    1. 9.1. Some Words in Advance
    2. 9.2. Parts List for the RoboBoat
      1. 9.2.1. Polystyrene Foam
      2. 9.2.2. Epoxy Resin
      3. 9.2.3. Gloves
      4. 9.2.4. Fiberglass Fabric
      5. 9.2.5. Glue
      6. 9.2.6. Styrofoam Cutter and Razor Knife
      7. 9.2.7. Miscellaneous
    3. 9.3. The RoboBoat Design
    4. 9.4. Assembling the Boat
      1. 9.4.1. The Templates
      2. 9.4.2. Gluing the Templates on the EPS/XPS Board
      3. 9.4.3. Cutting Out the Segments
      4. 9.4.4. Gluing the Segments Together
      5. 9.4.5. Inserting the Foam Anchors
      6. 9.4.6. The Coating
      7. 9.4.7. Applying the Finish
      8. 9.4.8. The Fins
      9. 9.4.9. Painting
      10. 9.4.10. The Deck
      11. 9.4.11. Completing the Assembly
    5. 9.5. The Propulsion Assembly
      1. 9.5.1. The Baseplate
      2. 9.5.2. The Pivot
      3. 9.5.3. The Tube
      4. 9.5.4. The Rudder Horns
      5. 9.5.5. The Motor
      6. 9.5.6. The Servo
      7. 9.5.7. The Pushrods
    6. 9.6. Electronics
      1. 9.6.1. The Heart of the System: The ArduPilot PCB
      2. 9.6.2. The GPS Module
      3. 9.6.3. The Electronic Speed Controller (ESC)
      4. 9.6.4. The Motor
      5. 9.6.5. The Rudder Servo
      6. 9.6.6. The Battery Pack
      7. 9.6.7. Assembling the Electronics
        1. 9.6.7.1. The Programming Adapter
    7. 9.7. Software and Mission Planning
      1. 9.7.1. GPS Receivers
      2. 9.7.2. The Software
        1. 9.7.2.1. AP_RoboBoat Module
        2. 9.7.2.2. Debug Module
        3. 9.7.2.3. Init Module
        4. 9.7.2.4. Navigation Module
        5. 9.7.2.5. PID_control Module
        6. 9.7.2.6. Servo_control Module
        7. 9.7.2.7. Header Files
      3. 9.7.3. Installing the Software
        1. 9.7.3.1. Installing the Arduino IDE
        2. 9.7.3.2. Configuring the Arduino IDE
        3. 9.7.3.3. Compiling and Uploading the Code
        4. 9.7.3.4. Customizing the Code
          1. 9.7.3.4.1. Customizing the Rudder Control
          2. 9.7.3.4.2. Customizing the PID Constants
          3. 9.7.3.4.3. Customizing the Motor Speed
          4. 9.7.3.4.4. Customizing the Waypoint Timeout
          5. 9.7.3.4.5. Customizing the Waypoint Radius
          6. 9.7.3.4.6. Customizing the Rudder Extents
      4. 9.7.4. Mission Planning
        1. 9.7.4.1. Employing Google Earth for the Coordinates
    8. 9.8. Putting It All Together
      1. 9.8.1. Integrating the System
      2. 9.8.2. Ships Ahoy!
    9. 9.9. Troubleshooting
      1. 9.9.1. The Thrust of the Motor/Propeller Is Not Sufficient
      2. 9.9.2. The Motor Does Not Start
    10. 9.10. Summary
  15. 10. Lawn-Bot 400
    1. 10.1. How the Lawn-bot 400 Works
      1. 10.1.1. Lawn Mower Deck
      2. 10.1.2. High-Capacity Batteries
      3. 10.1.3. Steel Frame
      4. 10.1.4. Dump-Bucket
      5. 10.1.5. Pneumatic Tires
      6. 10.1.6. Headlights
      7. 10.1.7. Failsafe
    2. 10.2. Tools and Parts List
      1. 10.2.1. Lawnmower
      2. 10.2.2. Parts Lists
    3. 10.3. The Wheels
      1. 10.3.1. Front Caster Wheels
      2. 10.3.2. Rear Drive Wheels
      3. 10.3.3. Installing Sprockets
    4. 10.4. The Frame
    5. 10.5. The Drive-Train
      1. 10.5.1. Motor Mount Brackets
      2. 10.5.2. Installing the Chain
    6. 10.6. The Motor Controller
      1. 10.6.1. Buying a Motor Controller
        1. 10.6.1.1. Sabertooth 2×25
      2. 10.6.2. Cooling Fans
      3. 10.6.3. Motor Controller feedback
        1. 10.6.3.1. Current sensor IC
    7. 10.7. The Arduino
      1. 10.7.1. Securing Connections for a Bumpy Ride
        1. 10.7.1.1. Building a Breakout Board
    8. 10.8. The Failsafe
      1. 10.8.1. R/C Toggle Switch
      2. 10.8.2. Power Relays
      3. 10.8.3. Avoiding an R/C Failsafe
    9. 10.9. Making Connections
    10. 10.10. The Code
    11. 10.11. Adding Cosmetics and Accessories
      1. 10.11.1. Painting
      2. 10.11.2. Headlights
      3. 10.11.3. Dump Bucket
      4. 10.11.4. Lawnmower Kill-Switch
    12. 10.12. Summary
  16. 11. The Seg-Bot
    1. 11.1. How the Seg-Bot Works
      1. 11.1.1. Inertial Measurement Unit
      2. 11.1.2. Steering and Gain
      3. 11.1.3. Engage Switch
    2. 11.2. Parts List for the Seg-Bot
    3. 11.3. Selecting the Right Sensors
      1. 11.3.1. 3.3v Power
      2. 11.3.2. Accelerometer
      3. 11.3.3. Gyroscope
        1. 11.3.3.1. Cycle Time
        2. 11.3.3.2. Gyro Starting Point
        3. 11.3.3.3. Gyroscope Drift
      4. 11.3.4. Gyroscope Versus Accelerometer Summary
      5. 11.3.5. Filtering the Angle
        1. 11.3.5.1. Weighted Average
    4. 11.4. Making the IMU Adapter Board
    5. 11.5. Selecting the Motors
      1. 11.5.1. Electric Brake Removal
      2. 11.5.2. Motor Mounting Position
    6. 11.6. Selecting the Motor Controller
      1. 11.6.1. SoftwareSerial Library
      2. 11.6.2. Sabertooth Simplified Serial
    7. 11.7. The Batteries
      1. 11.7.1. Sealed Lead-Acid
      2. 11.7.2. Charging
      3. 11.7.3. 12v Supply
    8. 11.8. The Frame
      1. 11.8.1. Frame Design
      2. 11.8.2. Building the Frame
    9. 11.9. Inputs
      1. 11.9.1. Steering
      2. 11.9.2. Gain
      3. 11.9.3. Engage Switch
      4. 11.9.4. Level-Start
      5. 11.9.5. Mounting the Inputs to the Frame
    10. 11.10. Installing the Electronics
      1. 11.10.1. Soldering the Inputs
      2. 11.10.2. Wiring the Connections
    11. 11.11. Reviewing the Code
      1. 11.11.1. The sample_accel() Function
      2. 11.11.2. The sample_gyro() Function
      3. 11.11.3. Checking the Angle Readings
      4. 11.11.4. The calculate_angle() Function
      5. 11.11.5. The read_pots() Function
      6. 11.11.6. The auto_level() Function
      7. 11.11.7. The update_motor_speed() Function
      8. 11.11.8. The time_stamp() Function
      9. 11.11.9. The serial_print_stuff() Function
      10. 11.11.10. The Full Code
    12. 11.12. Testing
    13. 11.13. Summary
    14. 11.14. References
  17. 12. The Battle-Bot
    1. 12.1. Robotic Combat Is Born
      1. 12.1.1. Battle-Bot Rules and Regulations
      2. 12.1.2. No Price Limit!
        1. 12.1.2.1. Is This Going to Be Expensive?
    2. 12.2. Parts List for the Battle-Bot
    3. 12.3. Input Control
      1. 12.3.1. Fly Sky CT-6: The $32, 5-ch*, 2.4GHz Radio Alternative
        1. 12.3.1.1. Attention Hackers
    4. 12.4. The Electronics
      1. 12.4.1. The Arduino
      2. 12.4.2. The Motor Controllers
    5. 12.5. The Frame
      1. 12.5.1. To Buy or Build?
      2. 12.5.2. Modifying the Wheels
      3. 12.5.3. Building the Frame
    6. 12.6. The Drive Train
      1. 12.6.1. Gearing
        1. 12.6.1.1. Calculating Gear Ratio
        2. 12.6.1.2. Modifications
      2. 12.6.2. Chain Tensioning Nut
        1. 12.6.2.1. Threading Sequence
        2. 12.6.2.2. Measuring the Chain
        3. 12.6.2.3. Adding Spacers
    7. 12.7. Batteries
    8. 12.8. Securing Electronics
      1. 12.8.1. Protecting Your Brains
      2. 12.8.2. Making Connections
    9. 12.9. The Code
    10. 12.10. Armor
    11. 12.11. Weapons
    12. 12.12. Additional Information
    13. 12.13. Summary
  18. 13. Alternate Control
    1. 13.1. Using Processing to Decode the Signals
    2. 13.2. Parts List for Alternate Control
    3. 13.3. Selecting the Input
    4. 13.4. Processing Prerequisites
    5. 13.5. Following Protocol
    6. 13.6. Examining the Processing Sketch
      1. 13.6.1. Explanation
      2. 13.6.2. Testing Processing
    7. 13.7. Examining the Arduino Sketch
    8. 13.8. Summary

Product information

  • Title: Arduino Robotics
  • Author(s):
  • Release date: July 2011
  • Publisher(s): Apress
  • ISBN: 9781430231837