NagaokaRoboticsClub_mbedTeam / Mbed OS 2019NHK_A_sensor

Dependencies:   SerialMultiByte QEI TFmini IRsensor

Files at this revision

API Documentation at this revision

Comitter:
highfieldsnj
Date:
Thu Sep 05 16:15:26 2019 +0900
Parent:
0:d789af71fbc6
Child:
2:4466f57c9e43
Commit message:
sensor_board

Changed in this revision

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-os.lib 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
--- a/SerialMultiByte.lib	Mon Aug 26 08:44:58 2019 +0000
+++ b/SerialMultiByte.lib	Thu Sep 05 16:15:26 2019 +0900
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/SerialMultiByte/#7f87c3ff29ef
+https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/SerialMultiByte/#ca2a6fdb24af
--- a/main.cpp	Mon Aug 26 08:44:58 2019 +0000
+++ b/main.cpp	Thu Sep 05 16:15:26 2019 +0900
@@ -8,8 +8,8 @@
 union UnionBytes{
     uint8_t bytes[28];
     float IRdistance[7];    //0~1
-    uint32_t TFdistance[7]; //2~3
-    uint32_t pulses[7];     //4~6
+    int32_t TFdistance[7]; //2~3
+    int32_t pulses[7];     //4~6
 };
 
 IRsensor ir[] = {
@@ -19,37 +19,47 @@
 
 TFmini tf[] = {
     TFmini(TF0_TX, TF0_RX),
-    TFmini(TF1_TX, TF0_RX)
+    TFmini(TF1_TX, TF1_RX)
 };
 
 QEI loli[] = {
-    QEI(encoder_0A, encoder_0B, NC, 100, QEI::X4_ENCODING),
     QEI(encoder_1A, encoder_1B, NC, 100, QEI::X4_ENCODING),
-    QEI(encoder_2A, encoder_2B, NC, 100, QEI::X4_ENCODING)
+    QEI(encoder_4A, encoder_4B, NC, 100, QEI::X4_ENCODING),
+    QEI(encoder_3A, encoder_3B, NC, 100, QEI::X4_ENCODING)
 };
 
 SerialMultiByte serial(mainTX, mainRX);
 
+Serial pc(USBTX, USBRX, 115200);
+
 int main()
 {
+    //pc.printf("hello\r\n");
     UnionBytes bytedata;
+    uint8_t sendbytes[28];
     for(int i=0; i<28; i++){
         bytedata.bytes[i] = 0;
     }
     for(int i=0; i<2; i++){
         ir[i].startAveraging(10);
     }
-    while (true) {
+    while (1) {
         for(int i=0; i<2; i++){
             bytedata.IRdistance[i] = ir[i].get_Averagingdistance();
+            pc.printf("%f ", bytedata.IRdistance[i]);
         }
         for(int i=0; i<2; i++){
-            bytedata.TFdistance[i+2] = tf[i].getDistance();
+            bytedata.TFdistance[i+2] = (int32_t)tf[i].getDistance();
+            pc.printf("%d ", bytedata.TFdistance[i+2]);
         }
         for(int i=0; i<3; i++){
-            bytedata.pulses[i+4] = loli[i].getPulses();
+            bytedata.pulses[i+4] = (int32_t)loli[i].getPulses();
+            pc.printf("%d ", bytedata.pulses[i+4]);
         }
-        serial.sendData(bytedata.bytes, 28);
+        for(int i=0; i<28; i++){
+            sendbytes[i] = bytedata.bytes[i];
+        }
+        serial.sendData(sendbytes, 28);
+        pc.printf("a\r\n");
     }
 }
-
--- a/mbed-os.lib	Mon Aug 26 08:44:58 2019 +0000
+++ b/mbed-os.lib	Thu Sep 05 16:15:26 2019 +0900
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2
+https://github.com/ARMmbed/mbed-os/#1bf6b20df9d3cd5f29f001ffc6f0d0fcbbb96118
--- a/pinconfig.h	Mon Aug 26 08:44:58 2019 +0000
+++ b/pinconfig.h	Thu Sep 05 16:15:26 2019 +0900
@@ -1,22 +1,22 @@
 #ifndef PINCONFIG_H
 #define PINCONFIG_H
-
-const PinName IR_0 = A2;
-const PinName IR_1 = A3;
+//sensor
+const PinName IR_0 = PA_4;
+const PinName IR_1 = PB_0;
 
-const PinName TF0_TX = A0;
-const PinName TF0_RX = A1;
-const PinName TF1_TX = PC_12;
-const PinName TF1_RX = PD_2;
+const PinName TF0_TX = PC_10;
+const PinName TF0_RX = PC_11;
+const PinName TF1_TX = PC_6;
+const PinName TF1_RX = PC_7;
 
-const PinName encoder_0A = D2;
-const PinName encoder_0B = D3;
-const PinName encoder_1A = D4;
-const PinName encoder_1B = D5;
-const PinName encoder_2A = D6;
-const PinName encoder_2B = D7;
+const PinName encoder_1A = PA_8;
+const PinName encoder_1B = PA_9;
+const PinName encoder_4A = PA_0;
+const PinName encoder_4B = PA_1;
+const PinName encoder_3A = PB_6;
+const PinName encoder_3B = PB_7;
 
-const PinName mainTX = PC_10;
-const PinName mainRX = PC_11;
+const PinName mainTX = PC_12;
+const PinName mainRX = PD_2;
 
-#endif
\ No newline at end of file
+#endif