The 'BD65496MUV' Library
BD65496MUV.h
Go to the documentation of this file.
1 
14 #ifndef BD65496MUV_h
15 #define BD65496MUV_h
16 
18 // includes //
20 #include <inttypes.h>
21 #include <Arduino.h>
22 
23 
25 // defines //
27 
28 
30 // classes //
32 
37 class BD65496MUV {
38 // Begin PUBLIC ------------------------------------------------------------------
39  public:
40 
41  // enums
42  enum DriverMode {Speed_n_Dir, H_Bridge};
43  enum PowerMode {Running, Standby};
44  enum SwitchingSpeed {On150_Off50, On250_Off70, On350_Off90, On500_Off110};
45  enum ShortBreakMode {On, Off};
46 
47  // constructors
48  BD65496MUV(uint8_t pinInA, uint8_t pinInB, uint8_t pinPwmMode ,DriverMode driverMode = DriverMode::Speed_n_Dir); // Constructor of the BD65496MUV class with the pwm mode pin.
49  BD65496MUV(uint8_t pinInA, uint8_t pinInB, DriverMode driverMode = DriverMode::Speed_n_Dir, // Constructor of the BD65496MUV class with all pins (Pro-Mode).
50  bool pinPwmModeDefined = false, uint8_t pinPwmMode = 0,
51  bool pinPsDefined = false, uint8_t pinPs = 0, PowerMode powerMode = PowerMode::Running,
52  bool pinTrDefined = false, uint8_t pinTr1 = 0, uint8_t pinTr2 = 0,
53  SwitchingSpeed switchingSpeed = SwitchingSpeed::On150_Off50,
54  ShortBreakMode shortBreakMode = ShortBreakMode::Off);
55 
56  // functions
57  void setSpeed(int16_t speed); // Set the speed of the motor.
58  int16_t getSpeed(); // Get the speed of the moter.
59 
60  void setDriverMode(DriverMode driverMode); // Set the driver mode of the driver.
61  DriverMode getDriverMode(); // Get the dirver mdoe of the driver.
62 
63  void setPowerMode(PowerMode powerMode); // Set the power mode of the driver.
64  PowerMode getPowerMode(); // Get the power mode of the driver.
65 
66  void setSwitchingSpeed(SwitchingSpeed switchingSpeed); // Set the switching speed of the driver.
67  SwitchingSpeed getSwitchingSpeed(); // Get the switching speed of the driver.
68 
69  void setShortBreakMode(ShortBreakMode shortBreakMode); // Set the short break mode of the driver.
70  ShortBreakMode getShortBreakMode(); // Get the short break mode of the dirver.
71 
72  uint16_t getVersion(); // Get the version of the library.
73 
74 // End PUBLIC --------------------------------------------------------------------
75 
76 // Begin PRIVATE -----------------------------------------------------------------
77  private:
78 
79  // enum
80  enum TurnDir {CW, CCW}; // Enum that represents the turn direction of the motor.
81 
82  // variables
83  DriverMode _driverMode; // Var for the driver mode.
84  PowerMode _powerMode; // Var for the power mode.
85  SwitchingSpeed _switchingSpeed; // Var for the switching speed.
86  ShortBreakMode _shortBreakMode; // Var fot the short break mode.
87 
88  bool _pinPwmModeDefined; // Flag if the pwm mode pin is defined.
89  bool _pinPsDefined; // Flag if the ps pin is defined.
90  bool _pinTrDefined; // Flag if the tr pins are defined.
91 
92  uint8_t _pinInA; // Var for the number of the INA pin.
93  uint8_t _pinInB; // Var for the number of the INB pin.
94  uint8_t _pinPwmMode; // Var for the number of the pwm mode pin.
95  uint8_t _pinPs; // Var for the number of the PS pin.
96  uint8_t _pinTr1; // Var for the number of the TR1 pin.
97  uint8_t _pinTr2; // Var for the number of the TR2 pin.
98 
99  int16_t _speed; // Var for the current motor speed.
100 
101  // functions
102  void _initDriverPins(); // Function to initialize the output pins.
103 
104 // End PRIVATE -------------------------------------------------------------------
105 };
106 
107 #endif
BD65496MUV::setDriverMode
void setDriverMode(DriverMode driverMode)
Set the driver mode of the driver.
Definition: BD65496MUV.cpp:223
BD65496MUV::BD65496MUV
BD65496MUV(uint8_t pinInA, uint8_t pinInB, uint8_t pinPwmMode, DriverMode driverMode=DriverMode::Speed_n_Dir)
Constructor of the BD65496MUV class with the pwm mode pin.
Definition: BD65496MUV.cpp:64
BD65496MUV::getPowerMode
PowerMode getPowerMode()
Get the power mode of the driver.
Definition: BD65496MUV.cpp:268
BD65496MUV::getSpeed
int16_t getSpeed()
Get the speed of the moter.
Definition: BD65496MUV.cpp:214
BD65496MUV::setPowerMode
void setPowerMode(PowerMode powerMode)
Set the power mode of the driver.
Definition: BD65496MUV.cpp:250
BD65496MUV::getDriverMode
DriverMode getDriverMode()
Get the dirver mdoe of the driver.
Definition: BD65496MUV.cpp:241
BD65496MUV::setSpeed
void setSpeed(int16_t speed)
Set the speed of the motor.
Definition: BD65496MUV.cpp:140
BD65496MUV::getSwitchingSpeed
SwitchingSpeed getSwitchingSpeed()
Get the switching speed of the driver.
Definition: BD65496MUV.cpp:316
BD65496MUV::setShortBreakMode
void setShortBreakMode(ShortBreakMode shortBreakMode)
Set the short break mode of the driver.
Definition: BD65496MUV.cpp:325
BD65496MUV::getVersion
uint16_t getVersion()
Get the version of the library.
Definition: BD65496MUV.cpp:343
BD65496MUV::getShortBreakMode
ShortBreakMode getShortBreakMode()
Get the short break mode of the dirver.
Definition: BD65496MUV.cpp:334
BD65496MUV::setSwitchingSpeed
void setSwitchingSpeed(SwitchingSpeed switchingSpeed)
Set the switching speed of the driver.
Definition: BD65496MUV.cpp:277
BD65496MUV
The main class of the Arduino library for the BD65496MUV Single Brushed DC Motor Driver.
Definition: BD65496MUV.h:37