0910

Dependencies:   mbed QEI2

kyuuban.cpp

Committer:
kenboh
Date:
2019-09-10
Revision:
1:5f5d47a593bc

File content as of revision 1:5f5d47a593bc:

#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