2022Aのエンコーダを読んでとばす(サブ2基盤)

Dependencies:   QEI SerialMultiByte mbed

Files at this revision

API Documentation at this revision

Comitter:
nagix
Date:
Sun Oct 09 09:02:22 2022 +0000
Commit message:
a

Changed in this revision

QEI.lib Show annotated file Show diff for this revision Revisions of this file
SerialMultiByte.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/QEI.lib	Sun Oct 09 09:02:22 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kikoaac/code/QEI/#a24686ca50ab
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialMultiByte.lib	Sun Oct 09 09:02:22 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/SerialMultiByte/#a5d4fe088b23
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 09 09:02:22 2022 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "QEI.h"
+#include "SerialMultiByte.h"
+
+QEI enc1(PB_6,PB_3,NC,100, QEI::X4_ENCODING);
+QEI enc2(PA_8,PA_9,NC,100, QEI::X4_ENCODING);
+QEI enc3(PB_6,PB_7,NC,100, QEI::X4_ENCODING);
+QEI enc4(PA_0,PA_1,NC,100, QEI::X4_ENCODING);
+
+
+Serial pc(USBTX,USBRX,115200);
+SerialMultiByte send(PC_12,PD_2);
+
+//int Revol1;
+//int Current;
+//double GetAngle;
+//int Angle_rev;
+//double SumAngle;
+
+Timer t;
+
+int main() 
+{
+//    stop = 1;
+//    uint8_t test[4] = {1,2,3,4};
+    int16_t Angle[4] = {0};
+    uint8_t Pulse[8] = {0};
+    t.start();
+    send.setHeaders(0xff,0xff);
+
+    while(1)
+    {   
+        Angle[0] = enc1.getPulses(); 
+        Angle[1] = enc2.getPulses(); 
+        Angle[2] = enc3.getPulses(); 
+        Angle[3] = enc4.getPulses();
+        for(int i=0, j=0;i<8;i+=2,j++){
+            Pulse[i] = Angle[j] >> 8;
+            Pulse[i+1] = Angle[j] & 255;
+        }
+//        Pulse[0] = Angle[0] >> 8;
+//        Pulse[1] = Angle[0] & 255;
+
+//        Revol1 = enc1.getRevolutions();
+//        Current = enc1.getCurrentState();
+//        GetAngle = enc1.getAngle();
+//        Angle_rev = enc1.getAng_rev();
+//        SumAngle = enc1.getSumangle();
+
+                                           
+//        pc.printf("t:%.2f | ENC0:%d | REV0:%d | Cur:%d | GetAngle:%.2f | Angle_rev:%d | SumAngle:%.2f", t.read(),Angle1,Revol1,Current,GetAngle,Angle_rev,SumAngle);
+        pc.printf("t:%.2f | ENC1:%.2d | ENC2:%.2d | ENC3:%.2d | ENC4:%.2d |", t.read(),Angle[0],Angle[1],Angle[2],Angle[3]);
+        pc.printf("\r\n");
+        send.sendData(Pulse,8);
+        
+//        pc.printf("t:%.2f | test1:%.2d | test2:%.2d | test3:%.2d | test4:%.2d |", t.read(),test[0],test[1],test[2],test[3]);
+//        pc.printf("\r\n");
+//        send.sendData(test,4);
+        
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 09 09:02:22 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file