在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)PID算法實(shí)現(xiàn)

            單片機(jī)PID算法實(shí)現(xiàn)

            作者: 時(shí)間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
            在avr單片機(jī)上實(shí)現(xiàn)的100%通過測試,用單片機(jī)調(diào)的倒立擺非常穩(wěn)定.
            #include
            #include

            struct _pid
            {
            int pv; //integer that contains the process value 過程量
            int sp; //*integer that contains the set point 設(shè)定值
            float integral; // 積分值
            float pgain;
            float igain;
            float dgain;
            int deadband; //死區(qū)
            int last_error;
            };

            struct _pid warm,*pid;
            int process_point, set_point,dead_band;
            float p_gain, i_gain, d_gain, integral_val,new_integ;;

            void pid_init(struct _pid *warm, int process_point, int set_point)
            {
            struct _pid *pid;
            pid = warm;
            pid->pv = process_point;
            pid->sp = set_point;
            }


            void pid_tune(struct _pid *pid, float p_gain, float i_gain, float d_gain, int dead_band)
            {
            pid->pgain = p_gain;
            pid->igain = i_gain;
            pid->dgain = d_gain;
            pid->deadband = dead_band;
            pid->integral= integral_val;
            pid->last_error=0;
            }



            void pid_setinteg(struct _pid *pid,float new_integ)
            {
            pid->integral = new_integ;
            pid->last_error = 0;
            }


            void pid_bumpless(struct _pid *pid)
            {
            pid->last_error = (pid->sp)-(pid->pv); //設(shè)定值與反饋值偏差
            }




            float pid_calc(struct _pid *pid)
            int err;
            float pterm, dterm, result, ferror;

            // 計(jì)算偏差
            err = (pid->sp) - (pid->pv);

            // 判斷是否大于死區(qū)
            if (abs(err) > pid->deadband)
            {
            ferror = (float) err; //do integer to float conversion only once 數(shù)據(jù)類型轉(zhuǎn)換

            上一頁 1 2 下一頁

            關(guān)鍵詞: 單片機(jī)PID算

            評論


            技術(shù)專區(qū)

            關(guān)閉