00001 #ifndef DualMC33926_h 00002 #define DualMC33926_h 00003 00004 #include <Arduino.h> 00005 00006 //#ifdef __SAM3X8E__ //DUE 00007 // #undef PWM_FREQUENCY 00008 //#define PWM_FREQUENCY 20000 //20khz 00009 //#endif 00010 class DualMC33926 00011 { 00012 public: 00013 // CONSTRUCTORS 00014 DualMC33926(); // Default pin selection. 00015 DualMC33926(unsigned char M1DIR, unsigned char M1PWM, unsigned char M1FB, 00016 unsigned char M2DIR, unsigned char M2PWM, unsigned char M2FB, 00017 unsigned char nD2, unsigned char nSF); // User-defined pin selection. 00018 00019 // PUBLIC METHODS 00020 void init(); // Initialize TIMER 1, set the PWM to 20kHZ. 00021 void restart(); 00022 void setTorque(bool t); 00023 unsigned char getTorque(); 00024 void setM1Speed(int speed); // Set speed for M1. 00025 void setM2Speed(int speed); // Set speed for M2. 00026 void setSpeeds(int m1Speed, int m2Speed); // Set speed for both M1 and M2. 00027 float getM1CurrentMilliamps(); // Get current reading for M1. 00028 float getM2CurrentMilliamps(); // Get current reading for M2. 00029 unsigned char getFault(); // Get fault reading. 00030 00031 private: 00032 unsigned char _nD2; 00033 unsigned char _M1DIR; 00034 unsigned char _M2DIR; 00035 unsigned char _M1PWM; 00036 unsigned char _M2PWM; 00037 unsigned char _nSF; 00038 unsigned char _M1FB; 00039 unsigned char _M2FB; 00040 }; 00041 00042 #endif