女人叫床声_动漫美女被艹视频_国产精品短篇二区_理发店女人一级毛片

dcgdeng
級(jí)別: *
精華主題: * 篇
發(fā)帖數(shù)量: * 個(gè)
工控威望: * 點(diǎn)
下載積分: * 分
在線時(shí)間: (小時(shí))
注冊(cè)時(shí)間: *
最后登錄: *
查看dcgdeng的 主題 / 回貼
樓主  發(fā)表于: 2011-01-24 14:05


#include <REGX51.H>
#include <intrins.h>
#include <string.h>
#include <stdio.h>

typedef struct PID {

        double  SetPoint;          

        double  Proportion;        
        double  Integral;        
        double  Derivative;        

        double  LastError;        

        double  PrevError;          

        double  SumError;        

} PID;
double PIDCalc( PID *pp, double NextPoint )
{
    double  dError,
            Error;

        Error = pp->SetPoint -  NextPoint;        

        pp->SumError += Error;                    

        dError = pp->LastError - pp->PrevError;  

        pp->PrevError = pp->LastError;
        pp->LastError = Error;
        return (pp->Proportion * Error        

            +   pp->Integral * pp->SumError      

            +   pp->Derivative * dError            

        );
}
//////////////////////////////////////////////////////////////////////

void PIDInit (PID *pp)
{
    memset ( pp,0,sizeof(PID));
}



double sensor (void)                

    return 100.0;
}

void actuator(double rDelta)        {}

void man(void)
{
    PID         sPID;                  

    double      rOut;                  

    double      rIn;                  

    PIDInit ( &sPID );                

    sPID.Proportion = 0.5;            

    sPID.Integral   = 0.5;
    sPID.Derivative = 0.0;
    sPID.SetPoint   = 0.3;        

    for (;;) {                        

        rIn = adc ();                

        rOut = PIDCalc ( &sPID,rIn );
        actuator ( rOut );            

    }
}