brushless motor control library with l293d

Dependents:   brushless_L293D

Revision:
3:d6e8fbc04a43
Parent:
2:ac825be76379
Child:
4:3f311665f813
--- a/brushlessController_L293D.cpp	Tue Jul 14 08:43:10 2015 +0000
+++ b/brushlessController_L293D.cpp	Thu Jul 16 15:17:01 2015 +0000
@@ -8,7 +8,18 @@
 DigitalOut out2(p22);
 DigitalOut out3(p24);
 
-/* HIGH-Z is activated with 2xL293D, now it works better */
+
+/* Brushless motor control function 
+*
+* @brief: This function can control a brushless motor with L293D.
+* By changing steps of the brushless motor one after another, motor
+* can be controlled in either direction.
+*
+* @variables: 
+*   dir: Direction of the motor
+*   delay_time: Time delay between steps
+*   stepNum: Number of steps
+*/
 void brushlessControl(bool dir, int delay_time, int stepNum)
 {
     /* Digital outputs are initially zero */
@@ -39,6 +50,16 @@
     }   
 }
 
+/* Brushless motor one step movement function 
+* 
+* @brief: This function can move the motor one step in either direction
+* It takes the previous step as a parameter and uses it to go next.
+*
+* @variables: 
+*   dir: Direction of the motor
+*   delay_time: Time delay between steps
+*   prevStep: Previous step of the motor
+*/
 void oneStep(bool dir, int delay_time, int* prevStep)
 {
     /* Digital outputs are initially zero */
@@ -58,7 +79,7 @@
         
     int i = *prevStep;
         
-    if (i<0) // Mod operation for the negative number
+    if (i<0)   // Mod operation for the negative number
     {
         i*=(-1); i%=6; i=6-i; 
         i%=6;  // if i=6, it should be zero.   
@@ -71,4 +92,3 @@
     out3 = data_array[3*i+2];  (data_array[3*i+2] == 2)?(en3 = 0):(en3 = 1);   
     wait_ms(delay_time);  
 }
-