2019NHK_teamA_auto_measuring wheel

Dependencies:   QEI R1370MeasuringWheel

Files at this revision

API Documentation at this revision

Comitter:
tanabe2000
Date:
Wed Jul 04 09:32:06 2018 +0000
Parent:
0:505dd5510add
Child:
2:f34a22b28ac5
Commit message:
test

Changed in this revision

QEI.lib Show annotated file Show diff for this revision Revisions of this file
measuring_wheel.cpp Show annotated file Show diff for this revision Revisions of this file
measuring_wheel.h Show annotated file Show diff for this revision Revisions of this file
--- a/QEI.lib	Mon Jul 02 08:38:07 2018 +0000
+++ b/QEI.lib	Wed Jul 04 09:32:06 2018 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/aberk/code/QEI/#40523b009a03
+https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/QEI/#40523b009a03
--- a/measuring_wheel.cpp	Mon Jul 02 08:38:07 2018 +0000
+++ b/measuring_wheel.cpp	Wed Jul 04 09:32:06 2018 +0000
@@ -3,13 +3,17 @@
 MeasuringWheel::MeasuringWheel(PinName channel1_1, PinName channel1_2, PinName channel2_1, PinName channel2_2, PinName channel3_1, PinName channel3_2):
     w1(channel1_1, channel1_2, NC, 500, QEI::X4_ENCODING),
     w2(channel2_1, channel2_2, NC, 500, QEI::X4_ENCODING),
-    w3(channel3_1, channel3_2, NC, 500, QEI::X4_ENCODING)
+    w3(channel3_1, channel3_2, NC, 500, QEI::X4_ENCODING),
+    mainMicon(PC_10, PC_11, 115200),
+    led(LED2)
 
 {
     radian[0] = 0;
     radian[1] = -2*PI/3;
     radian[2] = 2*PI/3;
-    ticker.attach(callback(this, &MeasuringWheel::computeXY),0.001);
+    ticker.attach(callback(this, &MeasuringWheel::computeXY),0.01);
+    ticker1.attach(callback(this, &MeasuringWheel::transmissionXY),0.1);
+//    mainMicon.attach(callback(this, &MeasuringWheel::resetpisithon));//受信割り込み
 }
 
 
@@ -50,29 +54,10 @@
     return Y;
 }
 
-TransmissionXY::TransmissionXY(PinName serialTX,PinName serialRX): mainMicon(serialTX, serialRX, 115200), led(LED2)
-{
-//    mainMicon.attach(callback(this, &TransmissionXY::resetpisithon));
-}
-
-void TransmissionXY::resetpisithon()
+void MeasuringWheel::transmissionXY()
 {
-    get = mainMicon.getc();
-    if(get == 'R') {
-        ofsetX = X_;
-        ofsetY = Y_;
-        led = !led;
-    }
-    X_ -= ofsetX;
-    Y_ -= ofsetY;
-
-}
-
-bool TransmissionXY::sendMeasuring(MeasuringWheel &request)
-{
-
-    X_ = request.getOutX()+32768;
-    Y_ = request.getOutY()+32768;
+    X_ = X + 32768;
+    Y_ = Y + 32768;
     upBitX = (X_ >> 8) & 0xff;
     downBitX = X_ & 0xff;
     upBitY = (Y_ >> 8) & 0xff;
@@ -83,6 +68,17 @@
     mainMicon.putc(downBitX);
     mainMicon.putc(upBitY);
     mainMicon.putc(downBitY);
+}
 
-    return 1;
-}
\ No newline at end of file
+//void MeasuringWheel::resetpisithon()
+//{
+//    get = mainMicon.getc();
+//    if(get != 'R') {
+//        //X = 0;
+////        Y = 0;
+////        led = !led;
+//    }
+//
+//
+//}
+
--- a/measuring_wheel.h	Mon Jul 02 08:38:07 2018 +0000
+++ b/measuring_wheel.h	Wed Jul 04 09:32:06 2018 +0000
@@ -15,38 +15,29 @@
 
     float getOutX();
     float getOutY();
-
+    void transmissionXY();
+     
 
 private :
     float diameter[3];
     float radian[3];
     float wheel[3],r,X,Y;
     void computeXY();
-     
+       
 
     QEI w1;
     QEI w2;
     QEI w3;
     Ticker ticker;
-    
-};
-
-
-class TransmissionXY
-{
-
-public:
-    TransmissionXY(PinName serialTX, PinName serialRX);
-    bool sendMeasuring( MeasuringWheel &request);
-    void resetpisithon();
-private:
-
+    Ticker ticker1;
     uint16_t X_, Y_,ofsetX, ofsetY;
     char upBitX, upBitY;
     char downBitX,downBitY;
     Serial mainMicon;
     char get;
     DigitalOut led;
-      
+//    void resetpisithon(); 
+    
 };
+
 #endif
\ No newline at end of file