Motor Controller for BeagleBone Black

3,399 views
Skip to first unread message

raslab.f...@gmail.com

unread,
Sep 4, 2013, 9:48:22 AM9/4/13
to beagl...@googlegroups.com
We are building a robot and we want to use the BeagleBone Black.
We want a motor controller that is cabable of:
- Control of two DC brushed motors
- 12V nominal
- 2.5A continuous, 4A peak
- PWM
- with Encoders

Any ideas where we can find such motor controller? We looked in the capes and there is no one available with our specifications

Gerald Coley

unread,
Sep 4, 2013, 9:49:31 AM9/4/13
to beagl...@googlegroups.com


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andrey Nechypurenko

unread,
Sep 5, 2013, 2:53:06 AM9/5/13
to beagl...@googlegroups.com
> We want a motor controller that is cabable of:
> - Control of two DC brushed motors
> - 12V nominal
> - 2.5A continuous, 4A peak
> - PWM
> - with Encoders

You can take a look at this one:
http://www.robot-electronics.co.uk/htm/md25tech.htm

T.Morgan

unread,
Sep 5, 2013, 2:29:55 PM9/5/13
to beagl...@googlegroups.com, raslab.f...@gmail.com
I'm using an Arduino Motor & Servo Shield. It's obviously not pin compatible, but it's cheap ($20).
The only fiddly part is controlling the on-board 74595 shift-register. I used the following Python script.


import Adafruit_BBIO.GPIO as GPIO

# Beaglebone pin names for interface to 74HCT595 latch
# (Arduino lib name = shield name = BBB pin)
MOTORENABLE = DIR_EN = "P8_15"
MOTORDATA = DIR_SER = "P8_16"
MOTORCLK = DIR_CLK = "P8_9"
MOTORLATCH = DIR_LATCH = "P8_10"

def bit(n): return  1<<n

class ShiftRegister(object):
      
    def __init__(self, d):
        self.data = d
        GPIO.setup(DIR_EN,GPIO.OUT)
        GPIO.setup(DIR_SER,GPIO.OUT)
        GPIO.setup(DIR_CLK,GPIO.OUT)
        GPIO.setup(DIR_LATCH,GPIO.OUT)
        GPIO.output(DIR_EN,GPIO.LOW)      # Enable shift register
        self.transmit()                 # Switch off (RELEASE) all motors
   
    def string(self): return '{0:08b}'.format(self.data)
    def bit(self, n): return GPIO.HIGH if (self.data & bit(n)) else GPIO.LOW
    def set(self, n, x): # Set the nth bit on or off
        if x:
            self.data |= bit(n)
        else:
            self.data &= ~bit(n)
    def setall(self, d): self.data = d

    # Copy self.data to the 74HCT595 shift register one bit at a time via the
    # serial data bit (DIR_SER). Each time the serial clock (DIR_CLK) goes from
    # low to high, the current contents of the 74HCT595's register are shited
    # one bit to the left and DIR_SER is copied into the rightmost bit.
    # When DIR_LATCH goes from low to high the contents of the shift register
    # are moved to the chip's 8 output pins.
    # (These 8 bits control the motor shield's 4 H-bridges.)
    def transmit(self):
        GPIO.output(DIR_LATCH,GPIO.LOW)        # - Set latch trigger low
        GPIO.output(DIR_SER,GPIO.LOW)        # - Set serial data bit low
        for i in xrange(0,8):                # - For each bit of motor_register:
            GPIO.output(DIR_CLK,GPIO.LOW)    # - Set serial clock trigger low
            GPIO.output(DIR_SER, self.bit(7-i)) # - Copy register bit(7-i) to the serial data bit
            GPIO.output(DIR_CLK,GPIO.HIGH)    # - Set serial clock trigger high; the
                                            #   rising edge shifts the serial data bit
                                            #   into the 74HCT595's shift register.
        GPIO.output(DIR_LATCH,GPIO.HIGH)    # - Set the latch trigger high; the
                                            #   rising edge sends the stored
                                            #   bits to the 74HCT595's parallel outputs.
        GPIO.output(DIR_SER,GPIO.LOW)
        GPIO.output(DIR_CLK,GPIO.LOW)
        GPIO.output(DIR_LATCH,GPIO.LOW)

and call with:

# Shift register bits motor control bits (from AFmotor.h)
# (Bit positions in the 74HCT595 shift register output.)
MOTOR1_A = 2
MOTOR1_B = 3
MOTOR2_A = 1
MOTOR2_B = 4
MOTOR3_A = 5
MOTOR3_B = 7
MOTOR4_A = 0
MOTOR4_B = 6
MOTOR_BITS = [(MOTOR1_A,MOTOR1_B), (MOTOR2_A,MOTOR2_B), (MOTOR3_A,MOTOR3_B), (MOTOR4_A,MOTOR4_B)]

