Page 1 of 7
SparkFun Blocks for Intel® Edison - Dual
H-Bridge
Introduction
SparkFun’s H-Bridge Block for Edison adds a two-channel low-voltage lowcurrent h-bridge (the Toshiba TB6612) to your stack. The block can be
configured to draw power either from the VSYS supply of the stack or from
an external supply connected to the header on the block.
Dual H-Bridge Block
Suggested Reading
If you are unfamiliar with Blocks, take a look at the General Guide to
Sparkfun Blocks for Intel Edison.
Other tutorials that may help you on your Edison adventure include:
• Programming the Edison - This tutorial assumes you are not using
the Arduino IDE, so you’ll want to familiarize yourself with C++
development on the Edison.
• Powering Your Project
• Connector Basics
• PWM
Board Overview
Page 2 of 7
Dual H-Bridge Block Functional Diagram
• Motor Outputs - Two DC motor outputs. Motor A and B
• Motor Power Input - External power input for DC motors. Limit to 15v
DC.
• VSYS -> VIN - Close this jumper to power Motors off VSYS. Use
caution to not overdraw power supply capabilities.
• Expansion Header - The 70-pin Expansion header breaks out the
functionality of the Intel Edison. This header also passes signals and
power throughout the stack. These function much like an Arduino
Shield.
Using the Dual H-Bridge Block
To use the Dual H-Bridge Block simply attach an Intel Edison to the back of
the board or add it to your current stack. Blocks can be stacked without
hardware but it leaves the expansion connectors unprotected from
mechanical stress.
Dual H-Bridge Block Installed
We have a nice Hardware Pack available that gives enough hardware to
secure three blocks and an Edison.
Page 3 of 7
Intel Edison Hardware Pack
NOTE: The Dual H-Bridge Block does not have console access or a voltage
regulator. It is recommended to use a console communication block in
conjunction with this block like ones found in the General Guide to Sparkfun
Blocks for Intel Edison.
C++ Code Example
We’re assuming that you’re using the Eclipse IDE as detailed in our Beyond
Arduino tutorial. If you aren’t, you’ll need to go to that tutorial to get up to
speed.
Getting Started
Follow the instructions in the programming tutorial to create a new project
named “SparkFun_H-Bridge_Edison_Block_Example”. Once you’ve
created the project, open the project files on disk (hint: you can find the
path to the project by choosing “Properites” from the project menu), and
copy the three source files found in the Edison H-Bridge Block CPP library
GitHub repository into the “src” directory.
D O W N L O A D A ZI P FIL E O F T H E RE P O S I T O R Y
Hardware Connection
For this example, we have two small DC motors with gearboxes attached to
the outputs. The image below shows how to build the circuit. It’s up to you
whether you want to drive the motors with an external supply. I’ve shown
one here, but I’ve had perfectly good luck closing the supply jumper and
pulling the current for these motors directly from the stack’s VSYS rail, even
when powering it over USB.
Code
Page 4 of 7
Everything you need to know is in the comments.
Page 5 of 7
#include
#include "mraa.h"
#include "SparkFun_TB6612_Edison.h"
#include
#include
using namespace std;
int main()
{
// The constructor for the tb6612 class object configures al
l the necessary
// pins, exporting them if they aren't already exported, et
c. Note that only
// one tb6612 class object may exist at a time, as they sha
re hardware
// resources!
tb6612 motors;
// The constructor disables the outputs of the tb6612 by ass
erting the standby
// pin on the controller. You *must* use the standby() func
tion to enable
// them before proceeding!
motors.standby(false);
// diffDrive() accepts a floating point number for channel
A and channel B, in
// the range 1.0 to 1.0 inclusive.
motors.diffDrive(0.5,0.5);
sleep(5);
motors.diffDrive(0.5,0.5);
sleep(5);
// "short brake" literally means the two outputs are shorte
d together. This
// drags the motor to a halt in a very short time and then
holds it still
// (albeit fairly weakly). The shortBrake() function does
n't change the
// PWM output settings, so when shortBrake() is released b
y sending a "false"
// parameter, the motor will immediately resume its previou
s speed.
motors.shortBrake(true, true);
// Return the motors to hiz state. This also doesn't affec
t the PWM output,
// so when standby is released (by passing false to this fu
nction) the motors
// will immediately resume their former speeds. This also d
oesn't provide any
// braking, so the motors will coast to a stop much more sl
owly than with
// shortBrake().
motors.standby(true);
bool brakeA = false;
bool brakeB = false;
float dcA = 0;
float dcB = 0;
bool onStandby = false;
Page 6 of 7
// We've provided a number of "get" functions, to check the
current status of
// the device.
// getStandby() returns true if the motors are on standby, f
alse otherwise.
// This function checks the actual status of the gpio pin u
sed for setting
// the standby mode on the chip, so it will always match re
ality.
onStandby = motors.getStandby();
// getDiffDrive() checks the *stored* speed value, rather th
an the current
// value. Thus, if another process alters the PWM output du
ty cycle without
// actually touching the class object, this may return inva
lid data. It also
// doesn't return any information about standby or brake st
atus.
motors.getDiffDrive(&dcA, &dcB);
// getShortBrake() checks the pins used for setting the dire
ction/brake mode,
// so the values placed into the pointer parameters by the
function are
// accurate at the time the function is called.
motors.getShortBrake(&brakeA, &brakeB);
cout
很抱歉,暂时无法提供与“DEV-13043”相匹配的价格&库存,您可以联系我们找货
免费人工找货