謙一 永井 / Mbed 2 deprecated SRC2018Auto

Dependencies:   mbed QEI2

Files at this revision

API Documentation at this revision

Comitter:
kenboh
Date:
Tue Sep 10 09:30:41 2019 +0000
Parent:
0:2a0c62e53e9c
Commit message:
SRC2018Auto

Changed in this revision

PinName.h Show annotated file Show diff for this revision Revisions of this file
QEI2.lib Show annotated file Show diff for this revision Revisions of this file
kyuuban.cpp Show annotated file Show diff for this revision Revisions of this file
kyuuban.h 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinName.h	Tue Sep 10 09:30:41 2019 +0000
@@ -0,0 +1,74 @@
+//二重インクルードの防止。未定義の時のみ以下を読み込む
+#ifndef _INCLUDED_PINNAME 
+#define _INCLUDED_PINNAME
+
+#include "mbed.h"
+
+
+//これ以下エクセルからコピペ
+
+//CN7   名前決める   ピン名
+#define ctrTX    PC_10
+#define subTX    PC_12  //送信
+//      
+//        
+#define odo1A   PA_13
+#define odo1B   PA_14
+#define odo2A   PC_14
+#define odo2B   PC_15
+#define photo   PH_0
+#define MD1_CW1 PH_1
+//      
+#define MD1_DIS1    PC_2
+#define MD1_CW2 PC_3
+
+//CN6,8 名前決める   ピン名
+#define ctrRX    PC_11
+#define subRX    PD_2    //受信
+//      
+//          
+//      
+#define MD1_PWM1    PA_1
+#define MD1_CCW1    PA_4
+#define MD1_PWM2    PB_0
+#define MD1_CCW2    PC_1
+#define MD1_DIS2    PC_0
+
+//CN5,9 名前決める   ピン名
+#define limit1  PC_9
+#define enc1    D15
+#define enc2    D14
+//      AVDD
+//      GND
+#define kyuuban D9
+#define MD2_DIS1    D8
+#define LED1    D7
+#define LED2    D6
+#define MD2_CW2 D5
+#define MD2_DIS2    D4
+#define MD2_PWM2    D3
+#define MD2_CCW2    D2
+#define MD2_PWM1    D1
+#define MD2_CCW1    D0
+
+
+//CN10  名前決める   ピン名
+#define limit2  PC_8
+#define limit3  PC_6
+#define limit4  PC_5
+//      
+//      
+#define MD3_CW2 PA_12
+#define MD3_DIS1    PA_11
+#define MD3_CW1 PB_12
+//      NC
+#define MD3_PWM1    PB_2
+#define MD3_CCW1    PB_1
+#define MD3_PWM2    PB_15
+#define MD3_CCW2    PB_14
+#define MD3_DIS2    PB_13
+//      AGND
+#define MD2_CW1 PC_4
+//      
+//      
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI2.lib	Tue Sep 10 09:30:41 2019 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/kikoaac/code/QEI2/#49fa8827718d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kyuuban.cpp	Tue Sep 10 09:30:41 2019 +0000
@@ -0,0 +1,50 @@
+#if 1
+#include "kyuuban.h"
+#include "QEI.h" 
+
+Timer enc_tim;  //Timerクラスのインスタンス(実体)
+QEI qei(D15,D14,D10,800,&enc_tim);  //class宣言
+// qei.getPulses(); //Pulsesを返す
+
+void KyuubanINIT() {
+//    pc.printf("morter init ... ");
+    kyuuban_pwm.period_us(100);    //PWM信号を出し始める
+    kyuuban_pwm.pulsewidth_ms(20);
+    kyuuban_up = 0;   //正転も逆転もしない状態
+    kyuuban_down = 0;
+    kyuuban_dis = 0;    //dis=1だとフリー回転
+    kyuubanMOVE = 0;
+    int K1 = kyuuban_lim;
+    while(K1 == 0){    //反応してる状態が0?
+        kyuuban_down = 1;             //下降開始
+        K1 = kyuuban_lim;    //代入しなおし
+        wait_ms(0.5);
+    }
+    kyuuban_down = 0;             //下降停止
+//    pc.printf("END\n\r");
+//    return 0;
+} 
+
+void KyuubanLIFT(){
+//    pc.printf("Lyuuban LIFT...");
+    kyuuban_up = 1;
+    while(qei.getPulses() < kyuubanUPlimit){
+        wait_ms(0.5);
+    }
+    kyuuban_up = 0;
+//    return 0;
+}
+
+void KyuubanEND(){
+    kyuuban_down = 1;
+    while(qei.getPulses() < kyuubanDOWN){
+        wait_ms(0.5);
+    }
+    kyuuban_down = 0;
+    kyuubanMOVE = 0;
+    wait(2);
+//    return 0;
+}
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kyuuban.h	Tue Sep 10 09:30:41 2019 +0000
@@ -0,0 +1,15 @@
+#ifndef KYUUBAN_H_
+#define KYUUBAN_H_
+
+#include "mbed.h"
+//#include "PinName.h"
+DigitalOut kyuubanMOVE(D9);
+PwmOut kyuuban_pwm(PB_0);
+DigitalOut kyuuban_up(PC_3);
+DigitalOut kyuuban_down(PC_1);
+DigitalOut kyuuban_dis(PC_0);
+DigitalIn kyuuban_lim(PC_13);
+#define kyuubanUPlimit 50
+#define kyuubanDOWN 20
+
+#endif
\ No newline at end of file
--- a/main.cpp	Wed Sep 12 09:07:30 2018 +0000
+++ b/main.cpp	Tue Sep 10 09:30:41 2019 +0000
@@ -4,6 +4,17 @@
 #include "User.h"
 #include "DualShockMod.h"
 
+//永井ここから
+//#include "kyuuban.h"
+//#include "QEI.h"
+
+//Timer enc_tim;  //Timerクラスのインスタンス(実体)
+//QEI qei(enc1,enc2,D10,800,&enc_tim);  //class宣言
+// qei.getPulses(); //Pulsesを返す
+
+//ここまで
+
+
 //serial通信
 Serial pc(SERIAL_TX, SERIAL_RX);
 Serial tsuushin(PC_12,PD_2);  
@@ -116,7 +127,7 @@
 
 
 
-int main(void){
+int main(void){    
     motor_init();           //cwなどの初期化
     while(1){
         //エンコーダーの値
@@ -283,7 +294,4 @@
         
         }
     }
-}
-        
-    
-
+}
\ No newline at end of file