npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

motor-driver-tb6612

v0.0.1

Published

A motor driver library for the TB6612FNG breakout

Downloads

3

Readme

motor-driver-tb6612

A JavaScript Driver for the TB6612FNG motor driver from Sparkfun. Use this chip to drive one or two motors from your microcontroller.

If you're looking for a fun project, I recommend integrating this motor driver with this motor powered car kit.

Breakout Image

Installation

npm install motor-driver-tb6612

Hardware Connections

The hardware hook up for this module is a little more complicated than usual because it needs to use 5 different GPIOs and 2 PWM pins. Tessel's GPIO bank offers 3 PWM (which can also act as GPIO) and 3 GPIO pins so you'll need to add one more GPIO from another module.

I followed the wiring tutorial I found on this instructable.

Motor Driver | Tessel 

PWMA <-> GPIO Port G4

AIN2 <-> GPIO Port G1

AIN1 <-> GPIO Port G2

STBY <-> GPIO Port G4

BIN1 <-> ANY OTHER GPIO (I use Port D, GPIO 1 in my examples) 

BIN2 <-> GPIO Port G6

PWMB <-> GPIO Port G5

GND <-> Not Connected (you could connect to GND if you want)

VM <-> The Motor Power Source (you must power motors with heavy duty power (like 4 AA's)

VCC <-> Tessel 3V3

GND <-> Tessel GND

A01 <-> Motor 1 Postive Terminal

A02 <-> Motor 1 Negative Terminal

B01 <-> Motor 2 Positive Terminal

B02 <-> Motor 2 Negative Terminal

GND <-> Not Connected 

Note: You should probably use throughhole diodes (as explained in the Instructable I posted above) on between the motor driver output and the motor. This protects the chip from back EMF.

Example

var tessel = require('tessel');
var port = tessel.port['GPIO'];
var driverLib = require('../');
var md = driverLib.use(port, tessel.port['D'].digital[0]);

var speed = 0;
var direction = 0;

setInterval(function() {

  md.drive(0, direction, speed);
  md.drive(1, !direction, speed);

  if (speed >= 1.00) {
    direction = !direction;
    speed = 0;
  }
  else {
    speed += 0.10;
  }
}, 250);

API

####Commands

library.use(gpioPort, otherGPIOPin, callback) initializes the module and returns a MotorDriver object. The GPIO bank must be the first argument and any other GPIO pin can be the second callback. The extra GPIO pin must be

MotorDriver.drive(motorIndex, direction, speed) turns the motor at motorIndex (either 0 or 1) in direction (0 for forward, 1 for backward), at rate speed where speed is a float between 0 and 1.

####Events

ready thrown after the module initializes.

drive thrown when a motor is being driven. Arguments are (motorIndex, direction, speed).

Examples

In the /examples directory, there are two main examples:

  • motor.js which is the same as the example above and shows how to drive to motors forward and at increasing speed, then backwards at increasing speed.
  • /robo-car has two files. robo-car.js is code that can run on a Tessel connected to a remote control car to open up a TCP server. When it receives WASD commands, it moves in the corresponding direction. remote-control.js is a Node.js script that when run, will accept keypress in the command line and send it to the car. NOTE: You'll need to change the IP Address to the IP Address of your Tessel.