Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Servo Motor Controlling with Beaglebone Black (Part 6/15)

By Ashish Vara June 29, 2021

Beaglebone Black Servo Motor Control

This tutorial  explains about the fundamental use of PWM where servo motor is controlled by potentiometer.  It is a DC motor which operates on electrical pulse. You can directly interface servo motor with Beaglebone black without any driver IC.  For this you have to write a program in python script with adafruit PWM and ADC library.

Required Tools:

  • Beaglebone Black
  • Servo motor ( Micro servo 9g)
  • Potentiometer ( 5k Ω )
  • 1 k Ω Resistor
  • Breadboard
  • Female to Female connectors

Setup of Software environment

Install the latest python version in BBB as explained in tutorial How to make first python program with Beaglebone Black. Install the adafruit python-GPIO library named adafruit_BBIO.

Working

It is a simple learning tutorial in which I have interfaced servo motor and potentiometer with Beaglebone black. When script is being  executed, it enters into a continuous loop. Servo motor’s position  varies according to the value of potentiometer. If you vary the value of potentiometer, servo motor’s rotational angle also changes. When  the entered angle value  reaches the threshold value of servo motor, exit form continuous loop and stop the program. Press ctrl+C  to stop the execution of program form SSH command terminal.

Description

Let’s first prepare the circuit connection. Take a breadboard and provide VCC and ground from BBB to breadboard line. Servo motor  requires 4.8 V while Potentiometer needs only 3.3 V. BBB has 5 V on chip system and 3.3 V on pin header which allows you to draw both supplies from Beaglebone Black. System 5 V is drawn for Servo motor and 3.3V is drawn for potentiometer.  On one side of breadboard, Connect Supply 3.3 V from pin number 3rd of header P9 and ground from pin number 2nd of header P8. Another side of breadboard connects supply system 5 V from pin number 8th of header P9 and makes ground common with pin number 2nd of header P8.

Potentiometer has three terminals.  The middle one is output terminal and is connected with ADC pin (40th pin of header P9) of Beaglebone black. Output of potentiometer is analog value that’s why it’s connected with ADC pin. Any left or right pin of potentiometer is connected with 3.3 V and remaining pins are connected with ADC ground pin (34th pin of header P9).

Servo motor has also three terminals:

            Orange wire – Pulse input

            Red wire – Vcc

            Brown wire – Ground

Beaglebone controlled servo motor

Servo motor is rotary actuator which controls the linear or angular position of motor.  It is controlled by electrical pulse with various width or Pulse Width Modulation. BBB has on chip PWM pin. Servo motor is interfaced with PWM pin (13th pin of header P8) of BBB. I have interfaced 1k ohm resistor between  the two so as to protect it from unnecessary damage.

You may also like:


  • What are LoRa gateways and what types are available?

  • What is the role of embedded software in electric vehicles?

  • What are the components of robotic arms and industrial robots?

  • What is an Actuator Sensor Interface (AS-i)?

  • What are the top open-source software systems for home automation?

  • What are inertial sensors?

Project Source Code

 

Project Source Code

###


import Adafruit_BBIO.PWM as PWM
import Adafruit_BBIO.ADC as ADC
 
 
servo_pin = "P8_13"
 
sensor_pin = 'P9_40'
 
ADC.setup()
 
duty_min = 85
duty_max = 95
duty_span = duty_max - duty_min
PWM.start(servo_pin, (100-duty_min), 60.0)
 
while True:
 
        reading = ADC.read(sensor_pin)
        angle = reading * 1800                            
        if angle > 270:
                PWM.stop(servo_pin)
                PWM.cleanup()
                break
        anglefl = float(angle)
        duty = 100 - ((anglefl / 180) * duty_span + duty_min)
        PWM.set_duty_cycle(servo_pin, duty)      

###

 


Circuit Diagrams

beagleblack-controlled-servo-BBB6

Project Video


Filed Under: BeagleBone, Electronic Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe