下载

1下载券

加入VIP
  • 专属下载券
  • 上传内容扩展
  • 资料优先审核
  • 免费资料无限下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 PIC单片机应用开发典型模块各章程序第六章程序

PIC单片机应用开发典型模块各章程序第六章程序.doc

PIC单片机应用开发典型模块各章程序第六章程序

WindomZhong
2018-09-08 0人阅读 举报 0 0 0 暂无简介

简介:本文档为《PIC单片机应用开发典型模块各章程序第六章程序doc》,可适用于IT/计算机领域

()位置式PID控制算法代码#include"mathh"structPIDData{struct{floatuc输入命令值floaty实际测量值floatu实际控制器输出值floatv控制器输出的一个比较值}Signalsstruct{floatP比例控制器输出值floatI积分器输出值floatD微分器输出值floatyoldy(k)t的值floatSi积分分离算法时误差的判断点}Statesstruct{floatK比例增益floatTi积分时间常数floatTd微分时间常数floatN最大位分增益floatulow控制器输出最小值floatuhigh控制器输出最大值floatT采样周期floatKi,ar,bd,ad中间变量}Par}piddataPID初始化子函数voidPIDInit(structPIDData*data){data>StatesI=data>StatesD=data>Statesyold=data>ParK=data>ParTi=data>ParTd=data>ParN=data>Parulow=data>Paruhigh=data>ParT=data>ParKi=(data>ParK)*(data>ParT)(data>ParTi)计算Kidata>Parbd=(data>ParK)*(data>ParN)*(data>ParTd)(data>ParTddata>ParN*data>ParT)data>Parad=data>ParTd(data>ParTddata>ParN*data>ParT)}voidPIDCalculateOutput(structPIDData*data){比例控制器输出data>StatesP=data>ParK*(data>Signalsucdata>Signalsy)微分控制器输出data>StatesD=data>Parad*data>StatesDdata>Parbd*(data>Signalsydata>Statesyold)积分控制器的输出data>StatesI=data>StatesIdata>ParKi*(data>Signalsucdata>Signalsy)计算控制器的输出data>Signalsv=data>StatesPdata>StatesIdata>StatesD判断实际控制器的输出if(data>Signalsv<data>Parulow){data>Signalsu=data>Parulow}elseif(data>Signalsv>data>Paruhigh){data>Signalsu=data>Paruhigh}else{data>Signalsu=data>Signalsv}data>Statesyold=data>Signalsy}voidPIDMain(){PIDInit(piddata)while(){PIDCalculateOutput(piddata)}}()增量式PID控制算法structPIDData{struct{floatuc输入命令值floaty实际测量值}Signalsstruct{doubleu实际控制器输出值doubledetaudoubleuu(k)tdoubleuu(k)tdoubleyy(k)tdoubleyy(k)tdoubleerrordoubleerrordoubleerrordoublekpdoublekidoublekd}Statesstruct{doublexdoublexdoublex}Par}piddataPID参数初始化voidPIDInit(structPIDData*data){data>Signalsuc=data>Statesdetau=data>Statesu=data>Statesu=data>Statesy=data>Statesy=data>Stateskp=data>Stateski=data>Stateskd=data>Stateserror=data>Stateserror=data>Parx=data>Parx=data>Parx=}增量式PID算法控制输出计算voidPIDCalculateOutput(structPIDData*data){intk=data>Signalsy=QepCNTB控制器输出增量值data>Statesdetau=data>Stateskp*data>Parxdata>Stateski*data>Parxdata>Stateskd*data>Parx计算控制器输出data>Statesu=data>Statesudata>Statesdetau判断实际控制器输出if(data>Statesu>){data>Statesu=}elseif(data>Statesu<){data>Statesu=}else{data>Statesu=data>Statesu}data>Stateserror=data>Signalsucdata>Signalsydata>Statesu=data>Statesudata>Statesu=data>Statesudata>Statesy=data>Statesydata>Statesy=data>Signalsydata>Parx=data>Stateserrordata>Stateserrordata>Parx=data>Stateserror*data>Stateserrordata>Stateserrordata>Parx=data>Stateserrordata>Stateserror=data>Stateserrordata>Stateserror=data>Stateserror}()单神经元自适应控制PID算法#include"mathh"structPIDData{struct{doubleuc输入命令值doubley实际测量值doubleu实际控制器输出值doubleuu(k)doublev控制器输出的一个比较量}Signalsstruct{longxitePlongxiteIlongxiteDlongyoldy(k)t的值longerrore(k)longerrore(k)longerrore(k)}Statesstruct{intK总比例系数longwkplongwkilongwkdlongwkplongwkilongwkd}Par}piddatavoidPIDInit(structPIDData*data){data>Signalsu=data>StatesxiteP=data>StatesxiteI=data>StatesxiteD=data>Statesyold=data>Stateserror=data>Stateserror=data>Parwkp=data>Parwki=data>Parwkd=data>ParK=}voidPIDCalculateOutput(structPIDData*data){longx,x,xlongwaddlongw,w,wdata>Stateserror=data>Signalsucdata>Signalsydata>Parwkp=data>Parwkpdata>StatesxiteP*data>Stateserror*data>Signalsu*(*data>Stateserrordata>Stateserror)data>Parwki=data>Parwkidata>StatesxiteI*data>Stateserror*data>Signalsu*(*data>Stateserrordata>Stateserror)data>Parwkd=data>Parwkddata>StatesxiteD*data>Stateserror*data>Signalsu*(*data>Stateserrordata>Stateserror)x=data>Stateserrordata>Stateserrorx=data>Stateserrorx=data>Stateserror*data>Stateserrordata>Stateserrorwadd=fabs(data>Parwkp)fabs(data>Parwki)fabs(data>Parwkd)w=data>Parwkpwaddw=data>Parwkiwaddw=data>Parwkdwadddata>Signalsv=data>Signalsudata>ParK*(x*wx*wx*w)if(data>Signalsv>)data>Signalsu=elseif(data>Signalsv<)data>Signalsu=elsedata>Signalsu=data>Signalsvdata>Stateserror=data>Stateserrordata>Stateserror=data>Stateserrordata>Signalsu=data>Signalsu}

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

评分:

/6

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利