2022 NHK Bteam main totyuu

Dependencies:   HOSOKIkikou FEP_RX22 QEI R1370 ikarashiMDC_2byte_ver mbed 2022_NHK_B_canTR PID SEKIkikou

Files at this revision

API Documentation at this revision

Comitter:
umekou
Date:
Sat Oct 08 08:31:07 2022 +0000
Parent:
3:75dae8deb5f3
Child:
5:2934a132d594
Commit message:
change enc

Changed in this revision

FEP_RX22.lib Show annotated file Show diff for this revision Revisions of this file
R1370.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
pinconfig.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FEP_RX22.lib	Sat Oct 08 08:31:07 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/FEP_RX22/#39eb865e21e1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/R1370.lib	Sat Oct 08 08:31:07 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tknara/code/R1370/#96f91d9e3bff
--- a/main.cpp	Fri Sep 30 06:28:25 2022 +0000
+++ b/main.cpp	Sat Oct 08 08:31:07 2022 +0000
@@ -1,13 +1,15 @@
 #include "mbed.h"
-#include "controller.h"
+#include "FEP_RX22.h"
+//#include "controller.h"
 #include "pinconfig.h"
 #include "ikarashiMDC.h"
 #include "QEI.h"
 
-Bcon mycon(fepTX, fepRX, fepad);
+FEP_RX22 mycon(fepTX, fepRX, fepad);
+//Bcon mycon(fepTX, fepRX, fepad);
 Serial pc(USBTX, USBRX, 115200);
 Serial serial(motorTX, motorRX, 115200);
-QEI enc1(encoder1_A, encoder1_B, NC, 100, QEI::X4_ENCODING);
+//QEI enc1(encoder1_A, encoder1_B, NC, 100, QEI::X4_ENCODING);
 QEI enc2(encoder2_A, encoder2_B, NC, 100, QEI::X4_ENCODING);
 QEI enc3(encoder3_A, encoder3_B, NC, 100, QEI::X4_ENCODING);
 QEI enc4(encoder4_A, encoder4_B, NC, 100, QEI::X4_ENCODING);
@@ -26,24 +28,35 @@
     ikarashiMDC(2,0,SM,&serial),
     ikarashiMDC(2,1,SM,&serial),
     ikarashiMDC(2,2,SM,&serial),
-    ikarashiMDC(2,3,SM,&serial)
+    ikarashiMDC(2,3,SM,&serial),
+    ikarashiMDC(3,0,SM,&serial)
 };
 
 uint8_t b[8];
 int16_t stick[4];
 
+uint8_t data[128];
+
+float angle[4]={};
+
+double speed[13]={};
+
 void recieveController(){
-    for (int i=0; i<8; i++) b[i] = mycon.getButton(i);
-    for (int i=0; i<4; i++) stick[i] = mycon.getStick(i);
-        
-    for (int i=0; i<8; i++) pc.printf("%d ", b[i]);
+    mycon.getData(data);
+    for (int i=0; i<5; i++) pc.printf("%d ", data[i]);
     pc.printf(" | ");
-    for (int i=0; i<4; i++) pc.printf("%3d ", stick[i]);
-    pc.printf(" | ");
-    if (mycon.status) pc.printf("received\r\n");
+    if (mycon.getStatus()) pc.printf("received\r\n");
     else pc.printf("anything error...\r\n");
 }
 
+void updateangle(){
+    //angle[0] = (float)enc1.getPulses();
+    angle[1] = (float)enc2.getPulses();
+    angle[2] = (float)enc3.getPulses();
+    angle[3] = (float)enc4.getPulses();
+    for (int i=0; i<4; i++) pc.printf("%f  ", angle[i]);
+    pc.printf("\r\n ");
+}
 
 int main()
 {
@@ -51,9 +64,14 @@
     stop = 1;
     led = 1;
     
+    printf("success!\r\n");
+    
     while(1) {
         
         //recieveController();
+        updateangle();
+        
+        
         
     }
 }
\ No newline at end of file
--- a/pinconfig.h	Fri Sep 30 06:28:25 2022 +0000
+++ b/pinconfig.h	Sat Oct 08 08:31:07 2022 +0000
@@ -7,23 +7,26 @@
 static PinName const stop_pin = PA_5;
 
 /*FEP*/
+
 static PinName const fepTX = PA_9;
 static PinName const fepRX = PA_10;
-static uint8_t const fepad = 005; // 通信相手のアドレス
+static uint8_t const fepad = 20; // 通信相手のアドレス
 
 /*motor serial*/
 static PinName const motorTX = PC_10;
 static PinName const motorRX = PC_11;
 
 /*encoder*/
-static PinName const encoder1_A = PB_6;
-static PinName const encoder1_B = PB_7;
-
+/*
+static PinName const encoder1_A = PB_2;
+static PinName const encoder1_B = PB_1;
+使えない
+*/
 static PinName const encoder2_A = PA_6;
 static PinName const encoder2_B = PA_7;
 
-static PinName const encoder3_A = PC_3;
-static PinName const encoder3_B = PC_2;
+static PinName const encoder3_A = PB_13;
+static PinName const encoder3_B = PB_15;
 
 static PinName const encoder4_A = PA_1;
 static PinName const encoder4_B = PA_0;