# 74HCT595 output bits
#  7   6   5   4   3   2   1   0
# 3B, 4B, 3A, 2B, 1B, 1A, 2A, 4A

class Robot(object):
   
    def __init__(self):
        self.control_bits = shift_register.ShiftRegister(0)
        ...

    # Switch motor's control bits depending on command.
    def run(self, motornum, cmd):
  
        # Find the control bits (74HCT595 output pins) corresponding to the given motor.
        a, b = MOTOR_BITS[motornum -1]        # Arduino library uses 1..4
   
        # Translate the given command into a pair of control bits
        x, y = COMMAND_BITS[cmd -1]            # Arduino library uses 1..4
       
        self.control_bits.set(a, x)         # Set bit MOTORn_A
        self.control_bits.set(b, y)         # and bit MOTORn_B.
        self.control_bits.transmit()        # Send the control bits to the 74HCT595.

Paul Tan

unread,
Sep 12, 2013, 10:49:25 AM9/12/13
to beagl...@googlegroups.com, raslab.f...@gmail.com
We finally have our web store launched and we are producing the Dual Motor Controller Cape in decent quantity (making 100 in this batch).
The spec are:
- Dual motor control of DC brushed motor
- 5V to 28V 
- 7A Max continuous 
- Quadrature encoder interface
- PID with programmable Kp, Ki, Kd constants
- Velocity PID
- Simple 'C' interface
- Stackable cape allowing up to 4 capes to be used on a single Beaglebone black.

You can find more information at http://exadler.blogspot.com, and our webstore is live at https://exadler.myshopify.com.

Paul Tan.

Teknoman117

unread,
Dec 1, 2013, 8:22:27 PM12/1/13
to beagl...@googlegroups.com, raslab.f...@gmail.com
Hey! Nice board!  Is the motor control done through the onboard hardware, or is there a microcontroller in it?

- Nathaniel Lewis

paulj...@yahoo.com

unread,
Dec 11, 2013, 2:06:34 AM12/11/13
to beagl...@googlegroups.com, raslab.f...@gmail.com
It looks like he is using Microchip microcontroller on it. I'm curious if anyone tried to use PRU-ICSS unit to control more than 3 motion channels (there are "only" 3 QEI channels on TI AM335x).

Nathaniel Lewis

unread,
Dec 22, 2013, 9:50:57 PM12/22/13
to beagl...@googlegroups.com
It is probably not too difficult, especially if using the lines directly attached to the PRUs.  However, you’d be sacrificing one of your PRUs.  One of mine is dedicated to sonar timing.

Nathaniel Lewis
3rd year Undergraduate, Computer Science and Engineering
Vice President of the Robotics Society at UC Merced
Undergraduate Lab Technician Intern at the Mechatronic, Embedded Systems, and Automation Labs
(925) 309 9730
linux.r...@gmail.com


Paul Tan

unread,
Dec 23, 2013, 2:24:37 PM12/23/13
to beagl...@googlegroups.com, raslab.f...@gmail.com
The motor control and quadrature encoder is done using an onboard Microchip dsPIC processor.  The communication with the Beaglebone is done using i2c, that way we can stack multiple DMCC boards on top of a single Beaglebone.

Paul Tan.
Exadler Technologies Inc.

manj...@gmail.com

unread,
Feb 16, 2014, 6:24:05 PM2/16/14
to beagl...@googlegroups.com, raslab.f...@gmail.com
Hi Morgan,

How is the Motor shield wired to the beaglebone? I see that you are using P8_9,10,15, and 16, wondering what pins on the shield are the hooked up to. 

Tony Morgan

unread,
Feb 17, 2014, 2:43:54 PM2/17/14
to beagl...@googlegroups.com
The pin names in the Python code match the signal names on the schematic at http://osepp.com/wp-content/uploads/2013/07/OSEPP_motor_shield_v1-0.pdf.

So, DIR_SER=Arduino.D8, DIR_EN=Arduino.D7, DIR_ CLK=Arduino.D4 and DIR_LATCH=Arduino.D12.

When I get round to it, I'm going to replace the motor shield and Beaglebone PWM outputs with a purpose-built daughterboard.
I'll use an ATmega328p with a couple of H-bridge drivers controlled via I2C from the BBB.
I found that the BBB is too susceptible to noise and motor startup current drain to interface to servos directly.
I'll have the BBB and sensors running on separate 3.3V supply from the daughterboard, motors and servos on 5V.

Good luck.


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/bBNE16rJA5w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages