V0.1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kweisbeek
Date:
Mon Oct 22 11:11:15 2018 +0000
Commit message:
V1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 1045216da12e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 22 11:11:15 2018 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+
+
+//initial allocations
+DigitalOut dirpin(D4);
+PwmOut pwmpin(D5);
+QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING);
+
+//volatiles
+volatile counts_prev=0;
+
+//functions
+int counts(){
+    int counts=Encoder.getPulses();     //MAAK NOG AF MET PREVIOUS COUNTS ONTHOUDEN.
+    return counts
+
+
+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
+    
+    //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)){
+            for (n=1;caltime;n++){
+                if (counts()!=counts_prev){
+                    n=0;}
+                else {}
+            wait(0.1);}
+            dir=dir+1;}
+            
+            
+            
+            
\ No newline at end of file
diff -r 000000000000 -r 1045216da12e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 22 11:11:15 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file