Motor Bridge Cape v1.0

The Motor Bridge Cape features bi-directional motor control using two TB6612FNG integrated dual H-bridge, so it can control two stepper motors or four brushed DC motors with 6 ~15V DC power and about 1A current draw per motor. The cape provides 5V regulated power to BBG or BBB with a max input voltage of 15V. It also has six servo control interfaces and six expand I\O.  All the features are provided by the on board STM32F0 coprocessor. The MCU can communicate with BeagleBone by I2C or UART interface. 





Features


Specification


Hardware Overview



Getting Started

After this section, I will show you how to use the Motor Bridge Cape on BBG. Before you get started, please download the Motor Bridge Cape Driver library code from the Github.

To use the Motor Bridge Cape Library simply add the MotorBridge.py file to your project. And import the python file to your project, and create a object of the Motor Bridge Cape.

import MotorBridge
motor = MotorBridge.MotorBridgeCape()

Stepper Motor

The Stepper Motor Interface of Motor Bridge Cape just as the picture below shows.

The functions of Stepper Motor

Here is the brief description about the function of stepper motor.

StepperMotorAInit()

Description : Init the Stepper Motor A port

StepperMotorAMove(MoveSteps,StepDelayTime)

Description : Drive the Stepper Motor A.
MoveSteps : How many steps the stepper motor will move. Positive stands for clock wise direction. Negative stands for counter-clock wise direction.
StepDelayTime : The dead time for every step. unit: us.

StepperMotorBInit()

Description : Init the Stepper Motor B port

StepperMotorBMove(MoveSteps,StepDelayTime)

Description: Drive the Stepper Motor B.
MoveSteps: How many steps the stepper motor will move. Positive stands for clock wise direction. Negative stands for counter-clock wise direction.
StepDelayTime: The dead time for every step. unit: us.

Example of Stepper Motor

Copy the following code to your project and save it as a python file.

import MotorBridge
import time
 
def StepperMotorATest():
    print 'Hello From MotorBridge'
    motor.StepperMotorAInit()
    motor.StepperMotorAMove(1000,1000) # 1000 steppers  1000us every step
    time.sleep(1)
    motor.StepperMotorAMove(-1000,1000) #1000 steppers  1000us every step
    time.sleep(1)
 
def StepperMotorBTest():
    print 'Hello From MotorBridge'
    motor.StepperMotorBInit()
    motor.StepperMotorBMove(1000,1000) # 1000steppers  1000us every step
    time.sleep(1)
    motor.StepperMotorBMove(-1000,1000) # 1000 steppers  1000us every step
    time.sleep(1)
 
 
if __name__=="__main__":
    motor = MotorBridge.MotorBridgeCape()
    StepperMotorATest()
    StepperMotorBTest()

DC Motor

The DC Motor Interface of Motor Bridge Cape just as the picture below shows.

The functions of DC Motor

Here is the brief description about the functions of DC motor.

DCMotorInit(MotorName,Frequency)

Description: Init the DC Motor ant set the frequency
MotorName: 1 ~ 4 stands for Motor1 ~ Motor4.
Frequency: Set the frequency of the DC motor.

Note:If you change the DC motor frequency, the other DC Motors's frequency will change too.

DCMotorMove(MotorName,Direction,PWMDuty)

Description: Drive the DC Motor. Set the direction and PWMDuty.
MotorName: 1 ~ 4 stands for Motor1 ~ Motor4.
Direction: 1 stands for clock wise. 2 stands for counter-clock wise. 3 Stop the motor.
PWMDuty: 0 ~ 100 stands for 0%~ 100% of the pwm duty.

motor.DCMotorStop(MotorName)

Description: Stop the DC Motor.
MotorName: 1 ~ 4 stands for Motor1 ~ Motor4.

Example of DC Motor

Copy the following code to your project and save it as a python file.

import MotorBridge
import time
 
MotorName        = 1
ClockWise        = 1
CounterClockWise = 2
PwmDuty          = 90
Frequency        = 1000
 
if __name__=="__main__":
    motor = MotorBridge.MotorBridgeCape()
    motor.DCMotorInit(MotorName,Frequency)
    while True:
        motor.DCMotorMove(MotorName,ClockWise,PwmDuty)
        time.sleep(2)
        motor.DCMotorMove(MotorName,CounterClockWise,PwmDuty)
        time.sleep(2)
        print "hello"
        motor.DCMotorStop(MotorName)
        time.sleep(2)

Servo

The Servo Interface of Motor Bridge Cape just as the picture below shows.

The functions of Servo

Here is the brief description about the functions of Servo.

ServoInit(ServoName,Frequency)

Description: Init the Servo and set the frequency
ServoName: 1 ~ 6 stands for Servo1 ~ Servo6.
Frequency: Set the frequency of the Servo, the default value is 50 Hz.

ServoMoveAngle(ServoName,Angle)

Description: Drive the Servo. Set the Servo angle.
ServoName: 1 ~ 6 stands for Servo1 ~ Servo6.
Angle: 0 ~ 180 stands for 0 degrees to 180 degrees.


Example of Servo

Copy the following code to your project and save it as a python file.

import MotorBridge
import time
ServoName   =  2
Frequency   =  50
Angle1      =  20
Angle2      =  160
 
if __name__=="__main__":
    motor = MotorBridge.MotorBridgeCape()
    motor.ServoInit(ServoName,Frequency)
 
    while True:
        print 'Servo Test'
        motor.ServoMoveAngle(ServoName,Angle1)
        time.sleep(2)
        motor.ServoMoveAngle(ServoName,Angle2)
        time.sleep(2)

Upgrade the Firmware

If there's something wrong with your cape, try to upgrade it. In this section, I will show you how to upgrade the Motor Bridge Cape Firmware using BeagleBone Green, it also works on BBGW and BBB.

1. Insert the Motor Bridge Cape to BBG/BBGW/BBB, and connect BBG to your computer via USB cable.

2. Let your BBG connect to the internet, and access it via SSH as the picture below shows.

3. Download the code from Github by execute following commands

git clone https://github.com/Seeed-Studio/MotorBridgeCapeFirmware

4. Navigate to "MotorBridgeCapeFirmware" and execute "make flash" command to flash the firmware.

cd MotorBridgeCapeFirmware/ && make flash

After a few seconds, you can see "Verification OK" information from the terminal

5. Check if the firmware is flash well by execute following command

i2cdetect -y -r 1

If you find the I2C address 0x4b,it means you have already refreshed the firmware successfully.

Known issues

Can't find the I2C address

Q: I have already update the firmware, but can't detect the i2c address?

A:Be sure that the P9_23 Pin is High, since the P9_23 is connect to Reset pin of STM32, I set the P9_23 pin to high level in the initialization function of MotorBridgeCape class.

Can't Update the firmware

Q: When I update the firmware, the error information says that can't find the UART2?

A: You should enable the BB-UART2, since the BBG flash the firmware to Motor Bridge Cape by UART2..

vi /boot/uEnv.txt

Then uncomment "cape_enable=capemgr.enable_partno=BB-UART2". Save and exit the editor, at last reboot your board.

The Cape still can't working

Q: I have already update the firmware successfully and can detect the I2C address, but why I still can't get the cape working?

A: Please mention that there's a working mode switch on the board, be sure the switch is turn to working. If you still have other questions, please come to our forum.

Resources

Copyright (c) 2008-2016 Seeed Development Limited (www.seeedstudio.com / www.seeed.cc)
This static html page was created from http://www.seeedstudio.com/wiki