make sine to determine simulink contants motor

Dependencies:   HIDScope MODSERIAL QEI mbed

Fork of frdm_motorConstantesBepalen_bewerkt by Marieke M

Files at this revision

API Documentation at this revision

Comitter:
FloorC
Date:
Wed Nov 02 09:12:53 2016 +0000
Parent:
2:78a4dccff486
Commit message:
motor constantes bepalen, sinus hogere frequentie, werkt??

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Wed Nov 02 09:12:53 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#8ef4f91813fd
--- a/main.cpp	Tue Nov 01 16:24:38 2016 +0000
+++ b/main.cpp	Wed Nov 02 09:12:53 2016 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "QEI.h"
-#include "HIDScope.h"
+//#include "HIDScope.h"
+#include "MODSERIAL.h"
 
 // Definiëren van alle poorten
 
@@ -12,7 +13,8 @@
 PwmOut pwm_motor1 (D6);
 DigitalOut motor2 (D4);
 PwmOut pwm_motor2 (D5);
-HIDScope    scope( 4 );
+MODSERIAL pc(USBTX, USBRX);
+//HIDScope    scope( 4 );
 Ticker      sample_timer, snelheid_ticker;
 
 double t;
@@ -21,22 +23,17 @@
 double PWMAout;
 //float v_1;
 int counts1_old;
-int counts1;
-int counts2;
+double counts1;
+double counts2;
 const int cw=0;
 const int ccw=1;
 
-void sample()
-{
+
+
     //v_1 = (float) ((counts1 - counts1_old)/0.02);
     //counts1_old=counts1;
-    scope.set(0, counts1);
-    scope.set(1, counts2);
-    scope.set(2, Aout);
-    scope.set(3, PWMAout);
-    //scope.set(3, PWMAout);
-    scope.send();
-}
+
+
 
 
 /*void snelheid()
@@ -52,18 +49,20 @@
 
 
 int main() {
+    
+    pc.baud(115200);
     const double frequency_pwm = 0.5;
     pwm_motor1.period(1.0/frequency_pwm);
     pwm_motor2.period(1.0/frequency_pwm);
     QEI Encoder1(D12, D13, NC, 32); //maakt de encoder aan, NC niet aanwezig, 32 bits
     QEI Encoder2(D10, D11, NC, 32); //maakt de encoder aan, NC niet aanwezig, 32 bits
-    sample_timer.attach(&sample, 0.001);
+
     //snelheid_ticker.attach(&snelheid, 0.01f);
     
  
     while(true){
-      for (t=0; t<2000; t=t+0.1) {
-                Aout= (double) 1*sin(0.001*pi*t);
+      for (t=0; t<2000; t=t+0.002) {
+                Aout= (double) 1*sin(2*pi*2*t);
                 PWMAout=fabs((Aout+1)/2);
             if (Aout >=0) //clockwise rotation
                 {motor1.write(cw);        //?
@@ -91,7 +90,15 @@
             pwm_motor2.write(0.5);*/
             counts1 = Encoder1.getPulses();
             counts2 = Encoder2.getPulses();
+            pc.printf("%f \r\n",counts1);
+                 
             }
+            //scope.set(0, counts1);
+    //scope.set(1, counts2);
+    //scope.set(2, Aout);
+    //scope.set(3, PWMAout);
+    
+    //scope.send();
     }
  }
 
--- a/mbed.bld	Tue Nov 01 16:24:38 2016 +0000
+++ b/mbed.bld	Wed Nov 02 09:12:53 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32
\ No newline at end of file