Reader small image

You're reading from  Mastering Beaglebone Robotics

Product typeBook
Published inDec 2014
Reading LevelBeginner
Publisher
ISBN-139781783988907
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Richard Grimmett has more fun that should be allowed working on robotics projects while teaching Computer Science and Electrical Engineering at Brigham Young University Idaho. He has a Bachelors and Masters degree in Electrical Engineering and a PhD in Leadership Studies. He also has 26 years of experience in the Radar and Telecommunications industries, and even has one of the original brick phones. He has written books on the basics of using the BeagleBone Black for robotics projects, and another for the Raspberry PI and yet another for the Arduino.
Read more about Richard Grimmett

Right arrow

Program to control DC motors using the BeagleBone Black


Now that you've connected your motor, here is a simple Python program to control one of the motors:

Let's look at the details. Here are the individual command statements:

  • #!/usr/bin/python: As noted earlier, this command sets up the program to be executed without invoking Python

  • import Adafruit_BBIO.PWM as PWM: This library is used to communicate with the GPIO pins

  • motor1 = "P8_13": This sets the motor to PWM control P8_13—the 13th pin on the 8th connector

  • duty_stop = 9: This sets the duty cycle of the PWM that is needed to stop the motor

  • duty_forward = 12 # 12 max: This sets the duty cycle of the PWM signal on the control pin that is needed to make the motor go in the forward direction at the maximum speed

  • duty_back = 6 # 6 min: This sets the duty cycle of the PWM signal on the control pin that is needed to make the motor go in the backward direction at the maximum speed

  • PWM.start(motor1, duty_stop, 60.0): This sets the PWM signal...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering Beaglebone Robotics
Published in: Dec 2014Publisher: ISBN-13: 9781783988907

Author (1)

author image
Richard Grimmett

Richard Grimmett has more fun that should be allowed working on robotics projects while teaching Computer Science and Electrical Engineering at Brigham Young University Idaho. He has a Bachelors and Masters degree in Electrical Engineering and a PhD in Leadership Studies. He also has 26 years of experience in the Radar and Telecommunications industries, and even has one of the original brick phones. He has written books on the basics of using the BeagleBone Black for robotics projects, and another for the Raspberry PI and yet another for the Arduino.
Read more about Richard Grimmett