bbekec / dual-mc33926-motor-shield

Arduino library for the Pololu Dual MC33926 Motor Driver Shield

Home Page:http://www.pololu.com/product/2503

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arduino library for the Pololu Dual MC33926 Motor Driver Shield

Version: 1.0.0
Release Date: 2012-06-07
www.pololu.com

Summary

This is a library for the Arduino that interfaces with the Pololu Dual MC33926 Motor Driver Shield. It makes it simple to drive two brushed, DC motors.

Getting Started

Software

Download the archive from GitHub, decompress it, and drag the “DualMC33926MotorShield” folder to your arduino-xx/libraries directory. Then restart the Arduino environment, so the libraries can be updated to include the library and its examples.

Hardware

The Dual MC33926 Motor Driver Shield can be purchased on Pololu’s website. See the motor shield user’s guide for more details.

Example Program

Demo

Open this example code sketch by selecting File→Examples→DualMC33926MotorShield→Demo.

The demo ramps motor 1 from stopped to full speed forward, ramps down to full speed reverse, and back to stopped. Then, it does the same with the other motor. Both motor’s current readings are sent over serial and can be seen with the serial monitor. If a fault is detected, a message is sent over serial.

Library Reference

DualMC33926MotorShield()
Default constructor, selects the default pins as connected by the motor shield.
DualMC33926MotorShield(unsigned char M1DIR, unsigned char M1PWM, unsigned char M1FB,
unsigned char M2DIR, unsigned char M2PWM, unsigned char M2FB, unsigned char nD2, unsigned char nSF)
Alternate constructor for shield connections remapped by user. M1PWM and M2PWM cannot be remapped because the library assumes PWM is on timer1.
void init()
Initialize pinModes and timer1.
void setM1Speed(int speed)
Set speed and direction for motor 1. Speed should be between -400 and 400. 400 corresponds to motor current flowing from M1A to M1B. -400 corresponds to motor current flowing from M1B to M1A.
void setM2Speed(int speed)
Set speed and direction for motor 2. Speed should be between -400 and 400. 400 corresponds to motor current flowing from M2A to M2B. -400 corresponds to motor current flowing from M2B to M2A.
void setSpeeds(int m1Speed, int m2Speed)
Set speed and direction for motor 1 and 2.
unsigned int getM1CurrentMilliamps()
Returns current reading from motor 1 in milliamps.
unsigned int getM2CurrentMilliamps()
Returns current reading from motor 2 in milliamps.
unsigned char getFault()
Returns 1 if there is a motor driver fault, 0 if no fault.

Version History

  • 1.0.0 (2012-06-07): Original release.

About

Arduino library for the Pololu Dual MC33926 Motor Driver Shield

http://www.pololu.com/product/2503

License:Other


Languages

Language:C++ 74.0%Language:Arduino 26.0%