芯片解密,芯片破解,IC解密,单片机解密,MCU解密,STM解密

飞芯科技提供芯片解密,芯片破解,IC解密,单片机解密,MCU解密,STM解密逆向服务

单片机解密STC8G1K08-SOP8单片机制作定时控制程序

  1. 单片机解密#define Max_Cycle 290//限制幅度
  2. #define Min_Cycle -290
  3. typedef struct//结构体
  4. {
  5.    int targetValue;//设定值
  6.    int Error;//误差
  7.    int prevError;//上次误差
  8.    int Integral;//误差积分
  9.    float Kp;//比例系数
  10.    float Ki;//没用
  11.    float Kd;//微分系数
  12. }PID;
  13. int  Calc_PID(PID *pid,int Pos)//位置PID
  14. {
  15.    int output;
  16.    int Differential;//微分变量
  17.    
  18.    pid->Error = (pid->targetValue - Pos);                                        //      误差有正负
  19.    
  20.    pid->Integral += pid->Error;                                                                                //                   误差累计
  21.    
  22.    Differential = pid->Error - pid->prevError;    //       微分部分本次误差减去上次误差
  23.                        
  24.    output = (pid->Kp * pid->Error + pid->Integral * pid->Ki + pid->Kd * Differential);//通过比例 积分 微分参数算出输出控制量 可省略积分部分
  25.    
  26.    pid->prevError = pid->Error;                                                                                //       本次误差赋值为上次
  27.    
  28.    if(output>Max_Cycle)                           //        超过上限则输出恒定值
  29.      output = Max_Cycle;
  30.          
  31.          if(output<Min_Cycle)
  32.                  output = Min_Cycle;

  33.    return output;
  34. }


  35. void Init_PID_Parameter(void)
  36. {
  37.    xPID.targetValue = 2300; //  
  38.    yPID.targetValue = 2300;
  39.          xPID.Error = 0;
  40.          yPID.Error = 0;
  41.    xPID.prevError=0;
  42.          yPID.prevError=0;
  43.         
  44.    xPID.Ki = 0.0f;  
  45.    yPID.Ki = 0.0f;

  46.    xPID.Kp = 0.3f;
  47.    yPID.Kp = 0.3f;  
  48.   
  49.    xPID.Kd = 0.60f;
  50.    yPID.Kd = 0.60f;
  51. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.taihedz.cn
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信