Simple DC motor control commands for driving DC motor conroller with PWM and up to 2 direction signals (complementary). Takes float value from -1.0 to 1.0.
Dependents: Teensy_Mot_QEI_Ser_20180111 Axis Axis_20181108 Axis_version2
Fork of MotCon by
Overloaded class that takes a pwm motor control pin and one or two direction pins for driving DC motors with a variety of motor control IC's. Tested examples include the LM298, TD340, MC33926, A3949.
MotCon.h@4:10187d108666, 2016-05-23 (annotated)
- Committer:
- jebradshaw
- Date:
- Mon May 23 19:06:31 2016 +0000
- Revision:
- 4:10187d108666
- Parent:
- 0:3ba12980833b
- Child:
- 2:23cd902e1774
- Child:
- 5:3e07f69d8abd
Simple motor control library for generating PWM and a direction signal for a motor driver board
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jebradshaw | 0:3ba12980833b | 1 | |
jebradshaw | 0:3ba12980833b | 2 | #include "mbed.h" |
jebradshaw | 0:3ba12980833b | 3 | |
jebradshaw | 0:3ba12980833b | 4 | #ifndef MBED_MOTCON_H |
jebradshaw | 0:3ba12980833b | 5 | #define MBED_MOTCON_H |
jebradshaw | 0:3ba12980833b | 6 | |
jebradshaw | 0:3ba12980833b | 7 | class MotCon{ |
jebradshaw | 0:3ba12980833b | 8 | public: |
jebradshaw | 0:3ba12980833b | 9 | MotCon(PinName _pwm, PinName _dir); |
jebradshaw | 0:3ba12980833b | 10 | void mot_control(float dc); |
jebradshaw | 4:10187d108666 | 11 | void mot_control(float dc, int invert); |
jebradshaw | 0:3ba12980833b | 12 | private: |
jebradshaw | 0:3ba12980833b | 13 | PwmOut _pwm; |
jebradshaw | 0:3ba12980833b | 14 | DigitalOut _dir; |
jebradshaw | 0:3ba12980833b | 15 | }; |
jebradshaw | 0:3ba12980833b | 16 | |
jebradshaw | 0:3ba12980833b | 17 | #endif |