void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
Yuqiao Hu:
上面的大部分的问题都解决了!
就这一句比较费解了:v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr; 这一句是用来求积分环节的,但是加粗部分很费解
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
rookiecalf:
回复 Yuqiao Hu:
积分是个累加的过程
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
Yuqiao Hu:
回复 rookiecalf:
但是也不是v->ui=v->ui+ 这样啊,应该是v->ui=v->ui1+这样吧
应该是在它原来的基础上累加吧!
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
rookiecalf:
回复 Yuqiao Hu:
ui1是什么量,你的代码中好像没有看到啊,如果等于前面计算的ui,那也是可以的
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
Yuqiao Hu:
回复 CHENG LIANG:
谢谢各位了!我忽略了v->Ui里面原来是有赋值的,就比如我曾经做的累加计算,Sum=Sum+i;
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
CHENG LIANG:
请问这个函数在哪里找到的?
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
user1088122:
回复 CHENG LIANG:
controlsuite的库里面,电机库
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
Yuqiao Hu:
回复 user1088122:
电机库在哪里啊!还有就是controlsuite里面到底有哪些内容?
void pid_reg3_calc(PIDREG3 *v)
{ // Compute the error
v->Err = v->Ref – v->Fdb;
// Compute the proportional output
v->Up = v->Kp*v->Err;
// Compute the integral output
v->Ui = v->Ui +v->Ki*v->Up + v->Kc*v->SatErr;
// Compute the derivative output
v->Ud = v->Kd*(v->Up – v->Up1);
// Compute the pre-saturated output
v->OutPreSat = v->Up + v->Ui + v->Ud;// v->OutPreSat =(v->OutPreSat>>24);
// Saturate the output
if (v->OutPreSat > v->OutMax) v->Out = v->OutMax;
else if (v->OutPreSat < v->OutMin)
v->Out = v->OutMin; else
v->Out = v->OutPreSat; // Compute the saturate difference
v->SatErr = v->Out – v->OutPreSat; // Update the previous proportional output v->Up1 = v->Up;}
囧:
回复 Yuqiao Hu:
C:\TI\controlSUITE\libs\app_libs\motor_control 电机库在controlsuite以下位置