faulhaber製エンコーダの動作検証用プログラム

Dependencies:   mbed CRotaryEncoder

Files at this revision

API Documentation at this revision

Comitter:
yusaku0125
Date:
Mon Jul 22 04:03:37 2019 +0000
Commit message:
test

Changed in this revision

CRotaryEncoder.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
diff -r 000000000000 -r df99e50ed3fd CRotaryEncoder.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRotaryEncoder.lib	Mon Jul 22 04:03:37 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Raabinator/code/CRotaryEncoder/#56f636261771
diff -r 000000000000 -r df99e50ed3fd main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jul 22 04:03:37 2019 +0000
@@ -0,0 +1,23 @@
+ //エンコーダの動作確認。
+ //左右モータの回転数を検出するプログラム
+ #include "mbed.h"
+ #include "CRotaryEncoder.h"
+ 
+ Serial PC(USBTX,USBRX);
+ CRotaryEncoder encoder_a(D1,D0);       //モータAのエンコーダ
+ CRotaryEncoder encoder_b(D11,D12);     //モータBのエンコーダ
+  
+ 
+ int main(){
+    int enc_count_a=0,enc_count_b=0;    //エンコーダパルス数を格納
+    int rotation_a=0,rotation_b=0;      //回転数を格納
+     while(1)
+    {
+         enc_count_a=encoder_a.Get();   //エンコーダパルス数を取得
+         enc_count_b=encoder_b.Get();
+         rotation_a=enc_count_a/400;    //400パルスで一回転
+         rotation_b=enc_count_b/400;    
+         PC.printf("enc_a:%d   enc_b:%d\r\n",rotation_a,rotation_b);//表示
+         wait(0.5);
+    }
+ }
diff -r 000000000000 -r df99e50ed3fd mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jul 22 04:03:37 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file