VNH5019 motor driver library
vnh5019.h@0:666c49565378, 2022-02-03 (annotated)
- Committer:
- LVRhase01
- Date:
- Thu Feb 03 08:30:44 2022 +0000
- Revision:
- 0:666c49565378
first create vnh5019 library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LVRhase01 | 0:666c49565378 | 1 | #ifndef VNH5019_H |
LVRhase01 | 0:666c49565378 | 2 | #define VNH5019_H |
LVRhase01 | 0:666c49565378 | 3 | |
LVRhase01 | 0:666c49565378 | 4 | #include "mbed.h" |
LVRhase01 | 0:666c49565378 | 5 | /** |
LVRhase01 | 0:666c49565378 | 6 | * vnh5019 class |
LVRhase01 | 0:666c49565378 | 7 | * class to drive vnh5019 |
LVRhase01 | 0:666c49565378 | 8 | */ |
LVRhase01 | 0:666c49565378 | 9 | class VNH5019 |
LVRhase01 | 0:666c49565378 | 10 | { |
LVRhase01 | 0:666c49565378 | 11 | public: |
LVRhase01 | 0:666c49565378 | 12 | /** creates VNH5019 instance |
LVRhase01 | 0:666c49565378 | 13 | *@param _dirH dirH pin |
LVRhase01 | 0:666c49565378 | 14 | *@param _dirL dirL pin |
LVRhase01 | 0:666c49565378 | 15 | *@param _pwm pwm pin |
LVRhase01 | 0:666c49565378 | 16 | */ |
LVRhase01 | 0:666c49565378 | 17 | VNH5019(PinName _dirH,PinName _dirL,PinName _pwm); |
LVRhase01 | 0:666c49565378 | 18 | /** set drive Mode won't work after setMotorSpeed() is called |
LVRhase01 | 0:666c49565378 | 19 | */ |
LVRhase01 | 0:666c49565378 | 20 | int setMotorSpeed(float speed); |
LVRhase01 | 0:666c49565378 | 21 | /** set pwm frequency |
LVRhase01 | 0:666c49565378 | 22 | *@param frequency needs to be bigger than 0 |
LVRhase01 | 0:666c49565378 | 23 | */ |
LVRhase01 | 0:666c49565378 | 24 | int setFreq(float freq); |
LVRhase01 | 0:666c49565378 | 25 | /** set this variable to 1 if you want to brake when the motorSpeed is set to 0 |
LVRhase01 | 0:666c49565378 | 26 | */ |
LVRhase01 | 0:666c49565378 | 27 | bool braking; |
LVRhase01 | 0:666c49565378 | 28 | private: |
LVRhase01 | 0:666c49565378 | 29 | bool started; |
LVRhase01 | 0:666c49565378 | 30 | DigitalOut dirH,dirL; |
LVRhase01 | 0:666c49565378 | 31 | PwmOut pwm; |
LVRhase01 | 0:666c49565378 | 32 | }; |
LVRhase01 | 0:666c49565378 | 33 | #endif |