Nucleo F303K8とSG90を用いたサーボ信号変更における処理時間の測定

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
RyotaNakamura
Date:
Thu Feb 09 11:00:42 2017 +0000
Commit message:
Nucleo F303K8?SG90??????????????????????

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 e7072f95dcaf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 09 11:00:42 2017 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+
+#define ON  1
+#define OFF 0
+
+PwmOut servo1(D10);
+Serial pc(USBTX, USBRX);
+Timer timer1;
+Timer timer2;
+
+int main()
+{
+    float pwidth;
+    int miri=1000;
+    servo1.period_ms(20);// pulse cycle = 20ms
+
+    while(1) {
+        for(pwidth=0.001; pwidth<=0.002; pwidth+=0.000001) { // 1ms ~ 2ms
+            timer1.reset();
+            timer1.start();
+            servo1.pulsewidth(pwidth); // pulse servo out
+            timer1.stop();
+            float t1=timer1.read();
+            float time1=t1*miri;
+            pc.printf("time1= %f ms\n",time1);
+            wait(0.001);
+        }
+
+        for(pwidth=0.002; pwidth>=0.001; pwidth-=0.000001) { // 1ms ~ 2ms
+            timer2.reset();
+            timer2.start();
+            servo1.pulsewidth(pwidth); // pulse servo out
+            timer2.stop();
+            float t2=timer2.read();
+            float time2=t2*miri;
+            pc.printf("time2= %f ms\n",time2);
+            wait(0.001);
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r e7072f95dcaf mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 09 11:00:42 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/176b8275d35d
\ No newline at end of file