Marieke M / Mbed 2 deprecated frdm_motorConstantesBepalen_bewerkt

Dependencies:   HIDScope QEI mbed

Fork of frdm_motorConstantesBepalen by Gerhard Berman

Files at this revision

API Documentation at this revision

Comitter:
Marieke
Date:
Fri Oct 28 11:04:15 2016 +0000
Child:
1:b7a1138131bb
Commit message:
Motor_sinus_test

Changed in this revision

HIDScope.lib Show annotated file Show diff for this revision Revisions of this file
QEI_DCmotors.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/HIDScope.lib	Fri Oct 28 11:04:15 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tomlankhorst/code/HIDScope/#eade4ec5282b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI_DCmotors.lib	Fri Oct 28 11:04:15 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aberk/code/QEI/#5c2ad81551aa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 28 11:04:15 2016 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "QEI.h"
+#include "HIDScope.h"
+
+// Definiëren van alle poorten
+
+DigitalIn encoder1A (D13); //Channel A van Encoder 1
+DigitalIn encoder1B (D12); //Channel B van Encoder 1
+DigitalIn encoder2A (D11); //Channel A van Encoder 2, kan niet op D15
+DigitalIn encoder2B (D10); //Channel B van Encoder 2, kan niet op D14
+DigitalOut motor1 (D7);
+PwmOut pwm_motor1 (D6);
+DigitalOut motor2 (D4);
+PwmOut pwm_motor2 (D5);
+HIDScope    scope( 2 );
+Ticker      sample_timer;
+
+double t;
+float pi=3.14159;
+float Aout;
+int counts1;
+int counts2;
+ 
+void sample()
+{
+    scope.set(0, counts1);
+    scope.set(1, counts2);
+    
+    scope.send();
+}
+
+
+int main() {
+    const double frequency_pwm = 100.0;
+    pwm_motor1.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.0004);
+ 
+    while(true){
+            for (t=0; t<10; t=t+0.005) {
+                Aout=1*sin(2*pi*t);
+            }
+        motor1= Aout;
+        pwm_motor1.write(1.0);
+        counts1 = Encoder1.getPulses();
+        counts2 = Encoder2.getPulses();
+    }
+ }
+
+   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 28 11:04:15 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file