xPCTarget主讲教师姜洪洲机电学院PCIn-the-LoopRTWWindowsTargetxPCTargetMatlabSimulinkRealTimeWorkshopStateflowWhatisxPCTarget(1)采用Host-Target模式,基于PC的,快速开发实时应用的解决方案。HostPC:DesktopPC、LaptopPCTargetPC:DesktopPC、LaptopPC、IndustrialPC、CompactPCI、PXI、PC-104、SingleBoardPCWhatisxPCTarget(2)在hostPC上开发和建立程序在targetPC上,实时运行程序,进行信号的采集、参数的调整TargetPC为廉价的计算机硬件和接口板TargetPCRS232orTCP/IPHostPCFeaturesofxPCTargetRealTimeKernelRealTimeApplicationSignalAcquisitionParameterTuningReal-timekernelRealTimekernel基于德国On-time公司的RTTarget-32(与win32兼容的、针对x86嵌入式系统、32位保护模式实时操作系统)*.dlm(DynamicLinkableModule)TargetBootDiskTargetPCBIOSTargetPCheap返回Real-timeApplicationMemoryModel(WindowsNTapplicationwiththeflatmemorymodel)TaskExecutionTime返回SignalAcquisitionSignalMonitoringacquiringsignaldatawithouttimeinformationSignalLoggingacquiringsignaldataduringareal-timerunUploaddatafromthetargetPCaftertherunSignalTracingacquiringandvisualizingsignalsduringareal-timerunUploaddatawhilethetargetapplicationisrunning.返回ParameterTuningInteractivexPCTargetsupportsinteractivetuningofparameterswhilethetargetapplicationisrunninginrealtime.ThechangestoparametersareimmediatelyreflectedinthesignaloutputsScriptsandbatchproceduresxPCTargetalsoincludescommandstochangeparametersduringarunorbetweenruns.Bywritingascriptthatincrementallychangesaparameterandmonitorsasignaloutput,youcanoptimizethevalueofthatparameter返回SystemRequirementsandConfigurationofxPC(HOST)1.软件要求2.硬件要求SystemRequirementsandConfigurationofxPC(TARGET)1.软件要求2.硬件要求xPCTargetSetup命令xpcsetup内容:Compiler(WatcomC/C++,VisualC/C++)Host-TargetCommunication(RS232,TCP/IP)BootMode(bootdisk\standalone\DOSloader)xPCTargetEmbeddedOptionsBootdisk(floppydisk)DOSLoader(DOSboot+xpcboot.com)Standalone(DOSboot+xpcboot.com+model.rtb)xpcbootmodel.rtbAtuoexec.batDOSsystembootdiskCommunicationforhost-targetRS232(115200bps)Ethernet(10M/100MEthernetcard)Communicationfortarget-targetRS232(characterandbinarymode)UDPCANSharedmemory(SystranandSBS)xPCblocklibraryI/OdriverRS232CANSharedmemoryUDPScope/dngWatchdog......xPCTargetI/ODriverAdvantech(PCL-818,PCL-726)NationalInstruments.......CreatingI/ODriverusingCMEXSfunctionwillbediscussedinotherlectures.xPCTargetApplicationDevelopmentProcessSimulatingtheapplicationCreatingtheTargetApplication(bootandbuild)ControllingtheTargetApplicationSignalmonitoringSignaltracingSignalloggingParametertuning实时控制开发过程DevelopmentProcessofRealTimeControl1.系统建模(状态方程,传递函数)2.控制系统频域设计(系统线性化)3.建立Simulink模型(信号发生器、控制器、被控对象、示波器)4.控制系统时域响应优化(考虑非线性因素)5.连接并设置硬件(I/O卡、外部信号接线)6.分离控制器,加入A/D,D/A模块7.建立实时应用8.实时运行并测试9.在线调整参数、显示与存储数据10.数据处理与分析UserInteractionSimulinkmodelinexternalmodeMatlabcommandusingtargetobjectsTargetcommandlineWebinterface(xpc)xPCremotecontroltoolSimulinkDialsandGuagesToolboxxPCTargetAPItobediscussedinthenextlecturexPCTargetObject返回TargetCommand键盘快捷键c、F#、v、m应用管理命令start、stop、reboot、getpar、setpar、p#、s#示波器命令addsignalscope_index=signal_indexremsignal,addscope,remscope,scopemode,viewmode,ylimit,gridscope_indexon|off命令setvarvariable=p#=1返回目标机界面xPCTargetRemoteControlToolSignalAcquisition信号的采集xPCScope(target/host)MatlabcommandusingtargetobjectsTargetcommandWebinterface(xpc)xPCTargetAPIWebInterface(1)Inthematlabcommandline,typexpcOpenthedoscommandwindow,typec:\MATLAB6p5\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser-v-t22222-c1OpentheInternetExplorer,intheaddressbox,enter(2)返回DialsandGaugesToolbox(1)DialsandGaugesToolbox(2)xpc2dng(signalacquisition)dng2xpc(parametertuning)DialsandGaugesToolbox(3)返回UDP/IP与TCP/IPConnectionVersusConnectionlessStreamVersusPacketTCPisareliableprotocol,whileUDPisunreliableUDPandRealtimeCommunicationLightweightnatureDatatobeprocessedinsamplesDatatype(double,single,int32,int16)Packingandunpacking数据的无损传输双缓存技术100Mbps快速以太网TCP/IP协议t(s)t1t2t3t4t6t5数据采集数据发送数据采集数据采集数据发送Scope1触发信号SingleScopet3-t2时间段内的数据丢失数据采集数据发送数据采集数据发送数据采集数据发送t(s)数据采集数据发送Scope1Scope2触发信号DoubleScope无数据丢失Scope1Scope2[Scope1采集结束?][Scope2采集结束?]对试验进行全过程、全状态记录while(1)%loopuntilthescopehasfinishedwhile~strcmp(sc(scNum).Status,'Finished'),enddata(end+1:end+500,:)=sc(scNum).Data;t(end+1:end+500)=sc(scNum).Time;start(sc(scNum));%RestartthescopescNum=3-scNum;%SwitchtothenextscopeendSomeOpenIssuesDistributedRealTimeSimulation(Modelpartitioning,timingandnetworking)Oneconsistentchainoftoolsforthetool-baseddevelopmentIndependentexecutableGUIforxPCReferences参考资料GettingStartedGuide快速入门I/OReferenceGuide硬件支持User’sGuideManual用户手册APIUser’sandReferenceGuide应用编程接口•matlab\help\pdf\xpc\xpc_target_gs.pdf•matlab\help\pdf\xpc\xpc_target_io_ref.pdf•matlab\help\pdf\xpc\xpc_target_ug.pdfWheretofind:OnTimeRTOS-324.0RTTarget-32RTKernel-32RTFiles-32RTPEG-32RTIP-32PPPdriverFTPClient/Server•WebServer•SMTP/POP3Client•TELNETClient/Server•RTUSB-32OnTimeInformatikGmbH返回