V0.1

Dependencies:   mbed QEI

Fork of motor_calibration by Kenneth Weisbeek

Revision:
1:53bb5928adcf
Parent:
0:1045216da12e
Child:
2:ea985bb173f6
--- a/main.cpp	Mon Oct 22 11:11:15 2018 +0000
+++ b/main.cpp	Fri Oct 26 07:36:28 2018 +0000
@@ -6,37 +6,64 @@
 PwmOut pwmpin(D5);
 QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING);
 
+
+
 //volatiles
 volatile counts_prev=0;
 
-//functions
+
+
+//functions (4 functions not finished)
 int counts(){
     int counts=Encoder.getPulses();     //MAAK NOG AF MET PREVIOUS COUNTS ONTHOUDEN.
-    return counts
+    return counts;
+
+int pos_store(a){}                       //store position in counts to know count location of the ends of bridge
+    
+void rotate_start(){}                    //start rotation of disk
+
+void rotate_stop(){}                     //stop rotation of disk
 
 
+
+//main function
 int main(){
     pwmpin.period_us(60);
     
     //parameters
     int caltime=30;             //calibration time until condition has been met, caltime=(time/0.1)  
     float speed=0.50f;
-    int dir=0
+    int dir=0;
+    int counts_end=;          //amount of counts for 360 degrees rotation of main disk --> many revolutions of motor
     
     //move towards end
     for (m=1;2;m++){
         dirpin.write(dir);
         pwmpin = speed;
-        int n=1
         //when motor counts do not change anymore, change direction
-        while(n<(caltime+1)){
+        int n=1;
+        while(n=1){
             for (n=1;caltime;n++){
                 if (counts()!=counts_prev){
                     n=0;}
                 else {}
-            wait(0.1);}
-            dir=dir+1;}
-            
+                wait(0.1);}
+            int position=counts();}
+            dir=dir+1;
+            pos_store(position);}   //stores position integer
+    
+    //Check if a full circle can be made without obstruction
+        //Try adding a timer as well, you know how long it should take, how long does it actually take? Does that matter?
+    rotate_start();
+    while(1){
+        if counts2_zero()>=counts2_end{
+            break;}
+        else {}
+        wait(0.01);}
+    rotate_stop();
+    pos_store(counts2());   
+    //End sequence?    
+    }
             
             
             
\ No newline at end of file