完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
5个回答
|
|
罗尔夫
我听说你已经实现了discrite版本PID可以将编码发送到我的电子邮件ID:这对我有帮助.. 以上来自于谷歌翻译 以下为原文 Rolf i heard u have implement the discrite version PID can send the coding to my email id:it will helpful for me.. |
|
|
|
罗尔夫
我听说你已经实现了discrite版本PID可以将编码发送到我的电子邮件ID:这对我有帮助.. 以上来自于谷歌翻译 以下为原文 Rolf i heard u have implement the discrite version PID can send the coding to my email id:it will helpful for me.. |
|
|
|
罗尔夫
我听说你已经实现了discrite版本PID可以将编码发送到我的电子邮件ID:这对我有帮助.. 以上来自于谷歌翻译 以下为原文 Rolf i heard u have implement the discrite version PID can send the coding to my email id:it will helpful for me.. |
|
|
|
[嗨gforte
我有一个关于实现PI控制器闭环调节的想法。我需要汇编代码来实现。我希望它将用于实现PID控制器,请将它发送到我的地址mailto:n_muthukumaran@yahoo.com 以上来自于谷歌翻译 以下为原文 [hi gforte I have an idea about to implement PI controller closed loop regulation. I need the assembly code to implement.i hope it will use to implement the PID controller please send it to my address mailto:n_muthukumaran@yahoo.com |
|
|
|
你好,
这是一个PI(D)代码: s16 PID_Regulator(s16 hReference,s16 hPresentFeedback,PID_Struct_t * PID_Struct) { s32 wError,wProportional_Term,wIntegral_Term,houtput_32; s64 dwAux; #ifdef DIFFERENTIAL_TERM_ENABLED s32 wDifferential_Term; #万一 //错误计算 wError =(s32)(hReference - hPresentFeedback); //比例项计算 wProportional_Term = PID_Struct-&gt; hKp_Gain * wError; //积分项计算 if(PID_Struct-&gt; hKi_Gain == 0) { PID_Struct-&gt; wIntegral = 0; } 其他 { wIntegral_Term = PID_Struct-&gt; hKi_Gain * wError; dwAux = PID_Struct-&gt; wIntegral +(s64)(wIntegral_Term); if(dwAux&gt; PID_Struct-&gt; wUpper_Limit_Integral) { PID_Struct-&gt; wIntegral = PID_Struct-&gt; wUpper_Limit_Integral; } 否则if(dwAux&lt; PID_Struct-&gt; wLower_Limit_Integral) { PID_Struct-&gt; wIntegral = PID_Struct-&gt; wLower_Limit_Integral; } 其他 { PID_Struct-&gt; wIntegral =(s32)(dwAux); } } //差分项计算 #ifdef DIFFERENTIAL_TERM_ENABLED { s32 wtemp; wtemp = wError - PID_Struct-&gt; wPreviousError; wDifferential_Term = PID_Struct-&gt; hKd_Gain * wtemp; PID_Struct-&gt; wPreviousError = wError; //存储值 } houtput_32 =(wProportional_Term / PID_Struct-&gt; hKp_Divisor + PID_Struct-&gt; wIntegral / PID_Struct-&gt; hKi_Divisor + wDifferential_Term / PID_Struct-&GT; hKd_Divisor); #其他 houtput_32 =(wProportional_Term / PID_Struct-&gt; hKp_Divisor + PID_Struct-&GT; wIntegral / PID_Struct-&GT; hKi_Divisor); #万一 if(houtput_32&gt; = PID_Struct-&gt; hUpper_Limit_Output) { 返回(PID_Struct-&GT; hUpper_Limit_Output); } 否则if(houtput_32&lt; PID_Struct-&gt; hLower_Limit_Output) { 返回(PID_Struct-&GT; hLower_Limit_Output); } 其他 { 返回((S16)(houtput_32)); } 用 typedef结构 { s16 hKp_Gain; u16 hKp_Divisor; s16 hKi_Gain; u16 hKi_Divisor; s16 hLower_Limit_Output; //输出限制的下限 s16 hUpper_Limit_Output; //输出限制的下限 s32 wLower_Limit_Integral; //积分项限制的下限 s32 wUpper_Limit_Integral; //积分项限制的下限 s32 wIntegral; //实际上仅在启用了DIFFERENTIAL_TERM_ENABLED时使用 //stm32f10x_MCconf.h s16 hKd_Gain; u16 hKd_Divisor; s32 wPreviousError; } PID_Struct_t; 我让你找到更聪明的东西,以避免使用64位变量;-) 再见, Billino 以上来自于谷歌翻译 以下为原文 Hello, here is a PI(D) code: s16 PID_Regulator(s16 hReference, s16 hPresentFeedback, PID_Struct_t *PID_Struct) { s32 wError, wProportional_Term,wIntegral_Term, houtput_32; s64 dwAux; #ifdef DIFFERENTIAL_TERM_ENABLED s32 wDifferential_Term; #endif // error computation wError= (s32)(hReference - hPresentFeedback); // Proportional term computation wProportional_Term = PID_Struct->hKp_Gain * wError; // Integral term computation if (PID_Struct->hKi_Gain == 0) { PID_Struct->wIntegral = 0; } else { wIntegral_Term = PID_Struct->hKi_Gain * wError; dwAux = PID_Struct->wIntegral + (s64)(wIntegral_Term); if (dwAux > PID_Struct->wUpper_Limit_Integral) { PID_Struct->wIntegral = PID_Struct->wUpper_Limit_Integral; } else if (dwAux < PID_Struct->wLower_Limit_Integral) { PID_Struct->wIntegral = PID_Struct->wLower_Limit_Integral; } else { PID_Struct->wIntegral = (s32)(dwAux); } } // Differential term computation #ifdef DIFFERENTIAL_TERM_ENABLED { s32 wtemp; wtemp = wError - PID_Struct->wPreviousError; wDifferential_Term = PID_Struct->hKd_Gain * wtemp; PID_Struct->wPreviousError = wError; // store value } houtput_32 = (wProportional_Term/PID_Struct->hKp_Divisor+ PID_Struct->wIntegral/PID_Struct->hKi_Divisor + wDifferential_Term/PID_Struct->hKd_Divisor); #else houtput_32 = (wProportional_Term/PID_Struct->hKp_Divisor+ PID_Struct->wIntegral/PID_Struct->hKi_Divisor); #endif if (houtput_32 >= PID_Struct->hUpper_Limit_Output) { return(PID_Struct->hUpper_Limit_Output); } else if (houtput_32 < PID_Struct->hLower_Limit_Output) { return(PID_Struct->hLower_Limit_Output); } else { return((s16)(houtput_32)); } } with typedef struct { s16 hKp_Gain; u16 hKp_Divisor; s16 hKi_Gain; u16 hKi_Divisor; s16 hLower_Limit_Output; //Lower Limit for Output limitation s16 hUpper_Limit_Output; //Lower Limit for Output limitation s32 wLower_Limit_Integral; //Lower Limit for Integral term limitation s32 wUpper_Limit_Integral; //Lower Limit for Integral term limitation s32 wIntegral; // Actually used only if DIFFERENTIAL_TERM_ENABLED is enabled in //stm32f10x_MCconf.h s16 hKd_Gain; u16 hKd_Divisor; s32 wPreviousError; } PID_Struct_t; I let you find something smarter to avoid using 64 bit variable ;-) Ciao, Billino |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2724 浏览 1 评论
3237 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1807 浏览 1 评论
3646 浏览 6 评论
6034 浏览 21 评论
1336浏览 4评论
197浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
268浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 10:03 , Processed in 1.206792 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号