Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: brushlessController_L293D mbed
main.cpp
00001 /* Controlling a brushless motor with 2X L293D 00002 * 00003 * @author: Baser Kandehir 00004 * @date: July 16, 2015 00005 * @license: MIT license 00006 * 00007 * Copyright (c) 2015, Baser Kandehir, baser.kandehir@ieee.metu.edu.tr 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a copy 00010 * of this software and associated documentation files (the "Software"), to deal 00011 * in the Software without restriction, including without limitation the rights 00012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 * copies of the Software, and to permit persons to whom the Software is 00014 * furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in 00017 * all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 * THE SOFTWARE. 00026 * 00027 * @description of the program: 00028 * 00029 * Brushless motor control program with L293D. 00030 * L293D is a simple, cheap standard DC motor driver and can be found easily. 00031 * But I should say that controlling brushless motors with L293D is not efficient 00032 * and precise. Proper way to control brushless motor is using an ESC or drivers 00033 * like L6235. For the time being I have none of them, but I had a brushless motor that 00034 * I wanted to control and see how it works. If you want to do the same, that program 00035 * is for you. 00036 * 00037 * This guy did a great job by explaining how it is done: 00038 * http://www.instructables.com/id/Arduino-CDROM-BLDC-Motor-Driver-Enhanced-Performan/ 00039 * 00040 * Note: For any mistakes or comments, please contact me. 00041 */ 00042 00043 #include "mbed.h" 00044 #include "brushlessController_L293D.h" 00045 00046 int prevStep = 0; 00047 00048 int main() 00049 { 00050 /* Example: After nine steps it will stop */ 00051 //brushlessControl(1, 500, 9); 00052 00053 while(1) 00054 { 00055 oneStep(0, 500, &prevStep); // One step forward wait 500ms 00056 oneStep(1, 500, &prevStep); // One step backward wait 500ms 00057 00058 /* 500 ms delay time is just for testing, you should reduce the delay time for better movement */ 00059 } 00060 }
Generated on Thu Jul 14 2022 04:04:01 by
1.7.2