Kim Youngsik / Mbed 2 deprecated 0ROBOFRIEN_FCC_v1_12

Dependencies:   mbed BufferedSerial ConfigFile

ROBOFRIEN_SUB_FUNC/ROBOFRIE_PID.cpp

Committer:
skyyoungsik
Date:
2018-06-12
Revision:
0:3473b92e991e

File content as of revision 0:3473b92e991e:

#include "ROBOFRIEN_PID.h"
#include "PID.h"

#define RATE 0.01
PID ROLL_RATE_PID(10.0, 0.0, 0.0, RATE);

void ROBOFRIEN_PID::Init(){
    ROLL_RATE_PID.setInputLimits(0.0, 10.0);
    ROLL_RATE_PID.setOutputLimits(0.0, 1.0);
    ROLL_RATE_PID.setMode(AUTO_MODE);
    ROLL_RATE_PID.setSetPoint(err_Angle[0]);
}

void ROBOFRIEN_PID::ROLL_RATE_PID_RUN(){
    if(err_Rate[0] >= 0){
        ROLL_RATE_PID.setProcessValue(err_Rate[0]);
        output_Data[0] = ROLL_RATE_PID.compute();
    }
    else{
        ROLL_RATE_PID.setProcessValue(-err_Rate[0]);
        output_Data[0] = -ROLL_RATE_PID.compute();
    }
}

void ROBOFRIEN_PID::update(){
    ROLL_RATE_PID_RUN();
}