Brushless motor control program with L293D.

Dependencies:   brushlessController_L293D mbed

Committer:
BaserK
Date:
Tue Jul 21 07:57:46 2015 +0000
Revision:
5:c1f954e2f00a
Parent:
2:073c5513e2de
MIT license is added

Who changed what in which revision?

UserRevisionLine numberNew 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 5:c1f954e2f00a 5 * @license: MIT license
BaserK 5:c1f954e2f00a 6 *
BaserK 5:c1f954e2f00a 7 * Copyright (c) 2015, Baser Kandehir, baser.kandehir@ieee.metu.edu.tr
BaserK 5:c1f954e2f00a 8 *
BaserK 5:c1f954e2f00a 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
BaserK 5:c1f954e2f00a 10 * of this software and associated documentation files (the "Software"), to deal
BaserK 5:c1f954e2f00a 11 * in the Software without restriction, including without limitation the rights
BaserK 5:c1f954e2f00a 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
BaserK 5:c1f954e2f00a 13 * copies of the Software, and to permit persons to whom the Software is
BaserK 5:c1f954e2f00a 14 * furnished to do so, subject to the following conditions:
BaserK 5:c1f954e2f00a 15 *
BaserK 5:c1f954e2f00a 16 * The above copyright notice and this permission notice shall be included in
BaserK 5:c1f954e2f00a 17 * all copies or substantial portions of the Software.
BaserK 5:c1f954e2f00a 18 *
BaserK 5:c1f954e2f00a 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
BaserK 5:c1f954e2f00a 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
BaserK 5:c1f954e2f00a 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
BaserK 5:c1f954e2f00a 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
BaserK 5:c1f954e2f00a 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
BaserK 5:c1f954e2f00a 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
BaserK 5:c1f954e2f00a 25 * THE SOFTWARE.
BaserK 5:c1f954e2f00a 26 *
BaserK 2:073c5513e2de 27 * @description of the program:
BaserK 5:c1f954e2f00a 28 *
BaserK 2:073c5513e2de 29 * Brushless motor control program with L293D.
BaserK 2:073c5513e2de 30 * L293D is a simple, cheap standard DC motor driver and can be found easily.
BaserK 2:073c5513e2de 31 * But I should say that controlling brushless motors with L293D is not efficient
BaserK 2:073c5513e2de 32 * and precise. Proper way to control brushless motor is using an ESC or drivers
BaserK 2:073c5513e2de 33 * like L6235. For the time being I have none of them, but I had a brushless motor that
BaserK 2:073c5513e2de 34 * I wanted to control and see how it works. If you want to do the same, that program
BaserK 2:073c5513e2de 35 * is for you.
BaserK 2:073c5513e2de 36 *
BaserK 2:073c5513e2de 37 * This guy did a great job by explaining how it is done:
BaserK 2:073c5513e2de 38 * http://www.instructables.com/id/Arduino-CDROM-BLDC-Motor-Driver-Enhanced-Performan/
BaserK 2:073c5513e2de 39 *
BaserK 2:073c5513e2de 40 * Note: For any mistakes or comments, please contact me.
BaserK 2:073c5513e2de 41 */
BaserK 2:073c5513e2de 42
BaserK 0:06434e97c4f2 43 #include "mbed.h"
BaserK 1:46f06c96c5f0 44 #include "brushlessController_L293D.h"
BaserK 0:06434e97c4f2 45
BaserK 2:073c5513e2de 46 int prevStep = 0;
BaserK 2:073c5513e2de 47
BaserK 0:06434e97c4f2 48 int main()
BaserK 0:06434e97c4f2 49 {
BaserK 1:46f06c96c5f0 50 /* Example: After nine steps it will stop */
BaserK 2:073c5513e2de 51 //brushlessControl(1, 500, 9);
BaserK 2:073c5513e2de 52
BaserK 0:06434e97c4f2 53 while(1)
BaserK 2:073c5513e2de 54 {
BaserK 2:073c5513e2de 55 oneStep(0, 500, &prevStep); // One step forward wait 500ms
BaserK 2:073c5513e2de 56 oneStep(1, 500, &prevStep); // One step backward wait 500ms
BaserK 2:073c5513e2de 57
BaserK 2:073c5513e2de 58 /* 500 ms delay time is just for testing, you should reduce the delay time for better movement */
BaserK 0:06434e97c4f2 59 }
BaserK 0:06434e97c4f2 60 }