Brushless motor control program with L293D.
Dependencies: brushlessController_L293D mbed
main.cpp@2:073c5513e2de, 2015-07-16 (annotated)
- Committer:
- BaserK
- Date:
- Thu Jul 16 15:18:06 2015 +0000
- Revision:
- 2:073c5513e2de
- Parent:
- 1:46f06c96c5f0
- Child:
- 5:c1f954e2f00a
Brushless motor control program with L293D
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BaserK | 2:073c5513e2de | 1 | /* Controlling a brushless motor with 2X L293D |
BaserK | 2:073c5513e2de | 2 | * |
BaserK | 2:073c5513e2de | 3 | * @author: Baser Kandehir |
BaserK | 2:073c5513e2de | 4 | * @date: July 16, 2015 |
BaserK | 2:073c5513e2de | 5 | * @license: Use this code however you'd like |
BaserK | 2:073c5513e2de | 6 | * |
BaserK | 2:073c5513e2de | 7 | * @description of the program: |
BaserK | 2:073c5513e2de | 8 | |
BaserK | 2:073c5513e2de | 9 | * Brushless motor control program with L293D. |
BaserK | 2:073c5513e2de | 10 | * L293D is a simple, cheap standard DC motor driver and can be found easily. |
BaserK | 2:073c5513e2de | 11 | * But I should say that controlling brushless motors with L293D is not efficient |
BaserK | 2:073c5513e2de | 12 | * and precise. Proper way to control brushless motor is using an ESC or drivers |
BaserK | 2:073c5513e2de | 13 | * like L6235. For the time being I have none of them, but I had a brushless motor that |
BaserK | 2:073c5513e2de | 14 | * I wanted to control and see how it works. If you want to do the same, that program |
BaserK | 2:073c5513e2de | 15 | * is for you. |
BaserK | 2:073c5513e2de | 16 | * |
BaserK | 2:073c5513e2de | 17 | * This guy did a great job by explaining how it is done: |
BaserK | 2:073c5513e2de | 18 | * http://www.instructables.com/id/Arduino-CDROM-BLDC-Motor-Driver-Enhanced-Performan/ |
BaserK | 2:073c5513e2de | 19 | * |
BaserK | 2:073c5513e2de | 20 | * Note: For any mistakes or comments, please contact me. |
BaserK | 2:073c5513e2de | 21 | */ |
BaserK | 2:073c5513e2de | 22 | |
BaserK | 0:06434e97c4f2 | 23 | #include "mbed.h" |
BaserK | 1:46f06c96c5f0 | 24 | #include "brushlessController_L293D.h" |
BaserK | 0:06434e97c4f2 | 25 | |
BaserK | 2:073c5513e2de | 26 | int prevStep = 0; |
BaserK | 2:073c5513e2de | 27 | |
BaserK | 0:06434e97c4f2 | 28 | int main() |
BaserK | 0:06434e97c4f2 | 29 | { |
BaserK | 1:46f06c96c5f0 | 30 | /* Example: After nine steps it will stop */ |
BaserK | 2:073c5513e2de | 31 | //brushlessControl(1, 500, 9); |
BaserK | 2:073c5513e2de | 32 | |
BaserK | 0:06434e97c4f2 | 33 | while(1) |
BaserK | 2:073c5513e2de | 34 | { |
BaserK | 2:073c5513e2de | 35 | oneStep(0, 500, &prevStep); // One step forward wait 500ms |
BaserK | 2:073c5513e2de | 36 | oneStep(1, 500, &prevStep); // One step backward wait 500ms |
BaserK | 2:073c5513e2de | 37 | |
BaserK | 2:073c5513e2de | 38 | /* 500 ms delay time is just for testing, you should reduce the delay time for better movement */ |
BaserK | 0:06434e97c4f2 | 39 | } |
BaserK | 0:06434e97c4f2 | 40 | } |