A simple motor driver for the MC33926 chip, commonly found on the Polulu md11a breakout https://www.pololu.com/product/1213.
MC33926.h@0:3163bb06484b, 2017-04-30 (annotated)
- Committer:
- sk398
- Date:
- Sun Apr 30 16:14:35 2017 +0000
- Revision:
- 0:3163bb06484b
Library for driving the MC33926 Motor Driver chip which is commonly found on the Polulu md11a, with two MC33926 drivers https://www.pololu.com/product/1213
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sk398 | 0:3163bb06484b | 1 | /******************************************************************************************** |
sk398 | 0:3163bb06484b | 2 | |
sk398 | 0:3163bb06484b | 3 | Filename: MC33926.h |
sk398 | 0:3163bb06484b | 4 | |
sk398 | 0:3163bb06484b | 5 | Original Author: Steven Kay |
sk398 | 0:3163bb06484b | 6 | |
sk398 | 0:3163bb06484b | 7 | Development Group: Steve!! |
sk398 | 0:3163bb06484b | 8 | |
sk398 | 0:3163bb06484b | 9 | Original Creation Date: April 2017 |
sk398 | 0:3163bb06484b | 10 | |
sk398 | 0:3163bb06484b | 11 | Description: <Desc> |
sk398 | 0:3163bb06484b | 12 | |
sk398 | 0:3163bb06484b | 13 | Revision History: Version 1.0 - Initial Release |
sk398 | 0:3163bb06484b | 14 | |
sk398 | 0:3163bb06484b | 15 | *********************************************************************************************/ |
sk398 | 0:3163bb06484b | 16 | |
sk398 | 0:3163bb06484b | 17 | #ifndef MC33926_H |
sk398 | 0:3163bb06484b | 18 | #define MC33926_H |
sk398 | 0:3163bb06484b | 19 | |
sk398 | 0:3163bb06484b | 20 | |
sk398 | 0:3163bb06484b | 21 | #include "mbed.h" |
sk398 | 0:3163bb06484b | 22 | |
sk398 | 0:3163bb06484b | 23 | |
sk398 | 0:3163bb06484b | 24 | #define DRIVER_PWM_PERIOD 2 |
sk398 | 0:3163bb06484b | 25 | |
sk398 | 0:3163bb06484b | 26 | |
sk398 | 0:3163bb06484b | 27 | #define RESET 2 |
sk398 | 0:3163bb06484b | 28 | #define FORWARD 1 |
sk398 | 0:3163bb06484b | 29 | #define REVERSE 0 |
sk398 | 0:3163bb06484b | 30 | |
sk398 | 0:3163bb06484b | 31 | |
sk398 | 0:3163bb06484b | 32 | class MC33926 |
sk398 | 0:3163bb06484b | 33 | { |
sk398 | 0:3163bb06484b | 34 | |
sk398 | 0:3163bb06484b | 35 | public: |
sk398 | 0:3163bb06484b | 36 | |
sk398 | 0:3163bb06484b | 37 | MC33926(PinName pinIN1, PinName pinIN2, PinName pinFB, PinName pinSF); |
sk398 | 0:3163bb06484b | 38 | |
sk398 | 0:3163bb06484b | 39 | |
sk398 | 0:3163bb06484b | 40 | void SetPWMPulsewidth(int direction, float PWM_Pulsewidth); |
sk398 | 0:3163bb06484b | 41 | |
sk398 | 0:3163bb06484b | 42 | float ReadCurrentFeedback(); |
sk398 | 0:3163bb06484b | 43 | |
sk398 | 0:3163bb06484b | 44 | // Implemented on v2.0 |
sk398 | 0:3163bb06484b | 45 | // void StatusFlagWatch(bool latchPol); |
sk398 | 0:3163bb06484b | 46 | // bool GetStatus(); |
sk398 | 0:3163bb06484b | 47 | // void ResetStatus(); |
sk398 | 0:3163bb06484b | 48 | |
sk398 | 0:3163bb06484b | 49 | protected: |
sk398 | 0:3163bb06484b | 50 | |
sk398 | 0:3163bb06484b | 51 | PwmOut *_pinIN1; |
sk398 | 0:3163bb06484b | 52 | PwmOut *_pinIN2; |
sk398 | 0:3163bb06484b | 53 | AnalogIn *_pinFB; |
sk398 | 0:3163bb06484b | 54 | InterruptIn *_pinSF; |
sk398 | 0:3163bb06484b | 55 | |
sk398 | 0:3163bb06484b | 56 | volatile bool statusFlag; |
sk398 | 0:3163bb06484b | 57 | |
sk398 | 0:3163bb06484b | 58 | |
sk398 | 0:3163bb06484b | 59 | void StatusFlagISR(); |
sk398 | 0:3163bb06484b | 60 | |
sk398 | 0:3163bb06484b | 61 | |
sk398 | 0:3163bb06484b | 62 | }; |
sk398 | 0:3163bb06484b | 63 | |
sk398 | 0:3163bb06484b | 64 | #endif |