dspc语言与simulink界面联结操作手册

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

聯年說行DSPC流流利DSP行Simulink聯參數料CSimulinkDC例說易立ii錄1.......................................................................................6...................................................7........................................................7........................................................13參數...............................21說.................................21立聯..........................................27例...................................32........................................................32..............................................................35論....................................................................................41錄....................................................................................42參料............................................................................48iii錄2-1DOSC...........................82-2C........................................132-3C............................................142-4CSimulink.....................................152-5DSP路...............................163-1..............................................223-2Simulink..................................223-3S-function參數..................................................253-4SimilinkDCPID參數.....253-5Mask................................................263-6參數..................................263-7參數..................................273-8..293-9參數......................303-10連Simulink例............................313-11料率.................................................314-1DSPDC334-2Matlab路.............................344-3DSP.......................................344-4MatlabC.......................................354-5dc_PID.MDL行....................................................394-6DCPID.............................................39iv4-7DCPID參數.........................................404-8料參數..................................404-9PID參數..................................40v1.說SyscorDSP聯CMatlab[1]Simulink[2]立參數說DSPCDSPC說SimulinkC行立SimulinkDSP聯立參數DC流立CSimulink說立論說6說SyscorCDSPTIC行DSP不CodeComposer[3]DOS路DOS立行路CC:\DSP240\C24XHLL錄例syscor.bat列路更路錄錄行錄路DOS(edit)(compile)行DSPTTY.EXEDOSprompt理dsp24x.batCtest.cDOS令C:\DSP24XTEST72-1C令不.C2-1[1]錄[2]行EDIT.COM[3]行EDIT.COM便行[4]C[5]行DSPTTY.EXE便DSP行[6]DOS[0]離DSP24X.BAT列8910[4]令dspcl-k-rAR6-rAR7-v2xx%1-ztest.cmdcopya.out%1.outDSPCL.EXE行a.out料IOtest.cmdDSP參[4]test.cmd列11test.cmd行聯-lc:\dspcopy\C24XHLL\C24XTOOL\RTS2xx.lib路聯DOS2-2DOSEDIT.COM行12C參見2-3參數參數online_loopoffline_loopmain_loop來參數DC例說CDSPI/O#defineMAIN#includef24x.h#includeacm4.h#includemotion.h13參數參數路路率參數CDSP聯參數類參數Simulink參2-42-4DCPID令(cmd)(fbk)量(out)PID參數例益(kp)益(ki)益(kd)(ilim)參錄DSP數(ACM4.H)數1288000-807f(128):file_buffer[128]14參數PID例#definecmd(PLC_data[0x8000])#definefbk(PLC_data[0x8001])#defineout(PLC_data[0x8002])#definekp(PLC_data[0x8003])#defineki(PLC_data[0x8004])#definekd(PLC_data[0x8005])#defineilim(PLC_data[0x8006])參數參數力/*數*/staticintpht,pnew,pold,pdif;/*數*/staticintpwmout,uerr,uold,usum;/*prototype*/voidmain_loop(void);voidpid_control(void);15(main)CDSP4kHzonline_loop()offline_loop()路syscor說[5]2不路online_loopoffline_looponline_loop行(0.25ms)行offline_loop2-5(a)(b)online_loop4kHzoffline_loop若行(c)路列voidmain(void){16/*online_loopoffline_loop4kHz*/if(PLC_start_come()){asm(lacc#_offline_loop);asm(ldp#0);asm(saclPLC_aLoop);asm(lacc#_online_loop);asm(ldp#0);asm(saclPLC_aIntr);}main_loop();/*路*/}online_loop精率4kHz例流例voidonline_loop(void){pnew=IOPHT2;if((pdif=(pnew-pold))&0x80)pdif|=0xff00;elsepdif&=0x00ff;pht+=pdif;pold=pnew;}4kHz率料讀量1byte256highbytelowbytephthigh/lowbyteword(2bytes)度1732bitsoffline_loop例不main_loopC行PLC_start_come()PLC_stop_come()PLC_start_come()行DCPLC_stop_come()DCPWM路列voidmain_loop(void){if(PLC_start_come()){IOPWM2A=128;/*PWM0(128量)*/IOPWMMD=0x01;/*IOPORTPWM*/IOPA=0xf0;/*DCPWM*/pold=IOPHT2;/*讀*/pht=0;/**/fgCmd=500;/*令*/PLC_data[120]=0x30;/*DSP*/}if(PLC_stop_come()){IOPA=0x0f;/*DCPWM*/return;}if((PLC_nIntr%4)!=0)return;/*率1kHz*/pid_control();/*PID*/}18DSP4kHz數PLC_nIntr1數數來路率PLC_nIntr4(1kHz)行PID理論PIDonline_loop()不易PIDmain_loop()率精度不PID2不不理論路DCPIDpid_control()列voidpid_control(void){/*DSP數令(cmd)*/cmd=fgCmd;/*量*/uerr=cmd-pht;/*PID量*/out=(int)(((long)kp*uerr)/1024)+(((long)ki*usum)/4096)+(((long)kd*(uerr-uold))/1024);/*量PWM*/if(out127)out=127;if(out-127)out=-127;pwmout=out+128;IOPWM2A=pwmout;/**/if((usum+=uerr)ilim)usum=ilim;elseif(usum-ilim)usum=-ilim;19/*參數*/uold=uerr;fbk=pht;}PID量益10244096參數RS-232數便利DSP16理度留數精度數來PID量量10244096數精度行參數例PIDkp/1024ki/4096kd/1024例益例1.0DSP1024列DCPID例20參數行DCDSPC說說Matlab/Simulink立SimulinkDSP行聯Simulink參數料益說說立令3-1立參見→→拉立行拉3-3參數欄參數欄參數來21欄參數參數數參說參數欄參數22參數#definecmd(PLC_data[0x8000])→0x8000=8*16^3=32768#definefbk(PLC_data[0x8001])→0x8001=8*16^3+1=32769#defineout(PLC_data[0x8002])→0x8002=8*16^3+2=32770#definekp(PLC_data[0x8003])→0x8003=8*16^3+3=32771#defineki(PLC_data[0x8004])→0x8004=8*16^3+4=32772#definekd(PLC_data[0x8005])→0x8005=8*16^3+5=32773#defineilim(PLC_data[0x8006])→0x8006=8*16^3+6=32774參數參數數不參數參數…類參數…類參數數例益參數欄參數參見參數來參數→參數參數類Icon()Initialization(數

1 / 48
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功