42220082JOURNALOFSHANGHAIJIAOTONGUNIVERSITYVol.42No.2Feb.2008:2007201223:(19822),,,,,.(),,,(Tel.):021234206053;E2mail:xywang@sjtu.edu.cn.:100622467(2008)0220266204xPCLabVIEW,,,(,200240):xPC,xPC.xPC(API)/.xPC,xPC,,,,xPCLabVIEW.xPC.xPCLabVIEWxPC.:;xPC;;;LabVIEW:TP206.1;TP311:AAnalysisandUtilizationofInterfacebetweenxPCTargetandLabVIEWZHUYe,WANGXu2yong,TAOJian2feng,YANShu(MechatronicsInstitute,ShanghaiJiaotongUniversity,Shanghai200240,China)Abstract:TheprogrammingmethodofxPCtargetsmonitorwiththereal2timecontrolsystemwaspro2posed.TheinterfacebetweenthexPCtargetandvirtualinstrumentwasestablished.Theconnectionbe2tweenthetargetPCandhostPC,themonitoronthetargetxPCandtheexitofthetargetandhostsystembasedontheanalysisofthexPCtargetapplicationprogramminginterface(API)werediscussed.Thein2terfacebetweenxPCtargetandotherprogramminglanguageswasanalyzed.ThedatastructuredefinitioninthexPCtarget,datatypemapping,constantdefinitionandloadingDLL(dynamiclinkablelibrary)functionweresummarized.TheDLLbetweenxPCtargetandLabVIEWwasdesigned.Theprocessofcre2atingthehostPCsmonitorbyxPCtargetAPIinotherprogramminglanguageswaspresented.Thepro2gramofthexPCtargethostPCsmonitorbycreatingDLLandxPCtargetinterfacefunctioninLabVIEWwasimplemented.Keywords:real2timecontrolsystem;xPCtarget;hostmachine;interfacetechnology;LabVIEW,,.:[1],,,,.WDM(WindowsDriverModel)Win2dows[2].Windows.,WDM,,.MatlabxPC[3],,,,.Matlab,.xPC(Applica2tionProgrammingInterface,API)LabVIEW,LabVIEWWindowsxPC.Win2dows,,xPC.xPCAPILabVIEW,LabVIEW,,xPC.1xPCLabVIEW1.1xPCxPCMathWorksRTW,In2ter80x86/PentiumPC[4].xPC.xPC,Matlab,,,.xPCxPC.1.2xPCxPC9,:xPC;Matlab;Simulink;xPC(TargetScope);;web;Simulink;xPCAPI;xPCCOM(ComponentObjectModel)API.MatlabSimulink,.,,.xPCAPI.xPCAPIxPCCOMAPIxPC..xPCAPI.1.3LabVIEWLabVIEW,,[5].LabVIEW,(SystemExecVI).(CallLibraryFunc2tionNode,CLF)WindowsDLL,MacOS(Frameworks),Linux(SharedLibraries).(Codeinterfacenode,CIN).LabVIEWxPCCLF.CLF,Windows(DynamicLinkableLibrary,DLL).CLFDLL:LabVIEW,;..2LabVIEWxPC2.1xPCAPIxPCAPIC/C++,:(1).:,7622,:xPCLabVIEW.xPCAPI.:intxP2COpenSerialPort(intcomPort,intbaudRate);:intxPCOpenTcpIpPort(constchar3ipAddress,constchar3ipPort).(2)(.dlm).xPCxPC,.:voidxPCLoadApp(intport,constchar3pathstr,constchar3filename).(3).,xPCAPI:voidxPCStartApp(intport).(4).xPCAPI,:.:voidxPCSetStopTime(intport,doubletfinal);voidxPCSetSam2pleTime(intport,doublets)..ID,ID.ID:intxPCGetParamIdx(intport,constchar3blockName,constchar3paramName);ID.:voidxPC2SetParam(intport,intparamIdx,constdouble3paramValue)..:;(Scope)Scope.,ID,:intxPCGetSignalIdx(intport,constchar3sig2Name);:doublexPCGetSig2nal(intport,intsigNum);host;;,:voidxPCScGetData(intport,intscNum,intsig2nal-id,intstart,intnumsamples,intdecimation,double3data).(5).:voidxPCStopApp(intport).(6).,,xPCStart2App.voidxPCUnloadApp(intport).(7).voidxPCClosePort(intport).2.2xPCAPIxPCAPIxPCAPIxPC.xPCAPI:,Scope,Scope,xp2capiconst.h.MathWorkxpcapi.hxPCAPI,CxPCAPI.DLL,,,.DLL,DLL.xPCAPIDLL,APIxpcapi.dll.xPCCxpcapi.dllCxpcinitfree.c,intxPCInitAPI(void)xPCAPIDLL.DLL.xPCAPIDLL,xpcinitfree.cDLLvoidxPCFreeAPI(void).2.3LabVIEWxPCxPCCC,LabVIEWDLL,CCxPCAPI86242LabVIEWLabVIEWxPCAPI.VisualC++xPCAPI.VisualC++DLL:AppWizardWin32Dynaminc2LinkLibrary;;.xPCAPIC2xPCInitAPIxPCFreeAPI,xpcapi.dll.xPCAPI,xPCAPIC,API.xPCAPI,.LabVIEWxPCAPILabVIEWxPC.xPCAPICLabVIEW,charLabVIEW8(Signed82bitIntegerArray)xPCAPI2xPC,LabVIEW,xPC.1LabVIEWxPC.1LabVIEWFig.1xPCtargethostPCuserinterfacedevelopedbyLabVIEW3xPCAPI,xPCLabVIEW,LabVIEWxPC,.xPC,LabVIEW.xPCAPI;xPC,,;xPCLabVIEW,.:[1],,,.[J].,2006,40(2):351-354.YUShi2tao,TANWen2chun,GONGYuan2ming,etal.Theembeddedreal2timesoftwaresystemforhighpressurecommonrailelectroniccontrolsystem[J].JournalofShanghaiJiaotongUniversity,2006,40(2):351-354.[2],,,.Windows2000[J].,2006,23(4):83-85.LINXiao2fan,ZHANGSheng2yuan,PEIZhong2cai,etal.Theimplementationofthereal2timesoftwareofcontrolsystemunderWindows2000[J].Microelec2tronics&Computer,2006,23(4):83-85.[3],,,.xPC[J].,2005,27(4):737-739.ZHAIKun,YANGDi,LIUZhen2gang,etal.Appli2cationofxPCmethodtorealizetheturntablespositionservosystem[J].SystemsEngineeringandElectronics,2005,27(4):737-739.[4],,.[M].:,2002.[5],,,.LabVIEW7.1[M].:,2005.9622,:xPCLabVIEW