Basic Library for Pololu DRV8835

Dependents:   ME503_VehicleAssembly

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DRV8835.h Source File

DRV8835.h

00001 /* File: DRV8835.h
00002  * Adopted from work by Cameron Isbell
00003  *
00004  * Description: library for DRV8835 Motor Driver
00005  * Assumptions: A is left and B is right
00006  */
00007 #ifndef __DRV8835_H__
00008 #define __DRV8835_H__
00009 
00010 #include "mbed.h"
00011 
00012 #define DRV8835_PWM_PERIOD_DEFAULT      (0.002)   // 2 ms period                      // 50KHz (0.00002)
00013 #define DRV8835_PWM_PULSEWIDTH_DEFAULT  (0.50)      // 50% duty cycle
00014  
00015 class DRV8835
00016 {
00017 public:
00018     DRV8835( PinName pinPwmL, PinName pinLin,
00019                PinName pinPwmR, PinName pinRin);
00020 
00021     void motorL_stop(void);
00022     void motorL_fwd(float fPulsewidth);
00023     void motorL_rev(float fPulsewidth);
00024     void motorR_stop(void);
00025     void motorR_fwd(float fPulsewidth);
00026     void motorR_rev(float fPulsewidth);
00027     void setSpeeds(float Right,float Left);
00028     void stop(void);
00029     
00030 private:
00031     PwmOut pwmL;
00032     DigitalOut Lin;
00033     PwmOut pwmR;
00034     DigitalOut Rin;
00035 };
00036 
00037 #endif /* __DRV8835_H__ */